perf: remove expensive reflection from xDS hot path#14934
Merged
Conversation
Replaces the reflection-based implementation of proxycfg's ConfigSnapshot.Clone with code generated by deep-copy. While load testing server-based xDS (for consul-dataplane) we discovered this method is extremely expensive. The ConfigSnapshot struct, directly or indirectly, contains a copy of many of the structs in the agent/structs package, which creates a large graph for copystructure.Copy to traverse at runtime, on every proxy reconfiguration.
f6101cb to
ff3a827
Compare
rboyer
reviewed
Oct 10, 2022
rboyer
reviewed
Oct 10, 2022
rboyer
reviewed
Oct 10, 2022
|
|
||
| package pbpeering | ||
|
|
||
| // DeepCopy generates a deep copy of *PeeringTrustBundle |
Member
There was a problem hiding this comment.
Shouldn't protobufs use proto.Clone instead?
Contributor
Author
There was a problem hiding this comment.
Maybe, yeah. Although it'd be a bit of a shame to introduce reflection (or at least protobuf's reflection thing) when this type doesn't use any fancy protobuf features.
rboyer
reviewed
Oct 10, 2022
rboyer
reviewed
Oct 12, 2022
rboyer
approved these changes
Oct 13, 2022
boxofrad
added a commit
that referenced
this pull request
Feb 15, 2023
Backport of #14934 to 1.13 release series. Replaces the reflection-based implementation of proxycfg's ConfigSnapshot.Clone with code generated by deep-copy.
3 tasks
This was referenced May 26, 2023
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replaces the reflection-based implementation of proxycfg's
ConfigSnapshot.Clonewith code generated by deep-copy.While load testing server-based xDS (for consul-dataplane) we discovered this method is extremely expensive.
The
ConfigSnapshotstruct, directly or indirectly, contains a copy of many of the structs in theagent/structspackage, which creates a large graph forcopystructure.Copyto traverse at runtime, on every proxy reconfiguration. This is particularly a problem when updating "global" resources such as wildcard intentions orproxy-defaultswhich triggers a thundering herd of updates (and in our tests caused Raft leadership instability).Testing & Reproduction steps
We test the completeness of
Cloneby using gofuzz to construct a "full" snapshot, cloning it, and then comparing the clone to the original.The Envoy integration tests should also catch any regressions.