-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 xDS hot path #14934
perf: remove expensive reflection from xDS hot path #14934
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
|
||
package pbpeering | ||
|
||
// DeepCopy generates a deep copy of *PeeringTrustBundle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't protobufs use proto.Clone
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Backport of #14934 to 1.13 release series. Replaces the reflection-based implementation of proxycfg's ConfigSnapshot.Clone with code generated by deep-copy.
Description
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 theagent/structs
package, which creates a large graph forcopystructure.Copy
to traverse at runtime, on every proxy reconfiguration. This is particularly a problem when updating "global" resources such as wildcard intentions orproxy-defaults
which triggers a thundering herd of updates (and in our tests caused Raft leadership instability).Testing & Reproduction steps
We test the completeness of
Clone
by 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.