[Solved]Löve performance issues on Ubuntu/Linux ?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
clmj
Prole
Posts: 3
Joined: Fri Oct 08, 2021 1:57 pm

[Solved]Löve performance issues on Ubuntu/Linux ?

Post by clmj »

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
Last edited by clmj on Sat Oct 09, 2021 12:46 pm, edited 1 time in total.
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Löve performance issues on Ubuntu/Linux ?

Post by veethree »

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
clmj
Prole
Posts: 3
Joined: Fri Oct 08, 2021 1:57 pm

Re: Löve performance issues on Ubuntu/Linux ?

Post by clmj »

It was entirely my fault.
I missed something in my code :)

Sorry for the noobism and thank you @veethree for the answer !

Ubuntu rules!
User avatar
BrotSagtMist
Party member
Posts: 657
Joined: Fri Aug 06, 2021 10:30 pm

Re: Löve performance issues on Ubuntu/Linux ?

Post by BrotSagtMist »

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.
obey
clmj
Prole
Posts: 3
Joined: Fri Oct 08, 2021 1:57 pm

Re: Löve performance issues on Ubuntu/Linux ?

Post by clmj »

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

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
Good code : 24*18 = 432 objects per frame

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
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.
User avatar
BrotSagtMist
Party member
Posts: 657
Joined: Fri Aug 06, 2021 10:30 pm

Re: [Solved]Löve performance issues on Ubuntu/Linux ?

Post by BrotSagtMist »

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.
obey
User avatar
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 ?

Post by slime »

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.
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.
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: [Solved]Löve performance issues on Ubuntu/Linux ?

Post by pgimeno »

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:

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
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.
User avatar
BrotSagtMist
Party member
Posts: 657
Joined: Fri Aug 06, 2021 10:30 pm

Re: [Solved]Löve performance issues on Ubuntu/Linux ?

Post by BrotSagtMist »

AN optimizer. I was more thinking of CPU or graphic cards driver magic. Could that be plausible?
But right, drawing is not really predictable.
obey
User avatar
BrotSagtMist
Party member
Posts: 657
Joined: Fri Aug 06, 2021 10:30 pm

Re: [Solved]Löve performance issues on Ubuntu/Linux ?

Post by BrotSagtMist »

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.
obey
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 5 guests