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

perf: Remove expensive reflection from raft/mesh hot path #16552

Merged
merged 2 commits into from
May 26, 2023

Conversation

lstoll
Copy link
Contributor

@lstoll lstoll commented Mar 7, 2023

Description

Replaces a reflection-based copy of a struct in the mesh topology with a deep-copy generated implementation.

This is in the hot-path of raft FSM updates, and the reflection overhead was a substantial part of mesh registration times (~90%). This could manifest as raft thread saturation, and resulting instability.

This is a similar problem/fix as #14934, it might be worth seeing if there are any other uses of the reflection copy library and replacing it with (generated) copies.

Fixes #16551

Testing & Reproduction steps

Details in issue #16551 . The before/after from the test case in that issue:

Screenshot 2023-03-07 at 11 35 23

After the change was rolled out, we no longer saw any registration delays and the general raft/FSM thread saturation dropped off substantially

image

PR Checklist

  • updated test coverage
  • external facing docs updated
  • not a security concern

@hashicorp-cla
Copy link

hashicorp-cla commented Mar 7, 2023

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

github-actions bot commented May 7, 2023

This pull request has been automatically flagged for inactivity because it has not been acted upon in the last 60 days. It will be closed if no new activity occurs in the next 30 days. Please feel free to re-open to resurrect the change if you feel this has happened by mistake. Thank you for your contributions.

@github-actions github-actions bot added the meta/stale Automatically flagged for inactivity by stalebot label May 7, 2023
@karlhungus
Copy link

karlhungus commented May 24, 2023

@rboyer / @boxofrad would it be possible to take a look at this? It is a identical similar improvement to the one made in #14934, we've been running this for a few months now, and it'd be great if we could avoid patching consul ourselves.

@github-actions github-actions bot removed the meta/stale Automatically flagged for inactivity by stalebot label May 25, 2023
Copy link
Contributor

@boxofrad boxofrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, thanks @lstoll 🙌🏻 🔥

agent/consul/state/deep-copy.sh Show resolved Hide resolved
@boxofrad boxofrad added backport/1.14 backport/1.15 This release series is no longer active on CE. Use backport/ent/1.15. labels May 25, 2023
Replaces a reflection-based copy of a struct in the mesh topology with a
deep-copy generated implementation.

This is in the hot-path of raft FSM updates, and the reflection overhead was a
substantial part of mesh registration times (~90%). This could manifest as raft
thread saturation, and resulting instability.

Co-authored-by: Joel Brandhorst <[email protected]>
@jmurret jmurret force-pushed the lstoll-deepcopy-upstreamdownstream branch from 929c442 to 04b6a90 Compare May 26, 2023 17:16
@jmurret
Copy link
Member

jmurret commented May 26, 2023

thank you @lstoll ! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.15 This release series is no longer active on CE. Use backport/ent/1.15.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance issues/raft thread saturation on mesh updates
5 participants