Skip to content

VesselDataManager.RefreshVesselData causes extreme lag when parts are decoupled, destroyed, or otherwise broken off a vessel #119

@Phantomical

Description

@Phantomical

RefreshVesselData is called every time an onVesselModified event is fired. When a large vessel breaks apart this means it can end up running hundreds of times in a single frame with each call taking 0.1s or more.

Here's an example of a profile where a large ship is in the process of crashing. The whole frame takes 56 seconds, 14 of which are spent in VesselDataManager.RefreshVesselData.

Image

Here's a dotTrace view of the same time period. Basically all the time is spent in 3 different calls: VesselDataManager.RefreshVesselData, ModuleCargoBay.onVesselModified, and CollisionManager.FixedUpdate.

Image

From what I can see the vessel data is only used in two cases: the monitor UI and when in high time warp. It seems like it should be possible to just invalidate the vessel data and then recalculate it when it is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions