Implement Fast Level Loading#1072
Conversation
f90d474 to
49205d7
Compare
|
Very nice! Would probably be a good idea to add some |
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 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.