Avoid duplicate call to PSystemSetup.SetActive in FlightDriver.setStartupNewVessel#350
Conversation
|
Does it help in practice (i.e outside the profiler) too? With Plain Old RSS the results with this patch disabled vs enabled are within measurement error. |
|
I'm wondering if this is somewhat specific to launch sites in Sol, or if there's just something that causes it to only happen under some conditions. I would have expected somebody to notice this before now (me included) if it happened regularly. I'll do some more profiling here to see if it happens in stock |
|
Some quick testing on a (mostly) stock shows that this is definitely happening. I don't think I have anything installed on this new testing save that would affect the results here. Looking at the code this should happen any time you launch from the VAB or SPH and the launchsite is a PQSCity or a PQSCity2. @siimav what did your test setup look like?
Comparison with patch enabled
The launch does feel noticeably faster to me - which makes sense since it seems to nearly be a 4s improvement. I'll configure up a fully stock + KSPCF install and give it another test. edit: Gave it a spin in a stock + KSPCF install and I can definitely still see it happening along with the improvement from this PR. My setup is that I'm profiling rolling out a new ship from the VAB. |
When you launch out of the VAB, FlightDriver.setStartupNewVessel ends up starting all PQS instances twice. The initial start of PQS is very expensive, and all the work done on the first call is basically thrown away. This patches `FlightDriver.setStartupNewVessel` to avoid calling `PSystemSetup.SetActive` a second time. This is just a matter of patching the 3 different calls to shims that track whether they have been called.
358443b to
54ff61c
Compare
|
Rerun the tests with a SB save instead of career and with a single part vessel to minimize all the rest of the overhead. I guess there are some gains. Just easy to lose those within all the rest that usually happens on scene changes. |
…rtupNewVessel (KSPModdingLibs#350) Avoid second call to SetActive in FlightDriver.setStartupNewVessel When you launch out of the VAB, FlightDriver.setStartupNewVessel ends up starting all PQS instances twice. The initial start of PQS is very expensive, and all the work done on the first call is basically thrown away. This patches `FlightDriver.setStartupNewVessel` to avoid calling `PSystemSetup.SetActive` a second time. This is just a matter of patching the 3 different calls to shims that track whether they have been called.


When you launch out of the VAB, FlightDriver.setStartupNewVessel ends up starting all PQS instances twice. The initial start of PQS is very expensive, and all the work done on the first call is basically thrown away.
This patches
FlightDriver.setStartupNewVesselto avoid callingPSystemSetup.SetActivea second time. This is just a matter of patching the 3 different calls to shims that track whether they have been called.How much this actually ends up saving depends on the planet and mods installed. For stock I expect this to be about 2s, for the Sol install I'm testing (with a whole bunch of other patches to various mods) it is about 2.5s.
Before
After