perf: Load expansion bundles asynchronously in the background#345
Merged
JonnyOThan merged 3 commits intoNov 18, 2025
Conversation
9aa81e3 to
2f5d5bf
Compare
This commit completely overrides ExpansionLoader so that asset bundles are loaded in async and in parallel while part compilation is being done. These take a _really_ long time to decompress so it isn't able to completely hide the latency but it seems to improve overall loading time by ~10s on a stock + KSPCF install. As the time taken in part compilation increases the time saved should continue to improve until part compilation takes longer than about 13s, which is how long it takes to unload the `serenity_assets` asset bundle. The implementation details are: - we now start our own LoadExpansionsV2 coroutine immediately after patching which waits one frame then starts async background loads of all the asset bundles - once the bundles are loaded the coroutine waits until StartLoad is called and then goes and does the normal load for each of the expansion bundles in the usual order. - I have also moved checksum calculations off to a background thread, though I doubt this makes much of a difference. I haven't tried to optimize anything else other than moving the asset bundle load off the main thread because I don't think there's much worth optimizing there. Other compatibility notes: - this patch disables itself if the OptionalMakingHistoryDLCFeatures patch is enabled and configured to skip loading of the expansions.
2f5d5bf to
42eb4d6
Compare
Contributor
|
Is this ready to go or did you want to look at kicking it off earlier in the loading process? |
Collaborator
Author
|
This should be ready to go. Moving it earlier can come in a follow-up PR. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 commit completely overrides ExpansionLoader so that asset bundles are loaded in async and in parallel while part compilation is being done. These take a really long time to decompress so it isn't able to completely hide the latency but it seems to improve overall loading time by ~10s on a stock + KSPCF install. As the time taken in part compilation increases the time saved should continue to improve until part compilation takes longer than about 13s, which is how long it takes to unload the
serenity_assetsasset bundle.The implementation details are:
I haven't tried to optimize anything else other than moving the asset bundle load off the main thread because I don't think there's much worth optimizing there.
Other compatibility notes:
OptionalMakingHistoryDLCFeaturespatch is enabled and configured to skip loading of the expansions.Comparison
Ignore total load times as they include time taken for me to click the png caching popup
Before:
After: