-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
upstream: avoid copies of all cluster endpoints for every resolve target #15013
Conversation
…cality Currently Envoy::Upstream::StrictDnsClusterImpl::ResolveTarget when instantiated for every endpoint also creates a full copy of envoy::config::endpoint::v3::LocalityLbEndpoints the endpoint belongs to. Given the message contains all the endpoints defined for it this leads to exponential growth of consumed memory as the number of endpoints increases. Even though those copies of endpoints are not used. Instead of creating a copy of envoy::config::endpoint::v3::LocalityLbEndpoints introduce WeightedLocality class which is a wrapper around envoy::config::core::v3::Locality with priority and load balancing weight actually used in the upstream implementation. Signed-off-by: Dmitry Rozhkov <[email protected]>
@rojkov do you have before/after performance figures or flame graphs? :D I can believe this had a major impact, curious what it was . |
Couldn't |
Yes, that's possible with all the tests passing. Here's the v2 patch. I've measured how quickly the current master
v1 with WeightedLocality (I did 4 runs)
v2 with
The v2 patch seems to be as fast as v1, but it makes Though in both cases memory consumption is negligible (pprof doesn't show anything whose cumulative allocations <268k; I couldn't find how to make it show) comparing to the current code. For 9002 endpoints it consumes >20G and can probably explain #14993. |
Yeah, much prefer the v2 patch. Good call @dmitri-d. I am still somewhat convinced that using protos in various places where we don't need is going to bite us, but not this time. |
…int's Locality" This reverts commit 3de74c1. Signed-off-by: Dmitry Rozhkov <[email protected]>
for an instance of StrictDnsClusterImpl while it exists. Signed-off-by: Dmitry Rozhkov <[email protected]>
Switched to v2 and updated the description accordingly. |
/retest |
Retrying Azure Pipelines: |
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.
LGTM, thanks!
Commit Message: upstream: avoid copies of all cluster endpoints for every resolve target
Additional Description:
Currently
Envoy::Upstream::StrictDnsClusterImpl::ResolveTarget
when instantiated for every endpoint also creates a full copy ofenvoy::config::endpoint::v3::LocalityLbEndpoints
the endpoint belongs to. Given the message contains all the endpoints defined for it this leads to exponential growth of consumed memory as the number of endpoints increases. Even though those copies of endpoints are not used.Instead of creating a copy of
envoy::config::endpoint::v3::LocalityLbEndpoints
use a reference to a single copy stored inEnvoy::Upstream::StrictDnsClusterImpl
and accessible from all resolve targets during their life span.Risk Level: Low
Testing: unit tests
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A
May contribute to #12138, #14993