KSP-RO / TestFlight

KSP Mod that provides a part research and reliability system
42 stars 31 forks source link

Optimize the new ignition failure penalty calculations #242

Closed siimav closed 2 years ago

siimav commented 2 years ago

image Updating the PAW stats eats up a significant amount of CPU cycles - 0.3ms per engine.

siimav commented 2 years ago

One possible fix for this is to update PAW stats only for parts that currently have it open. I implemented something similar in RF here: https://github.com/NathanKell/ModularFuelSystem/pull/277

DRVeyl commented 2 years ago

image

Much simpler profiling test (1.12.3, RO dev build but no RP-1, TF recompiled w/debug and with a Profiler call added inside the IgnitionFail OnUpdate call.) 4-engines in the sample. Unclear why the GC is much lower in this example. Agree the GC is probably unneeded and the string manipulation for the PAW can be avoided, but very different performance measure.

DRVeyl commented 2 years ago

Potentially fixed with https://github.com/KSP-RO/TestFlight/commit/f3900879c66c6d28a50f3c3ccdf7fd2dfbbf17ae and https://github.com/KSP-RO/TestFlight/commit/ed2423aeab9d324cf9afb7c468ba4bf5f492cb4e

Try it out? Probably also need to register for an event from MEC if we ever actually need to load in a new engine configuration during flight scene