[solved] Large number of unused assets in game directory still slows down game

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
User avatar
dcoley13
Prole
Posts: 2
Joined: Thu Aug 24, 2023 8:54 pm

[solved] Large number of unused assets in game directory still slows down game

Post by dcoley13 »

So I encountered this issue today and potentially solved it already, but want to know why, and if it was known behavior or documented somewhere that I've just missed...

I have a large number of .json files in my game directory that contain some pre-computed lookup tables for the results of analysis that I'm displaying. I originally had these files (~1,000 files but only total about 17 MB combined) in a directory named ".data" and was easily hitting 60 fps. After some refactoring today I realized my fps had taken a hit and after a lot of debugging, I realized that having those same files in my game directory in a directory that doesn't begin with "." drops my fps by 20 or more, even when I've turned off the portion of the game that accesses those files.

I'm still not sure why, even when unused, I take such a hit on fps just by having those files present, but naming their directory something that begins with "." appears to be the solution. I'm guessing it omits that directory and it's children from some sort of filesystem indexing, but was hoping someone had more information.

Any ideas?

Thanks
Last edited by dcoley13 on Fri Aug 25, 2023 2:56 pm, edited 1 time in total.
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Large number of unused assets in game directory still slows down game

Post by ivan »

Hello and welcome to the forums.
You need to learn how to use profiling to find bottlenecks in your application. The profiler runs alongside your game and tracks the performance of your functions. Check out my GitHub for a free and open source profiler written in pure Lua. LuaJIT has its own profiler although that one is harder to setup.
It is not very clear if you are requiring a large number of files, iterating those files or scanning them on the disk using love.filesystem.
The most common reason for lag is the Lua Garbage Collector especially if you create a lot of intermediate objects.
It is difficult to determine the exact cause of the slowdown based on the provided information.
Last edited by ivan on Fri Aug 25, 2023 12:13 pm, edited 2 times in total.
User avatar
dcoley13
Prole
Posts: 2
Joined: Thu Aug 24, 2023 8:54 pm

Re: Large number of unused assets in game directory still slows down game

Post by dcoley13 »

Hey Ivan,

Thanks for the quick response. Your profiler came in handy and I was able to track the culprit: I was using the lurker module for hot reloading during development. Lurker is the one scanning the game directory for changes and (unknown to me) skips over directories that begin with "." which fully explains the behavior I was seeing, even when the files were unused within the code.

Thanks again!
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: [solved] Large number of unused assets in game directory still slows down game

Post by ivan »

You are welcome and please hang around -there are a lot of people on here who need help with their love2d projects
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 9 guests