LÖVE is a CPU/power hog: why?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Hexenhammer
Party member
Posts: 175
Joined: Sun Feb 17, 2013 8:19 am

LÖVE is a CPU/power hog: why?

Post by Hexenhammer » Tue Jan 14, 2014 5:17 am

At first I thought my game code was less efficient than I thought when I looked at the Windows task manager: my little (vsync'ed) demo maxed out one my CPU cores! But then I got suspicious, thinking "there is no way in hell that this code can max out a core", so I started LÖVE 0.9.0 (x64) without a game.. that Baby Inspector screen also maxes out one core!

I assume there is a reason why LÖVE hogs the CPU (one of its cores to be exact) all the time even if there is nothing to do. I would like to know that reason.

User avatar
slime
Solid Snayke
Posts: 2887
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: LÖVE is a CPU/power hog: why?

Post by slime » Tue Jan 14, 2014 6:10 am

What GPU and OS are you using? 0.9.0's no-game screen uses 4-5% CPU for me.

This is probably related to your problem:
http://gamedev.stackexchange.com/questi ... alext-is-e
http://www.retrocopy.com/blog/5/the-bat ... s-ati.aspx

(it's a driver issue.)

User avatar
Hexenhammer
Party member
Posts: 175
Joined: Sun Feb 17, 2013 8:19 am

Re: LÖVE is a CPU/power hog: why?

Post by Hexenhammer » Tue Jan 14, 2014 6:26 am

slime wrote:What GPU and OS are you using?
Win 7 Professional SP1, Geforce GT 640, official Nvidia driver .
0.9.0's no-game screen uses 4-5% CPU for me.

This is probably related to your problem:
http://gamedev.stackexchange.com/questi ... alext-is-e
http://www.retrocopy.com/blog/5/the-bat ... s-ati.aspx

(it's a driver issue.)
I only speed read it but if I got the gist it is that the problem is the combination OpenGL + Nvidia driver + Windows. Would explain why my old C + SDL games do not have that problem (they do not use OpenGL).

Thanks for the explanation.

P.S: Yet another excuse for me to write my own SDL based back-end! :awesome: (I love re-inventing the wheel). My combination is very common and I do not want my game to be a CPU/power hog on all those systems.

User avatar
slime
Solid Snayke
Posts: 2887
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: LÖVE is a CPU/power hog: why?

Post by slime » Tue Jan 14, 2014 6:32 am

nvidia's OpenGL driver in windows seems to wait for the screen's vblank by basically doing a busy-loop until it happens, which will always use 100% CPU on that thread if it can. Other drivers do it differently.

One of the links I gave provides a possible workaround for the issue.

By "SDL based backend" I assume you mean software rendering? SDL 2's render API (which replaces its old software rendering API) is hardware-accelerated with OpenGL as one possible backend, but it's still much more primitive than LÖVE's API.

Software rendering won't help, since you'd lose all reasonable performance plus the use of the GPU, and gain massive CPU usage.

User avatar
Hexenhammer
Party member
Posts: 175
Joined: Sun Feb 17, 2013 8:19 am

Re: LÖVE is a CPU/power hog: why?

Post by Hexenhammer » Tue Jan 14, 2014 8:04 am

slime wrote:nvidia's OpenGL driver in windows seems to wait for the screen's vblank by basically doing a busy-loop until it happens, which will always use 100% CPU on that thread if it can. Other drivers do it differently.

One of the links I gave provides a possible workaround for the issue.
I already have workarounds for other issues and at some point it makes sense to switch to a solution which does not require any workarounds. Especially given that I can implement the functionality of LÖVE I actually use (a small subset) in a day using C+SDL. LÖVE has been great for prototyping though.
By "SDL based backend" I assume you mean software rendering?
I meant using SDL2 with hardware accelerated rendering.
SDL 2's render API (which replaces its old software rendering API) is hardware-accelerated with OpenGL as one possible backend
One possible back-end. By default it uses Direct3D on Windows i.e. problem solved.
, but it's still much more primitive than LÖVE's API.
My Lua code will look almost the same. I will do it like LÖVE, implement the low-level logic in C (okay LÖVE does it in ugly C++ :P ) and expose a high-level interface to the Lua code i.e. the Lua code will not contain any direct SDL API calls.
Software rendering won't help, since you'd lose all reasonable performance plus the use of the GPU, and gain massive CPU usage.
Not in my experience. My software rendered SDL 1.2 game which does way more than my little demo and at a higher resolution only needs 2-3% of a core to do it. "It" being simply drawing a lot of tiles .. which is really all I need.

User avatar
Suppercut
Prole
Posts: 18
Joined: Sun Aug 05, 2012 4:10 pm

Re: LÖVE is a CPU/power hog: why?

Post by Suppercut » Tue Jan 14, 2014 10:47 pm

I'm having the same problem, but I have a Radeon, and I've never saw it up until 0.9.

Then again, I guess I never really looked at the percentages until 0.9 completely broke NppExec, making it a [random stream of curses] to test my game on the fly.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests