Question about Profile behavior. Outside VS GPU Latency.

Dear all,

this may eventually turn into a thread about Logic optimization, but right now I have a few concerns about Profile behavior.

Please note that I’ve already read Moguri’s “BGE Profile Stats and What They Mean” post on his blog, but this didn’t seem to end my doubts.

Here is the situation:

Suppose you have the default cube rotating around its Z axis and nothing more. “Use frame rate” in the Property panel is checked and Vsync is turned Off

This is the profile I get:


Within this situation, if I check my OS Task Manager, I see Blender is using about 20% of my CPU.

Same situation, this time “Use frame rate” is unchecked and Vsync is still Off:


Within this situation Task Manager shows Blender is using about 3% of my CPU.

I really don’t know how to interpret all this.

If you take for example the latest situation, I would expect Blender starting a Game Loop each 1/60 s (about 16,7 ms). This is just because, in absence of a given Logic Frame Rate, it seems to me that BGE sets it to the current display refresh rate (I’ve tested this on a 120Hz refresh rate display where logic speed seems to doulbe due to the higher refresh rate - indeed the Cube is rotating faster).
So, due to the current Scene simplicity, I would expect both the Scene Loop and the Render phase to end pretty soon, followed by the GPU buffer swap.
A Profile that would make sense for me in this situation would be something like this:

Outside --> almost 0%
Rasterizer --> almost 0%
GPU Latency --> almost 0%
Waiting for a new Game Loop to start (not existing entry in the current Profile!) --> about 99%

As for the moment it seems like non-processing time eventually ends up either in the Outside entry or in the GPU Latency entry, which makes it seem like some external process or Vsync delay is waisting your time.
Moreover I don’t understand why Unchecking “Use frame rate” would spare about 17% of my CPU usage if, in the end, the Logic Frame Rate still remain 60 FPS.

Sorry for the dull explanation, but I couldn’t find a better way to point out my concerns…

NIV

PS: Please see attached if you don’t want to reproduce the above-mentioned Scene by yourself

Attachments

Profile_concerns.blend (481 KB)

My guess is that your graphics driver is not respecting the application vsync settings and still forcing vsync. Check your graphics card’s settings (e.g., via Nvidia Control Panel or Catalyst).

Right now I’m working on a mid-2012 Macbook Pro with integrated Intel HD Graphics 4000. I really do not have any control on this, no Control Panel at all or anything else (at least that I’m aware of…).
I did a few tests on a Desktop with NVIDA GeForce GTX 660Ti, but since this didn’t seem to help me understanding the Profile behavior I went back on my Laptop after a little. I didn’t play with the Control Panel settings though. I’ll post here some results ASAP.

Still, there is a theoretical question that I think you may be able to answer regardless of the hardware context: where does the “idle time” ends up in Profile? By “idle time” I mean the time that neither the CPU nor the GPU are processing or waiting for anything. The time that there should pass before a new Game Loop starts, if the previous Game Loop (including buffers swap) ended up soon enough.

I’ve done extensive tests on my Desktop PC (Windows 7 + GTX 660Ti)

Please note that the Display is a native 120Hz PC Monitor

Here it comes the output:

Vsync OFF - NO Given Frame Rate


Vsync ON - NO Given Frame Rate




Vsync ON - Given Frame Rate 240 fps


No surprises here, when Vsync is ON, Sync time shows up in the GPU Latency entry, as it should.

When Vsync is OFF I get 1600 fps :smiley:

Here is when things start to get interesting

Vsync OFF - Given Frame Rate 60 fps


Vsync OFF - Given Frame Rate 120 fps



Vsync OFF - Given Frame Rate 240 fps


Vsync OFF - Given Frame Rate 360 fps

[ATTACH=CONFIG]336219[/ATTACH]

Vsync OFF - Given Frame Rate 480 fps

[ATTACH=CONFIG]336218[/ATTACH]

IMHO the interesting fact here is that “idle time” shows up either as Service time or Outside time, making you think that something on your PC is waisting processing time (or someone behind you is pushing all your keyboard keys simultaneously! :smiley: ).
As the progressive reduction shows, these (Service + Outside) are NOT real processing times! It’s just your CPU waiting to begin a new Game Loop according to your Frame Rate setting. If it wasn’t for that setting, the Game Loop would have ended after 0.6 ms (as shown in the Vsync OFF - No Given Frame Rate case), which makes completely sense, considering the simplicity of the current Scene.

Outside should be the time spent “outside” of the main game loop. I’m not sure what is causing services to take up time; I’m guessing there is a wait somewhere.

If I had some external tasks that were consuming processing time, those would have shown up in the Outside entry too. In my opinion, this is sort of misleading. One can never know how much time is spent “outside” the game loop “doing nothing” and how much time is spent “outside” the Game Loop “doing stuff”, because some external applications demand CPU. The first (“doing nothing” time) will automatically convert into Game Loop time in case of need, the latest (“doing stuff time”) won’t.

Regarding Services I’m going to check on my desktop if there’s any device or interface application which is causing this behavior. However, it is clear that this is not real processing time, as it shrinks while Frame Rate increases.

I’ve looked into the Services time thing.
As far as I can see there is nothing on my desktop that could cause this entry to take up time, even though this is not real processing time, as already said. I’ve practically made Blender the only application running on the PC, without any external devices plugged in apart from mouse and keyboard…

I would be curious to see if I’m the only one experiencing this Profile behavior…

Anyway, right now my primary concern is the one about the Outside entry. Since I’ll be likely messing with FPS a lot in the near future, I would like the Profile behavior not to be influenced by this setting. Meaning that, IMHO, time spent “outside” the Game Loop waiting for a new one to begin should not be confused with the time spent “outside” the Game Loop because some other application running on your PC requires to.

Does it make any sense? Am I thinking straight?