Defer work in vessel modules until the data is actually needed#120
Open
Phantomical wants to merge 2 commits intopost-kerbin-mining-corporation:masterfrom
Open
Defer work in vessel modules until the data is actually needed#120Phantomical wants to merge 2 commits intopost-kerbin-mining-corporation:masterfrom
Phantomical wants to merge 2 commits intopost-kerbin-mining-corporation:masterfrom
Conversation
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.
DBS has shown up in my profiles for a while in cases where a vessel gets modified (crashing, launch clamps decoupling, etc.) For large ships DBS can easily account for 15-20s of a 50s frame. This PR improves that from 15-20s to sub-100ms for an 1000 part ship that is in the process of exploding.
The main changes here are:
VesselDataManagerandModuleDynamicBatteryStorageno longer refresh their internal data inonVesselWasModified. Instead, they invalidate their current data and recalculate either the next time it is needed, or on the next FixedUpdate, respectively.O(n)instead ofO(n^2).There are also a bunch of other minor changes:
ShouldBeActiveto disable themselves when there is nothing for them to do.OnEnable/OnDisableto account for this.VesselDataManagerno longer has aFixedUpdatemethod. Instead, the vessel data is computed when it is requested.Fixes #119
For some performance numbers, here's what the dottrace profile looked like before these changes (ignore total times, only the relative sizes mean anything)

And here's what it looks like after. DBS has completely disappeared from the profile. (Again, ignore total times only relative sizes mean anything here)
