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

More microoptimizations #3805

Merged
merged 8 commits into from
Nov 23, 2023
Merged

More microoptimizations #3805

merged 8 commits into from
Nov 23, 2023

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented Nov 22, 2023

On the C++ side:

  1. Replace the std containers with absl containers whenever possible. This saves maybe 5% of the CPU.
  2. Minor code cleanups to use more modern C++.

On the C# side:

  1. Use SetPositionAndRotation to change the transforms. This is supposed to be faster but I guess that it has no effect when the physics is not auto-syncing.
  2. Use TryGetValue instead of ContainsKey + Item[], this saves a lookup.
  3. Rewrite the inner loop that looks at all the PartModules of a Part to use a vanilla iteration instead of Linq. This saves about 10% of the CPU.

At this point we are reaching diminishing returns: Principia is using about 25% of the time of a frame, so any further optimization is going to be essentially invisible.

Fix #3230.

@eggrobin eggrobin added the LGTM label Nov 23, 2023
@pleroy pleroy merged commit d9745a3 into mockingbirdnest:master Nov 23, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

High CPU usage for updating parts in active vessel
2 participants