Not sure if anyone else noticed this, but I’ve always had an issue with Defold using so much more CPU than I’d expect it to. Today I was playing around with game.project and found out that disabling sound threading lowered average CPU usage from ~40% to ~10%.
This is an HP Elitebook 840r G4 with Intel Core i5-7300U @ 2.60Gz running Windows 10.
I don’t necessarily need the threading, but this is interesting considering that thread on is default. I’ve been experiencing a lot of audio cracking and with this project from CPU issues (entire computer lags) and this had been a contributing to it.
Not sure what category to put this one in, but any thoughts?
Interesting. On macOS I see more or less the same CPU usage with and without the Sound Thread.
Can you share a bit more info about your project? How many sounds are you playing? Which format? Which sample rate? What does the engine show on startup?
The game contains multiple sound files and components, but at the time it was only playing 1 song, an ogg file (loaded from disk and resource.set_sound’d onto a sound component) with a 44.1k sample rate.
Thanks. I’m still not able to reproduce the CPU usage difference. I’m seeing the same usage (~28-30%) with and without using sound threads. I stripped down the project further:
I’d also like you to test the CPU usage with other tools, such as Process Explorer.
(The reason for that is that I’ve heard Windows’ CPU measurements may a little bit misleading sometimes)
I’ve now also tested on Windows 10 on a fairly low end PC and when measuring with the Windows task Manager I barely reach 2% CPU usage with and without threads. It is very strange that we are getting so very different results.
I still see the same effect, though Process Explorer does show it running with 66-80% of what task manager says, there is still a significant increase shown by it (without → 1-2%, with → 20-30%). I’ll now create a 48k version of the file to see if that’s the issue. But I am confused why the system is 48k instead of 44.1k? What is Defold reading when it prints these messages?