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

FlightIntegrator and friends micro-optimization #230

Merged
merged 4 commits into from
Oct 7, 2024
Merged

Conversation

gotmachine
Copy link
Contributor

@gotmachine gotmachine commented Jun 3, 2024

This is ongoing work to micro-optimize the various heavy duty stuff in FlightIntegrator, VesselPrecalculate and possible other flight scene low level components. The focus is on improving performance scaling in large part count situations, mainly by micro-optimizing the per-part work done in these component.

The optimizations are meant to keep behavior as close to stock as possible, but they do introduce minor changes, and given how critical the patched methods are, any bug or behavior change is likely to have dire cascading consequences, so this will need some testing before being pushed.

As of now, there are a few other areas I want to look at before considering pushing this to a (pre)release, but I won't have much time to commit in the next weeks, not sure when I will resume working on this.

Here is a preview release : KSPCommunityFixes_FlightPerf.zip

…nly relevant in large part count situations. More can be done : I didn't touch yet stuff specific to aero situations (drag, conduction occlusion...) and there is probably something to be done about Integrate()
@gotmachine gotmachine added the kspPerformance Possible performance improvement in KSP label Jun 3, 2024
@JonnyOThan
Copy link
Contributor

JonnyOThan commented Jul 5, 2024

I think there's some kind of issue related to the camera anchor point. This started happening after I installed this build in tpksp: https://clips.twitch.tv/ModernBusyLemurTinyFace-fvxZ_jtUEAGkjCZc

Possibly involving docking or loading a save.

@R-T-B
Copy link

R-T-B commented Jul 15, 2024

I think there's some kind of issue related to the camera anchor point. This started happening after I installed this build in tpksp: https://clips.twitch.tv/ModernBusyLemurTinyFace-fvxZ_jtUEAGkjCZc

Possibly involving docking or loading a save.

I may have seen this as well. On the vessel in question, do you also have where you can't get back to the spacecenter via the top menu, but only via esc menu and such?

@JonnyOThan
Copy link
Contributor

do you also have where you can't get back to the spacecenter via the top menu, but only via esc menu and such?

To be honest I haven't investigated at all and this has only been reported in TPKSP where we don't use the mouse or normal GUI :p

@R-T-B
Copy link

R-T-B commented Jul 16, 2024

Ah, well those are my symptoms when this bug strikes, at any rate.

gotmachine and others added 2 commits September 24, 2024 20:44
…cro-optimizations for various pieces of code running every frame on every part. Won't do much in low part count situations, and some patches are highly situational (atmospheric flight, docking ports, struts, particles repositionning on floating origin shifts...)

Patches affecting the FlightIntegrator and VesselPrecalculate are broably incompatible with mods trying to override/extend stuff through MFI. There are a bunch of perf issues with "end of the call stack" methods being inefficient because they do extra work that is already done at the call site or can be made faster by using state from the call site, so patching those methods doesn't cut it, but this mean many stock methods aren't called anymore, so if those methods are replaced/prefixed/postfixed with MFI, things will break. Notable examples are FI.UpdateAerodynamics() and FI.Integrate(Part). This could probably be avoided at the cost of some of the perf gains, but I wanted to see how far things could be pushed perf wise.
On a side note, there is a bug lurking in the VesselPrecalculate.CalculatePhysicsStats reimplementation, not sure what it is exactely but a side effect is camera target being wrongly offset. Likely something with the CoM calcs.
-most notably this caused the camera to be anchored to the wrong place
@JonnyOThan JonnyOThan marked this pull request as ready for review October 7, 2024 02:45
@JonnyOThan JonnyOThan merged commit 7346056 into master Oct 7, 2024
1 check passed
@JonnyOThan JonnyOThan deleted the FlightPerf branch October 7, 2024 02:45
@gotmachine gotmachine restored the FlightPerf branch October 7, 2024 09:31
JonnyOThan added a commit that referenced this pull request Oct 7, 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.

3 participants