Page 1 of 1

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

Posted: Fri Aug 25, 2023 1:43 am
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

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

Posted: Fri Aug 25, 2023 6:49 am
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.

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

Posted: Fri Aug 25, 2023 11:59 am
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!

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

Posted: Sat Aug 26, 2023 12:13 pm
by ivan
You are welcome and please hang around -there are a lot of people on here who need help with their love2d projects