itb-community / ITB-ModLoader

A lua-based mod loader for the game Into the Breach
48 stars 18 forks source link

Improve efficiency of modifying resource.dat file #132

Closed KnightMiner closed 2 years ago

KnightMiner commented 2 years ago

Did a loose benchmark:

Breakdown of improvement by change:

Note: startup times include the loading bar, which takes about 7 seconds. Meaning all the modloader preloading stuff takes around 40-55 seconds before changes, and around 20-23 seconds after.


Note: we could possibly save a few more seconds if we inject our signature into the start of resource.dat and break the signature scan loop as soon as its found. Based on how fast it ran with the broken signature scan code I had earlier, I doubt it would be much more than a second gain, so probably not worth it (plus, not sure if there is risk with changing the order of files)


Testing:

Lemonymous commented 2 years ago

I have not gone through the code, but I did test it on my system. On my system, it cuts the loading of the mod loader without mods to a third of master. From >30 seconds to <10 seconds until the loading bar shows up.

KnightMiner commented 2 years ago

Not sure what could cause that apart from a mod manually modifying the resource.dat, there is no path where assertExists would have worked with the old code where it does not work with the new code