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.
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.
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.
RefreshVesselDatais called every time anonVesselModifiedevent 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.Here's a dotTrace view of the same time period. Basically all the time is spent in 3 different calls:
VesselDataManager.RefreshVesselData,ModuleCargoBay.onVesselModified, andCollisionManager.FixedUpdate.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.