Hi everyone,
Currently working on a prototype game (something real simple), I'm encountering performance issues while testing my game on Ubuntu.
I draw a tilemap of 24 by 18 on screen and then my computer acts like I'm playing a triple A game on Ultra settings and the games gets framerate drops.
I first thought I did something wrong with the code but couldn't find what, everything seems perfectly normal, so I tested the game on a Windows partition and everything went okay !
Is Love2D getting performance issues on Ubuntu ? Is it known ? Can I do something to enhance it ? Am I missing something ?
Thanks in advance,
Clément
[Solved]Löve performance issues on Ubuntu/Linux ?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[Solved]Löve performance issues on Ubuntu/Linux ?
Last edited by clmj on Sat Oct 09, 2021 12:46 pm, edited 1 time in total.
Re: Löve performance issues on Ubuntu/Linux ?
I’m not aware of any Ubuntu specific issues. I’ve used love on Ubuntu before without a hitch. Could you post your code?
EDIT: I did a google and found this: https://love2d.org/forums/viewtopic.php?t=8322
EDIT: I did a google and found this: https://love2d.org/forums/viewtopic.php?t=8322
Re: Löve performance issues on Ubuntu/Linux ?
It was entirely my fault.
I missed something in my code
Sorry for the noobism and thank you @veethree for the answer !
Ubuntu rules!
I missed something in my code
Sorry for the noobism and thank you @veethree for the answer !
Ubuntu rules!
- BrotSagtMist
- Party member
- Posts: 657
- Joined: Fri Aug 06, 2021 10:30 pm
Re: Löve performance issues on Ubuntu/Linux ?
That is not how you close a topic, you have to explain what actually happened.
And if there is a possibility that the same code runs fine on windows but fails on linux i want to hear how that can happen.
And if there is a possibility that the same code runs fine on windows but fails on linux i want to hear how that can happen.
obey
Re: Löve performance issues on Ubuntu/Linux ?
The mistake here was that when I tried to loop over my map table using two nested For loops in order to draw the map, I forgot to remove an other loop wich was there earlier in the coding.
Bad code : (24*18)*(24*18) = 186624 objects per frame
Good code : 24*18 = 432 objects per frame
So it was indeed messed up.
As to why it lagged on Ubuntu (wich was a normal thing) and not on Windows I can't tell you.
Bad code : (24*18)*(24*18) = 186624 objects per frame
Code: Select all
for i = 1, pmap.width * pmap.height do
for r = 1, pmap.height do
for c = 1, pmap.width do
tile = pmap.data[r][c]
love.graphics.draw(pmap.tilesheet.image, pmap.tilesheet.tiles[tile], (c - 1) * pmap.tilewidth,
(r - 1) * pmap.tileheight)
end
end
end
Code: Select all
for r = 1, pmap.height do
for c = 1, pmap.width do
tile = pmap.data[r][c]
love.graphics.draw(pmap.tilesheet.image, pmap.tilesheet.tiles[tile], (c - 1) * pmap.tilewidth,
(r - 1) * pmap.tileheight)
end
end
As to why it lagged on Ubuntu (wich was a normal thing) and not on Windows I can't tell you.
- BrotSagtMist
- Party member
- Posts: 657
- Joined: Fri Aug 06, 2021 10:30 pm
Re: [Solved]Löve performance issues on Ubuntu/Linux ?
So there was a loop doing 432 times the exact same thing, i could imagine an optimizer should kick in and disable this loop for you automatically.
So you really do have an issue on ubuntu, this optimizer does not work.
So you really do have an issue on ubuntu, this optimizer does not work.
obey
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: [Solved]Löve performance issues on Ubuntu/Linux ?
No, just because a loop calls a function with the same inputs multiple times, doesn't mean it's work that can be automatically eliminated. That would only be true for a small subset of possible functions. In this case love.graphics.draw does a bunch of non-redundant work (as far as it knows), it will just sometimes look the same depending on the image being drawn, blend mode, opacity, shader code, etc.BrotSagtMist wrote: ↑Sat Oct 09, 2021 1:12 pm So there was a loop doing 432 times the exact same thing, i could imagine an optimizer should kick in and disable this loop for you automatically.
So you really do have an issue on ubuntu, this optimizer does not work.
Re: [Solved]Löve performance issues on Ubuntu/Linux ?
In fact, the optimizer has no information on what love.graphics.draw does, and can't assume that it has no side effects that alter an external state. And it would be right to not assume that, because two love.graphics.draw calls with the same parameters don't always produce the same results as just one, when the alpha of what's being drawn is not 0 or 1 but something in between. Try this:
After a very short while, the text will look much thicker and sharper than a single `love.graphics.print("Hello, world")` because the alpha keeps accumulating. That's what happens when you draw the same thing repeatedly with the default blendmode.
Things would be different for other blendmodes, but again, the optimizer has no information on that.
Code: Select all
local canvas = love.graphics.newCanvas()
function love.draw()
love.graphics.setCanvas(canvas)
love.graphics.print("Hello, world")
love.graphics.setCanvas()
love.graphics.draw(canvas)
end
Things would be different for other blendmodes, but again, the optimizer has no information on that.
- BrotSagtMist
- Party member
- Posts: 657
- Joined: Fri Aug 06, 2021 10:30 pm
Re: [Solved]Löve performance issues on Ubuntu/Linux ?
AN optimizer. I was more thinking of CPU or graphic cards driver magic. Could that be plausible?
But right, drawing is not really predictable.
But right, drawing is not really predictable.
obey
- BrotSagtMist
- Party member
- Posts: 657
- Joined: Fri Aug 06, 2021 10:30 pm
Re: [Solved]Löve performance issues on Ubuntu/Linux ?
Actually scrap that, i thought on that again.
Yes it might not be able to eliminate the draw call but youre forgetting about the table lookups here which are indeed eliminated by jit and there are quite a bunch in that loop. They should be easily enough to halve its speed and tip that over the edge of lag.
Of course i doubt myself that jit is failing on his install, but it remains a plausible explanation.
Yes it might not be able to eliminate the draw call but youre forgetting about the table lookups here which are indeed eliminated by jit and there are quite a bunch in that loop. They should be easily enough to halve its speed and tip that over the edge of lag.
Of course i doubt myself that jit is failing on his install, but it remains a plausible explanation.
obey
Who is online
Users browsing this forum: Google [Bot] and 12 guests