Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster implementation of TemperatureGaugeSystem #270

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

gotmachine
Copy link
Contributor

Address issue #194

Complete reimplementation of TemperatureGaugeSystem :

  • Minimal update overhead when no gauges are active/shown
  • Vastly reduced update overhead when gauges/highlight are active/shown
  • Gauges are now instantiated on demand, eliminating (most of) the cost on vessel load
  • Gauges are now recycled when the vessel is modified / switched, instead of destroying and re-instantiating all of them immediately

Gauges were previously always instantiated for every part on the active vessel, and this was pretty slow due to triggering a lot of internal UI/layout/graphic dirtying on every gauge instantiation. Overall, the operation can take several hundred milliseconds in not-so large part count situations, leading to very significant hiccups in most vessel events involving a part count change and on active vessel switches, as well as on flight scene loads.

Some profiling data :
TemperatureGaugeSystem.Update average frame time with a ~500 part vessel, gauges not shown : Stock 0.6%, KSPCF 0.04%
TemperatureGaugeSystem.Update average frame time with a ~500 part vessel, ~16 gauges shown : Stock 1.7%, KSPCF 0.3%

Note that we were already patching TemperatureGaugeSystem.Update with only a mild mitigation of the update overhead when gauges weren't shown. This is a much deeper hack changing the whole lifecycle and handling of the stock objects involved, and consequently any mod trying to interact with them will likely break. A github search didn't return anything, and I don't see any use case for such interactions, so probably alright ?

  - Minimal update overhead when no gauges are active/shown
  - Vastly reduced update overhead when gauges/highlight are active/shown
  - Gauges are now instantiated on demand, eliminating (most of) the cost on vessel load
  - Gauges are now recycled when the vessel is modified / switched, instead of destroying and re-instantiating them immediately
@gotmachine gotmachine added the kspPerformance Possible performance improvement in KSP label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kspPerformance Possible performance improvement in KSP
Development

Successfully merging this pull request may close these issues.

1 participant