Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background / sleep mode (to stop CPU hugging) #29257

Closed
ballerburg9005 opened this issue May 28, 2019 · 6 comments
Closed

Background / sleep mode (to stop CPU hugging) #29257

ballerburg9005 opened this issue May 28, 2019 · 6 comments

Comments

@ballerburg9005
Copy link

It has nothing to do with any particular version, code or OS.

I noticed that it happens all the time for no particular reason at all that Godot is very generously consuming 20%, 50%, or sometimes 80%+ CPU while essentially idling. The program isn't crashed or hung when that is the case, you can use it normally. It isn't a bug that this happens, its understandable, and by itself needs no fixing.

Regardless to me its a huge deal, because I only casually develop games. I leave the program open in the background and then only do 15 minutes here and there throughout the day while watching TV or cleaning my house or whatever.

So 95% of the time the program is idling and driving my notebook fan to high noise plus I suspect my power bill up by 5-10 Euros a month (I live in Germany ... its that expensive here).

If you are developing on a professional level, you start the program, work on your project and then you just close it the end of the day. No issue at all.

But with casual development in your kitchen or on the couch, its not like that. Either the fan noise or the slowdown (or even just fear of possible slowdown) or environmental concern will force you to like open and close the program 20 times a day, as to just use it when needed. This is very unproductive and its so off-putting to start the program that you maybe don't start it at all anymore a lot of times.

I propose a feature to enable "sleep mode". So you could check the feature in the options to kick in like after 5 minutes if the Godot window is not active. This would entirely cure the issue for casual home developers.

@mhilbrunner
Copy link
Member

mhilbrunner commented May 28, 2019

Hey! Thanks for your report.

A couple of things:

Godot is very generously consuming 20%, 50%, or sometimes 80%+ CPU while essentially idling. The program isn't crashed or hung when that is the case, you can use it normally. It isn't a bug that this happens, its understandable, and by itself needs no fixing.

Depending on how often and long that happens and how small or large your project is, I wouldn't dismiss this as not a bug that fast.
For me, Godot idles at 0%, maybe 0.1%, and when actually using the editor it rarely goes above 3-5% CPU usage - higher, of course, in very heavy 3D scenes, but still.

Even on my older laptops I haven't noticed anything close to this.

So can we get more information about your projects, their size, what features you use, and your hardware and OS, and the Godot version you use? Do you use Mono/C#?

The other thing is that there is a low processor usage mode already. Do you have that enabled, and if so, does it help?

@mhilbrunner mhilbrunner changed the title [feature request] background / sleep mode (to stop CPU hugging) Background / sleep mode (to stop CPU hugging) May 28, 2019
@mhilbrunner
Copy link
Member

Another thing:

... will force you to like open and close the program 20 times a day, as to just use it when needed. This is very unproductive and its so off-putting to start the program that you maybe don't start it at all anymore a lot of times.

How long does it take to open the Godot editor and your project, on average, if you had to give an estimate?

@Calinou
Copy link
Member

Calinou commented May 28, 2019

@mhilbrunner The low-processor usage mode is enabled by default in the editor, unless you click the update spinner in the top-right corner and set the update mode to Update Always (which is now considered deprecated).

There are several things that can cause high CPU/GPU usage when using the editor:

  • Something is causing the editor to repaint continuously (such as emitting particles), and rightfully so – otherwise, you wouldn't be able to see animations in the editor. This could be solved using an editor option to pause continuous simulations, see Ability to pause particle simulation in the editor #16397.
  • Something is causing the editor to repaint continuously, but it shouldn't. This is a bug that should be fixed.
  • The editor currently doesn't use a lower FPS cap when the window is unfocused or behind another window. We could also have a setting for this, but if we default to a low value (say, 20 FPS), people might wonder why particle simulations look choppy when the editor window isn't focused.
    • We could do this by default when the editor window is behind another window, but we don't have an API for this yet. It's technically possible (see Chromium), but not particularly easy.

@mhilbrunner
Copy link
Member

@Calinou Do we do this if the window is minimized?

@Calinou
Copy link
Member

Calinou commented May 29, 2019

@mhilbrunner It looks like CPU usage isn't decreasing much if I minimize the editor while having visible emitting particles (tested on Linux). This could probably be fixed by decreasing the FPS cap while the editor is minimized, but I'm not seeing any related signals in the MainLoop.NOTIFICATION_* constants that we could use for this, only an OS.window_minimized property.

Calinou added a commit to Calinou/godot that referenced this issue May 30, 2019

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
This decreases CPU/GPU usage when the window is unfocused, which can
be beneficial to laptop users.

This also makes the low-processor mode sleep project setting no longer
affect the editor. Instead, two new editor settings now define the
duration of sleeping when the editor is focused and unfocused.

This closes godotengine#24209 and partially addresses godotengine#29257.
@Calinou
Copy link
Member

Calinou commented Jul 29, 2019

I believe this is fixed by #29297, so I'll close this. If you need further power savings, you can increase Low Processor Mode Sleep Usec and Unfocused Low Processor Mode Sleep Usec in the Editor Settings (both values are in microseconds).

@Calinou Calinou closed this as completed Jul 29, 2019
@akien-mga akien-mga added this to the 3.2 milestone Jul 29, 2019
myhalibobo pushed a commit to myhalibobo/godot that referenced this issue Sep 3, 2019
This decreases CPU/GPU usage when the window is unfocused, which can
be beneficial to laptop users.

This also makes the low-processor mode sleep project setting no longer
affect the editor. Instead, two new editor settings now define the
duration of sleeping when the editor is focused and unfocused.

This closes godotengine#24209 and partially addresses godotengine#29257.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants