Page 1 of 1

FPS go below 60fps while doing actually nothing

Posted: Tue Mar 05, 2019 4:24 pm
by molul
Ok, this must be a problem with my laptop, but I'm asking anyway to make sure.

I'm trying to chase a momentary performance drop issue on a Raspberry Pi project I'm developing on Windows with LÖVE 11.2. On Windows, I noticed that after 30-40 seconds, FPS drop noticeably (from 60 to 54, sometimes 20 or 30 something). I get 500fps with vsync disabled, so I thought it should be something I'm doing wrong on the update or draw functions after the first 30 seconds.

As I found nothing, I started removing code chunks. I've reached to the point that almost nothing is done (initialize a global variable in love.load, and drawing some stats on love.draw). Here's the code:

Code: Select all

--*****************************************************************
-- MAIN LOVE FUNCTIONS
--*****************************************************************

lf = love.filesystem
la = love.audio
li = love.image
lg = love.graphics
lj = love.joystick
lm = love.mouse

lg.setDefaultFilter( "nearest", "nearest" )


-----------------------------------------
-- love.load
-----------------------------------------
function love.load(arg)
	gStartTime = love.timer.getTime()
end

-----------------------------------------
-- love.update
-----------------------------------------
function love.update( dt )
end

-----------------------------------------
-- love.draw
-----------------------------------------
function love.draw()
	local text = "FPS: " .. love.timer.getFPS() .. " | FRAMETIME: " .. string.format("%.5f", love.timer.getAverageDelta() ) 
	lg.print(text, 5, 5)
	
	local stats = lg.getStats()
	lg.print("DRAWCALLS: " .. stats.drawcalls, 5, 30)
	lg.print("DRAWCALLSBATCHED: " .. stats.drawcallsbatched, 5, 55)
	lg.print("IMAGES: " .. stats.images, 5, 80)
	lg.print("TIME: " .. (love.timer.getTime() - gStartTime), 5, 105)
	
	if (love.timer.getFPS() < 60 and (love.timer.getTime() - gStartTime) > 5) then
		print ("TIME: " .. (love.timer.getTime() - gStartTime) .. "; FPS: " .. love.timer.getFPS())
	end
end
The last "if" statement will print the seconds when FPS are below 60 on the console (the "> 5" is to avoid false messages when launching the app). I consistently see that line being printed in a moment from second 30 to 45. It happens on LÖVE 11.0, 11.1 and 11.2. Oh, and I just updated the Nvidia drivers just in case but no luck.

I'm attaching the .love (nearly empty main.lua and conf.lua files, actually) if you don't mind running it for a minute. As I said, it only makes sense that my machine is the problem, but I would like to confirm before figuring out another cause of the sudden performance drop :)

Re: FPS go below 60fps while doing actually nothing

Posted: Tue Mar 05, 2019 4:46 pm
by grump
No significant drops here after 5 minutes. It dropped to 58 fps for a second, but that was probably caused by other stuff that runs in the background.

Image

Re: FPS go below 60fps while doing actually nothing

Posted: Tue Mar 05, 2019 6:31 pm
by molul
Thanks! Fortunately I found where the performance drop was happening on the Raspberry Pi (I don't mind about the Windows issue as it's my laptop for sure). I was looking at any graphic changes, but the key was that I was writing to disk every frame a key was pressed, so if you kept pressing it, it was writing to disk every frame.

Sorry for making you loose your time, btw ^_^U

Re: FPS go below 60fps while doing actually nothing

Posted: Mon Mar 18, 2019 5:23 pm
by Strela_999
Are you sure it's not something working "behind" your program on your computer? Sometimes, you're searching for an issue somewhere and it's in a completely different place.
Edit, I'm stupid, I've just read as I posted that it happens on a Raspberry Pi and not on a PC. Sorry!

Re: FPS go below 60fps while doing actually nothing

Posted: Mon Mar 18, 2019 6:11 pm
by molul
Hehe, no problem. Actually, the performance problem that remains is the one on Windows (FPS drop a bit after 30-40 seconds running), but I don't really mind about it. The performance problem in the Raspberry Pi was solved so I'm happy with that (not that happy for finding out the issue right after posting here, though ^_^U).