Skip to content

ModuleCargoBay.onVesselModified is incredibly slow when a vessel is modified #356

@Phantomical

Description

@Phantomical

When a large ship breaks it results in many different onVesselWasModified events which then in turn call out to ModuleCargoBay.onVesselModified. Each instance of this calls out to EnableShieldedVolume, which ends up recursively walking all nearby parts and their components. This is slow.

Here's some profiles showing what this ends up looking like for a large (1000 part) ship:
Image

This one is with #355 enabled
Image

It should be possible to defer the compute for each ModuleCargoBay until the start of the next FixedUpdate or Update call that happens immediately after. I don't think anything really needs the info this calculates until later, and by doing so we could batch together the changes to only need to happen once per cargo bay part, instead of something approaching once per cargo bay part per joint break.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kspPerformancePossible performance improvement in KSP

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions