You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR implements "Fast Level Loading" (like Fast Texture Loading, but for levels).
In collabs, levels can take a lot of time to load (especially since texture loading times have already been improved).
The implementation uses Parallel.For (which uses CPU core count as degree of parallelism), is enabled by default (this could be changed), and logs level loading order (to help diagnose potential issues).
It adds a ThreadStatic attribute to stringLookup in BinaryPacker, so each thread has its own lookup.
It also adds a lock in MapData, because map data processors from mods don't expect concurrent access and may fail.
During testing, these changes improved loading times on my end, loading "Strawberry Jam Collab" levels takes about 6 seconds before changes, and about 4 seconds after changes.
Very nice! Would probably be a good idea to add some virtual bool IsThreadSafe => false; to MapDataProcessors, so that mods can work towards thread safety for their processors. If all registered processors are declared thread-safe, then the lock could be omitted and we'd probably see a larger perf boost. (And perhaps add some logging for non-thread-safe processors so we know what's blocking us?)
Very nice! Would probably be a good idea to add some virtual bool IsThreadSafe => false; to MapDataProcessors, so that mods can work towards thread safety for their processors. If all registered processors are declared thread-safe, then the lock could be omitted and we'd probably see a larger perf boost. (And perhaps add some logging for non-thread-safe processors so we know what's blocking us?)
Thanks!
From my testing (on the "Strawberry Jam Collab"), the locking doesn't have much impact on the performance boost (less than half a second).
I'm not sure getting mods towards thread safety in their map data processors is needed at this point, because it could lead to issues if mods are declared thread-safe but aren't in practice; and thread synchronization issues can be hard to diagnose and fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1: review neededThis PR needs 2 approvals to be merged (bot-managed)
5 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements "Fast Level Loading" (like Fast Texture Loading, but for levels).
In collabs, levels can take a lot of time to load (especially since texture loading times have already been improved).
The implementation uses
Parallel.For(which uses CPU core count as degree of parallelism), is enabled by default (this could be changed), and logs level loading order (to help diagnose potential issues).It adds a
ThreadStaticattribute tostringLookupinBinaryPacker, so each thread has its own lookup.It also adds a lock in
MapData, because map data processors from mods don't expect concurrent access and may fail.During testing, these changes improved loading times on my end, loading "Strawberry Jam Collab" levels takes about 6 seconds before changes, and about 4 seconds after changes.