Understanding profiler behavior

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AUD_FOR_IUV

Hey all,

I’ve been working on an initial optimization pass for my game now that I’m visiting family and stuck using my old shitty laptop for development. I’ve made some decent progress but I’ve hit a bit of a wall and I want to understand whether there’s any headroom left for this or if I’m fundamentally limited by my subpar hardware at this point.

I’ve been using Godot’s built-in profiler to try and pinpoint problematic code paths and I’ve had some great initial success with this. Basically, I start the profiler on game startup and continue until I start experiencing fairly consistent stutter (my current problem), then I go back and see if there are specific script functions that are causing issues.

However, I’m wondering now whether there’s any more room for improvement in some cases given some strange behavior I’ve noticed: mainly, that script functions are no longer really showing up as problematic on the profiler (except for the occasional single-frame spike), despite the fact that the game is stuttering and that the idle (and to a lesser extent, physics) frame times are still pretty bad (e.g. 40+ ms).

My hypothesis is that the profiler is actually measuring “wall clock time”, and not the actual in-process time that the game is taking. That is, supposing my shitty laptop CPU is also running a million other background processes, the profiler is reporting huge idle times because the actual game process is being constantly scheduled out to make time for other CPU-intensive processes, and thus doesn’t get a chance to run enough to produce a solid 60 fps.

Does anyone know if this is the case? That is, does Godot’s profiler measure just the time that the game process takes to run when scheduled, or does it measure that wall clock time which would presumably include all other processes running on my laptop? If it’s measuring just the game process’ time, then I may still have room for improvement. But if it’s measuring wall clock time, then it’s hard for me to know whether I’ve hit a wall and just have to deal with the fact that my CPU is too underpowered.

Thanks in advance!