Page 1 of 1

512 FPS?

Posted: Thu Jul 19, 2018 5:30 am
by uiblob
Hello there,

after I played around with my layout engine I managed to get a good boost from 149 fps to 512. But even after optimizing more I did not get more fps. Then I tested an empty project which did nothing but print the fps to screen (with disabled vsync). This empty screen got between 509 and 512 fps.

So now I am wondering: Is there a cap at 512 fps? I tested it on my most powerful machine so I cant tell if it possible to go higher. If so, why?
I am not even talking about gameplay aspects now, but for benchmarking my routines a cap would not be the best situation. Or is it just a coincidence?

Greetings
uiblob

Re: 512 FPS?

Posted: Thu Jul 19, 2018 7:44 am
by KayleMaster
There is a sleep function called in love.run to cap the fps to 512. Try using your own love.run and remove the love.timer.sleep

https://love2d.org/wiki/love.run

Re: 512 FPS?

Posted: Thu Jul 19, 2018 7:58 am
by zorg
KayleMaster wrote: Thu Jul 19, 2018 7:44 am There is a sleep function called in love.run to cap the fps to 512. Try using your own love.run and remove the love.timer.sleep

https://love2d.org/wiki/love.run
Technically, it caps it to 0.001 ms, or 1000 FPS, not 512 (in the best case scenario). At least, last time i checked, that was the value in the default love.run function.

Re: 512 FPS?

Posted: Thu Jul 19, 2018 7:58 am
by raidho36
It doesn't cap at any specific number, but it yields CPU time to the OS for 1 millisecond. It is not guaranteed to resume operation in exactly that much time, but, excluding extreme cases, it will not resume operation in less than that time. Your OS probably returns control to the process in 1.9 milliseconds, hence 512 fps.

Beat me to it, again!

Re: 512 FPS?

Posted: Thu Jul 19, 2018 8:19 am
by uiblob
Wow, thanks for the great information.

Re: 512 FPS?

Posted: Thu Jul 19, 2018 1:56 pm
by MissDanish
--snip--

Re: 512 FPS?

Posted: Thu Jul 19, 2018 2:52 pm
by zorg
I guess i'm just lucky my configuration happened to yield at exactly that amount of time then. :3

Re: 512 FPS?

Posted: Fri Jul 20, 2018 4:36 am
by raidho36
Default love.run function sleeps for 1 millisecond every frame. There is no need to sleep for 1 millisecond, you can sleep for 0 milliseconds and that will allow the OS scheduler to resume immediately, if no other threads need running, without wasting that 1 or more milliseconds. You can even forego the sleep call entirely, vertical synchronization will do the same job for you and to a much greater precision. Without the vsync however the program will run in a spinlock-like state with 100% CPU load at all times, in which case a small sleep actually prevents full CPU utilization.