Trace is now dominated by Stellaris searching for additional files in the base directory, repeatedly trying to open directories that no longer exist. That's enough for the whole Stellaris install, and it knocks another 10% off startup time.
Now we have a gfx.zip, with the gfx folder, and a data.zip, with everything else. That's not enough for all the data, so we need to add a second archive.
#Spellforce 2 editor save game archive#
My patch doesn't include its own archive functionality*, and relies on code already in Stellaris, ( physfs) which limits it to 2GB archives. The obvious first step is to move more files into an archive. Profiling shows that we're still spending 40%-ish of clock cycles in the kernel waiting for IO-ish stuff, which means we're still doing IO far too inefficiently. Moving out the gfx folder cut startup time by 45%, and adding in a few others increased that to 50%, but I'm sure we can shave a bit more off than that. I should probably also mention that this is all windows only, and probably will only work with the steam version: The same issues will apply to other OS/versions, but they'd need a patch of their own.Ĭontinuing to play with Stellaris startup performance, because overkill is fun. I've left the original up too, because this one needs more careful installation and has a higher chance of going wrong. That's enough playing around here anyway.
A better solution would be to keep a cache of folders that don't exist in a location, to save trying to look up further files in that folder, but that's too invasive for this small patch. But that's not the best of ideas, because the user directory is supposed to override base game files. I know I have no files in there that override base game files, so tweaking the search order cuts IO operations to 79,570, and cuts startup time by another 11%. The bulk of these are searching for files that are in the archives and don't exist in the user folder, since the user folder has a higher search priority. The user directory isn't too bad - with yesterdays patch, we have 174,017 IO operations. Since building the archives myself requires an installer for the patch, I've built it into a WIP save/mod editor I was working on. That more than halves the work required to read the archive, since the local headers are scattered throughout the file, whereas the central headers are clustered at the end. That means that Stellaris never has to read the local file header at all, while the archives are still valid zip files that can be opened by a regular archiver too.
#Spellforce 2 editor save game install#
OK, one last install directory tweak: If I create the archives myself, then I can control the offset from the local file header to the file data.