How to throttle down engine cpu usage

Godot Version

4.2 Mono

Question

I am trying to throttle down the cpu usage of the engine. I am working on a program that does not need to update the state so often, it need to update the state just when the user make some input.

I have trying to make the cpu usage lower by using the following code:

            RenderingServer.RenderLoopEnabled = false;
            Engine.MaxFps = 1;
            
            PhysicsServer2D.SetActive(false);
            PhysicsServer3D.SetActive(false);
            GetTree().Paused = true;
            
            OS.LowProcessorUsageMode = true;
            OS.LowProcessorUsageModeSleepUsec = 100000;

Even with all of that at the same time the cpu usage is maxed in one core. Also tested Thread.Sleep()

Plase note that the code is just a test. I was expecting that at least at 1 FPS, not rendering and disabling some systems the CPU usage would decrease but is not.

Is this a bug?

There is a way to control the update of the engine?

Thanks

I think you can go to Common in Physics setting and decrease the Physics Ticks per Second to 1 then try to use the Physics Process function

Already tested that without success, also I guess setting

PhysicsServer2D.SetActive(false);
PhysicsServer3D.SetActive(false);

should disable the physics completely

Instead of in code, set low processor mode in project settings.
image
Then, in your scene, make sure nothing is drawn. It will run at the FPS set on Max FPS in the project settings. This is because it is still checking for input and signals. It should have <10% CPU usage this way. It may be a bug if setting this in code has no effect.

Thanks for your response. I also done it in the project settings and I am sure the project is running at 1 fps. But the cpu usage still at max I will do more in depth profiling using some tool to see all threads that are running.

I can tell you this does not happen in my computer, but of course, that depends on the hardware you have, so… not much help =/

After profiling the threads I found a thread that I created time before and I forgot about it and that was the reason I was seeing the Cpu Core at max speed. Sorry about the time lost. Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.