ShipEffects: cache SoundLayerGroups globally instead of parsing per-vessel#53
Closed
bimo1d wants to merge 1 commit intoKSPModStewards:masterfrom
Closed
ShipEffects: cache SoundLayerGroups globally instead of parsing per-vessel#53bimo1d wants to merge 1 commit intoKSPModStewards:masterfrom
bimo1d wants to merge 1 commit intoKSPModStewards:masterfrom
Conversation
Member
|
Thanks for this; I implemented it a slightly different way but this is a great idea! |
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.
Hi again, follow-up to the debris-skip PR.
After debris are filtered out, the remaining hitch on separations comes from non-debris vessels. Profiler shows ~120ms in ShipEffects.Initialize, of which ~117ms is the SoundLayer parsing loop.
ShipEffectsConfig is global, AudioClips from GameDatabase are immutable, so the SoundLayer objects produced by CreateSoundLayerGroup are identical for every vessel. Parsing them once per vessel is pure overhead.
This PR moves the parsing into a lazy static cache (GetCachedSoundLayerGroups). Each vessel's Initialize copies references from the cache instead of re-parsing. SoundLayer instances are shared across vessels, but the per-vessel SoundLayerGroups dictionary owns it's own list copies to preserve existing per‑vessel isolation.
Thanks!