R
renex
Guest
I've seen way too many people asking about this and recently even got a dm asking about it. So here's a rant explaining windows sleep margin...
Say your room speed is 60. What happens is that each frame should be spaced by roughly 16 milliseconds. When the game is done rendering the frame, it sleeps for the rest of the time - so if it took the game 8 ms to render, it sleeps for 8.
This causes a problem - if it sleeps too little, the next frame comes out too early. If it sleeps too much, next frame will be late.
The solution to this problem was the sleep margin - what happens is that the game sleeps for frame time minus sleep margin, and then sits on an infinite loop waiting for the perfect time to send the frame in.
So for example if your sleep margin is 1 and rendering took 8 ms, the game will sleep for 7 ms and then actively wait during the last 1 ms to sync perfectly.
Now you can probably guess why the default used to be set to 10 - it means whatever time is not spent on the game will be spent in an infinite loop. This maxes out your one core. Now, this increases fps because your cpu then detects high usage and jumps to a higher profile, because modern cpus actually slow down when they're not being used fully. So by artificially using more cpu you are causing your computer to speed up in an attempt to perform better. This is why you should not trust fps_real for benchmarks - if you need to test something like that, set room speed to 999 and use the actual fps as a reference.
It is general community consensus that the sleep margin should be left at 10 for Windows targets - performance on power-saving-heavy machines is sketchy otherwise.
Say your room speed is 60. What happens is that each frame should be spaced by roughly 16 milliseconds. When the game is done rendering the frame, it sleeps for the rest of the time - so if it took the game 8 ms to render, it sleeps for 8.
This causes a problem - if it sleeps too little, the next frame comes out too early. If it sleeps too much, next frame will be late.
The solution to this problem was the sleep margin - what happens is that the game sleeps for frame time minus sleep margin, and then sits on an infinite loop waiting for the perfect time to send the frame in.
So for example if your sleep margin is 1 and rendering took 8 ms, the game will sleep for 7 ms and then actively wait during the last 1 ms to sync perfectly.
Now you can probably guess why the default used to be set to 10 - it means whatever time is not spent on the game will be spent in an infinite loop. This maxes out your one core. Now, this increases fps because your cpu then detects high usage and jumps to a higher profile, because modern cpus actually slow down when they're not being used fully. So by artificially using more cpu you are causing your computer to speed up in an attempt to perform better. This is why you should not trust fps_real for benchmarks - if you need to test something like that, set room speed to 999 and use the actual fps as a reference.
It is general community consensus that the sleep margin should be left at 10 for Windows targets - performance on power-saving-heavy machines is sketchy otherwise.
Last edited: