Love CPU usage
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Love CPU usage
Well, not that I'm really contributing anything, but I see CPU grabbing as a common practice among games. I even expect it when I open a game.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Love CPU usage
Ditto. I see games as a "This is what I do, and I don't do anything else" application. Most games are designed to be the main thing you use on the computer when running them. Or in the case of a console, the ONLY thing you do on the device. Unless it's a small windowed game that you play casually, it should be entitled to use all the processor and resources it can grab.TechnoCat wrote:Well, not that I'm really contributing anything, but I see CPU grabbing as a common practice among games. I even expect it when I open a game.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Love CPU usage
LÖVE games are often casual, though.Jasoco wrote:Unless it's a small windowed game that you play casually, it should be entitled to use all the processor and resources it can grab.
Help us help you: attach a .love.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Love CPU usage
For AAA titles that works fine (they usually use a tonne of resources anyway), but for anything else, well... not really.Jasoco wrote:it should be entitled to use all the processor and resources it can grab.
Re: Love CPU usage
You could always get [not a pentium 4] that should do the trick, that processor is 9 years old now.
Also, what constitutes as "plenty of ram". Love isn't all that demanding, but I can see it not working depending on ram-amount, or possibly the video card.
Also, what constitutes as "plenty of ram". Love isn't all that demanding, but I can see it not working depending on ram-amount, or possibly the video card.
@rynesaur
- ChicoGameDev
- Citizen
- Posts: 70
- Joined: Thu Feb 14, 2019 6:02 pm
- Location: Switzerland
- Contact:
Re: Love CPU usage
Hello everybody,
This a very old topic but it is still an "issue". I've put this piece of code in my main update function :
Just as kindly suggested on the love2D Wiki to limit FPS. My min_dt is set on 1/60 for 60fps
It's working great but what I'm concerned about is that LÖVE.app still takes ~103% of my processor.
Just for information my vSync is enabled too.
Do someone have the secret key for avoiding love2D to take over my CPU ?
Thanks
Regards
This a very old topic but it is still an "issue". I've put this piece of code in my main update function :
Code: Select all
function love.update(dt)
next_time = next_time + min_dt
[...]
local cur_time = love.timer.getTime()
if next_time <= cur_time then
next_time = cur_time
return
end
love.timer.sleep(next_time - cur_time)
end
It's working great but what I'm concerned about is that LÖVE.app still takes ~103% of my processor.
Just for information my vSync is enabled too.
Do someone have the secret key for avoiding love2D to take over my CPU ?
Thanks
Regards
Re: Love CPU usage
My best guess is that you graphics driver implements vsync with a busy (polling) loop, rather than with an idle (interrupt-based) loop, therefore most of the CPU time is spent by the driver checking for vsync. This might be caused either by the graphics card's hardware not supporting interrupts, or by the driver itself being crappy.ChicoGameDev wrote: ↑Sat Aug 29, 2020 10:19 am Just as kindly suggested on the love2D Wiki to limit FPS. My min_dt is set on 1/60 for 60fps
It's working great but what I'm concerned about is that LÖVE.app still takes ~103% of my processor.
Just for information my vSync is enabled too.
Do someone have the secret key for avoiding love2D to take over my CPU ?
If my guess is right, just disabling vsync, while keeping the sleep just as you mention above, should solve the issue.
The second possible cause is that your program is complex enough as to take 1/60th of a second per frame or more. If you still get 100%+ CPU after disabling vsync, you can test this by checking the CPU consumption with a program that disables vsync and implements the sleep method that you mention, but that does nothing else otherwise. If it still uses 100%+ CPU, then the driver or graphics card is most likely to blame. If it uses very little CPU, it may be that your program is too complex and is using up all CPU time every frame.
Another useful trick is to check the FPS of your program using the window title bar: love.window.setTitle(tostring(love.timer.getFPS())) - if it's under 60, it's your program that is eating all that CPU.
- ChicoGameDev
- Citizen
- Posts: 70
- Joined: Thu Feb 14, 2019 6:02 pm
- Location: Switzerland
- Contact:
Re: Love CPU usage
Hey,
Thanks for your answer I'm currently on a Macbook Pro and even an empty application with vsync off and just the sleep the CPU is up to ~103% here is the love file for testing purpose.
For the FPS as I said I have a text ingame to show it and it's really a strong and stable 60 fps.
So is it a bug on MacOS or is it normal?
What result do you guys have on Windows?
Thanks a lot
Regards
Thanks for your answer I'm currently on a Macbook Pro and even an empty application with vsync off and just the sleep the CPU is up to ~103% here is the love file for testing purpose.
For the FPS as I said I have a text ingame to show it and it's really a strong and stable 60 fps.
So is it a bug on MacOS or is it normal?
What result do you guys have on Windows?
Thanks a lot
Regards
-
- Party member
- Posts: 548
- Joined: Wed Oct 05, 2016 11:53 am
Re: Love CPU usage
On my Windows machine the .love you attached at most only uses 1% of my CPU, most of the time doesn't register even that. Even when I modify the code to output something to console, or do some operations, it doesn't budge. Didn't check if it maintains 60fps properly.
However, I see you are trying to implement your frame rate limiter inside the love.update. Generally I've seen people doing that by supplying their own love.run code. Not entirely sure, but having that love.timer.sleep inside your love.update, in tandem with love.run's own, might be causing issues. Another consideration is that even if your love.update doesn't do anything, and the GPU driver your Macbook Pro has is bad like pgimeno suggests, maybe modify love.run to only change the contents of the screen when love.update has finished a successful run. Eq. return a true/false value from love.update, and only run love.draw and such when trueish value is returned. Of course, love.graphics.present has a built-in stall if vsync is enabled.
Another personal recommendation is to check this library by bjornbytes, which properly implements the fixed timestep model. Maybe their love.run implementation might work better than your approach.
However, I see you are trying to implement your frame rate limiter inside the love.update. Generally I've seen people doing that by supplying their own love.run code. Not entirely sure, but having that love.timer.sleep inside your love.update, in tandem with love.run's own, might be causing issues. Another consideration is that even if your love.update doesn't do anything, and the GPU driver your Macbook Pro has is bad like pgimeno suggests, maybe modify love.run to only change the contents of the screen when love.update has finished a successful run. Eq. return a true/false value from love.update, and only run love.draw and such when trueish value is returned. Of course, love.graphics.present has a built-in stall if vsync is enabled.
Another personal recommendation is to check this library by bjornbytes, which properly implements the fixed timestep model. Maybe their love.run implementation might work better than your approach.
- ChicoGameDev
- Citizen
- Posts: 70
- Joined: Thu Feb 14, 2019 6:02 pm
- Location: Switzerland
- Contact:
Re: Love CPU usage
Hi,
Thanks for your answer.
Actually I did not know about love.run and I've not overwritten it.
I tried to add the library you liked me to the simple test project I've made and now it goes up to ~190% of CPU with a framerate set on 60.
The framerate is stable tho. But it's actually worth :O.
Thanks for the windows informations, Maybe someone on MacOS will see this thread and try out my little love file. Just to be sure I'm note alone...
Regards,
Thanks for your answer.
Actually I did not know about love.run and I've not overwritten it.
I tried to add the library you liked me to the simple test project I've made and now it goes up to ~190% of CPU with a framerate set on 60.
The framerate is stable tho. But it's actually worth :O.
Thanks for the windows informations, Maybe someone on MacOS will see this thread and try out my little love file. Just to be sure I'm note alone...
Regards,
Who is online
Users browsing this forum: Bing [Bot] and 0 guests