High CPU load in background
Moderator: GZDoom Developers
Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
High CPU load in background
I have just noticed that the game consumes one CPU core at 100% while in background.
The game state doesn't matter, even in the main menu CPU load will jump to top from a few percent when the game window loses focus.
The version 2.8pre-804 is OK, but 2.8pre-807 already has the mentioned problem.
It was quite easy to reveal that it's because of this commit.
It doesn't really matter on desktop, but for mobile users this may be an issue. I noticed that because of a fan noise while ZDoom's window was minimized.
It looks more like a bug rather than a "feature". What do you think, edward850?
The game state doesn't matter, even in the main menu CPU load will jump to top from a few percent when the game window loses focus.
The version 2.8pre-804 is OK, but 2.8pre-807 already has the mentioned problem.
It was quite easy to reveal that it's because of this commit.
It doesn't really matter on desktop, but for mobile users this may be an issue. I noticed that because of a fan noise while ZDoom's window was minimized.
It looks more like a bug rather than a "feature". What do you think, edward850?
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: High CPU load in background
Oh, it does matter on desktop. I noticed it too, yesterday, when launching two instances of GZDoom in parallel. Normally this wouldn't have caused any problems but with both running at full load it nearly ground my system to a halt.
So, two options:
a) a reasonable fix is provided
b) the commit is reverted.
I can't accept the current behavior.
So, two options:
a) a reasonable fix is provided
b) the commit is reverted.
I can't accept the current behavior.
Re: High CPU load in background
How about conditioning the new behavior to be only enabled when playing or recording a demo?
Re: High CPU load in background
After toying with the rewind function a little bit, I think I may have a grasp on what the actual bug was. Something about how g_ticker is key control for pausing everything, despite itself being a critcal aspect doesn't make much sense, and it's screwing with player input a lot. It needs to stop running the playsim entirely, while still ticking.
Unless someone beats me to it, I may restructure it a little bit to make it more sane. (And maybe make timedemo a little less fatal.)
As for why my current fix is causing problems? I honestly never noticed them. It doesn't seem to cause any sort of unreasonable load on my system.
Funny that.
Unless someone beats me to it, I may restructure it a little bit to make it more sane. (And maybe make timedemo a little less fatal.)
As for why my current fix is causing problems? I honestly never noticed them. It doesn't seem to cause any sort of unreasonable load on my system.
Funny that.
Re: High CPU load in background
It turns the Pi into a small oven, so there's that.
Re: High CPU load in background
So, you're cooking the Pi?
No idea why, but I'm just not getting this problem. I can run multiple instances of ZDoom or GZDoom, windowed or not and still have a perfectly responsive machine.

No idea why, but I'm just not getting this problem. I can run multiple instances of ZDoom or GZDoom, windowed or not and still have a perfectly responsive machine.

- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: High CPU load in background
Amazing that it's still responsive with this high CPU load... If you add up the percentages you are at 100%.
Re: High CPU load in background
Well, there's 2% left over... 
No idea why it was still working fine and, although I don't remember what the values were, presumably some of the other processes were doing something that had a CPU load.
I know it sounds like a silly question but can the CPU usage as reported in the task manager go above 100%? I know CPU usage can't actually be above 100% but perhaps there is something about how usage is reported?
[edit]
My computer got a little bit choppy this time as it flitted between giving attention to different instances but, once I had a particular game in focus, I was still able to play that copy of the game (Doom2 map01) with no obvious difficulties:

No idea why it was still working fine and, although I don't remember what the values were, presumably some of the other processes were doing something that had a CPU load.
I know it sounds like a silly question but can the CPU usage as reported in the task manager go above 100%? I know CPU usage can't actually be above 100% but perhaps there is something about how usage is reported?
[edit]
My computer got a little bit choppy this time as it flitted between giving attention to different instances but, once I had a particular game in focus, I was still able to play that copy of the game (Doom2 map01) with no obvious difficulties:
Spoiler:
Re: High CPU load in background
Any statistics can go above 100% due to rounding effects.
To give a simple example: Suppose you have 15 processes and they all inflict a perfectly identical workload on the CPU. 100/15=6.66666666666....% The CPU usage function reports an integer, so it rounds it up to 7%. Then when you make the tally, 15*7=105, so the reported CPU load is 105%.
To give a simple example: Suppose you have 15 processes and they all inflict a perfectly identical workload on the CPU. 100/15=6.66666666666....% The CPU usage function reports an integer, so it rounds it up to 7%. Then when you make the tally, 15*7=105, so the reported CPU load is 105%.
Re: High CPU load in background
Windows gives a slight priority boost to the application with the active window, so that's probably why.Enjay wrote:once I had a particular game in focus, I was still able to play that copy of the game (Doom2 map01) with no obvious difficulties:
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: High CPU load in background
Will anything be done about this? It's really annoying and if nothing happens I'll be forced to undo it as it causes a shitload of problems if the game is put in the background.
Here's another one:
http://forum.drdteam.org/viewtopic.php?f=24&t=6527
Here's another one:
http://forum.drdteam.org/viewtopic.php?f=24&t=6527
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: High CPU load in background
I'll check this evening.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: High CPU load in background
Applied, now I need to run some tests.
Re: High CPU load in background
Can't test on Windows at the moment, but on OS X the issue is gone.
Taking into account that excessive CPU load was caused by a busy loop in common code, the problem should be solved for all platforms. Running multiple instances should be smooth now.
Taking into account that excessive CPU load was caused by a busy loop in common code, the problem should be solved for all platforms. Running multiple instances should be smooth now.