-
Notifications
You must be signed in to change notification settings - Fork 142
server: Refactor stream observer #95
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
server: Refactor stream observer #95
Conversation
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.
Nice! Do you have any numbers how much did it improve performance of your control plane?
} | ||
} else if (requestTypeUrl.isEmpty()) { | ||
requestTypeUrl = defaultTypeUrl; | ||
} |
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.
I think you can simplify it. For the defaultTypeUrl
you always pass ANY_TYPE_URL
. You can delete the defaultTypeUrl
from the constructor, pass the ANY_TYPE_URL
to DiscoveryRequestStreamObserver
.
Then you can delete if (defaultTypeUrl.equals(ANY_TYPE_URL)) {
if and also } else if (requestTypeUrl.isEmpty()) {
branch
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.
that is correct, good catch 👍
server/src/main/java/io/envoyproxy/controlplane/server/XdsDiscoveryRequestStreamObserver.java
Outdated
Show resolved
Hide resolved
Haven't run any masurements yet, will do. Gonna run some measurements to see exactly how much memory we would be saving. |
Codecov Report
@@ Coverage Diff @@
## master #95 +/- ##
===========================================
- Coverage 89.8% 89.5% -0.31%
- Complexity 149 193 +44
===========================================
Files 19 22 +3
Lines 569 600 +31
Branches 53 48 -5
===========================================
+ Hits 511 537 +26
- Misses 44 48 +4
- Partials 14 15 +1
Continue to review full report at Codecov.
|
So, I ran some measurements creating 1M objects of Watch and DiscoveryRequestStreamObserver, here are the results. Before
After:
Conclusions:
The savings are noticeable enough for Watches and are incredible when operating with separate XDS streams. Of course there should also be performance improvements when operating with separate XDS streams coming from not using concurrent hash maps but plain field access. |
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 for the report on the performance improvements!
@joeyb Mind taking a look at this? I'm having a hard time finding time to review this unfortunately |
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.
This makes sense, thanks.
cache/src/main/java/io/envoyproxy/controlplane/cache/Watch.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/envoyproxy/controlplane/server/AdsDiscoveryRequestStreamObserver.java
Show resolved
Hide resolved
server/src/main/java/io/envoyproxy/controlplane/server/DiscoveryRequestStreamObserver.java
Show resolved
Hide resolved
server/src/main/java/io/envoyproxy/controlplane/server/DiscoveryRequestStreamObserver.java
Show resolved
Hide resolved
server/src/main/java/io/envoyproxy/controlplane/server/XdsDiscoveryRequestStreamObserver.java
Show resolved
Hide resolved
server/src/main/java/io/envoyproxy/controlplane/server/XdsDiscoveryRequestStreamObserver.java
Show resolved
Hide resolved
@sschepens can I ask whether you planning to work on this PR? I think that the improvements are valuable and it would be great to have this merged. |
@jakubdyszkiewicz yeah, wanted to follow up on this, i had the relevant changes made, but then i got my laptop replaced because of hardware issues and lost them. I'll see if i can address the comments today |
- Extract from Discovery server - Create abstract class - Create Ads observer which maintains current structure - Create simpler Xds observer with less overhead Signed-off-by: sschepens <[email protected]> Signed-off-by: Sebastian Schepens <[email protected]>
Signed-off-by: sschepens <[email protected]> Signed-off-by: Sebastian Schepens <[email protected]>
Signed-off-by: sschepens <[email protected]> Signed-off-by: Sebastian Schepens <[email protected]>
Signed-off-by: sschepens <[email protected]> Signed-off-by: Sebastian Schepens <[email protected]>
Signed-off-by: sschepens <[email protected]> Signed-off-by: Sebastian Schepens <[email protected]>
Signed-off-by: sschepens <[email protected]> Signed-off-by: Sebastian Schepens <[email protected]>
dbaa3f8
to
386a529
Compare
Signed-off-by: Sebastian Schepens <[email protected]>
@snowp @jakubdyszkiewicz addressed comments, review? |
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.
Can you rebase to current master?
server/src/main/java/io/envoyproxy/controlplane/server/DiscoveryRequestStreamObserver.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Sebastian Schepens <[email protected]>
495215f
to
214ddca
Compare
@jakubdyszkiewicz updated from master |
Signed-off-by: Sebastian Schepens <[email protected]>
827352f
to
94dfbac
Compare
Signed-off-by: Sebastian Schepens <[email protected]>
Signed-off-by: Sebastian Schepens <[email protected]>
c70d576
to
b81ef44
Compare
Signed-off-by: Sebastian Schepens <[email protected]>
@snowp can you look at it? Merging is blocked by "change requested" |
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.
Just a tiny nit, otherwise LGTM. Thanks for the contribution! Approving so I won't block merging
server/src/main/java/io/envoyproxy/controlplane/server/DiscoveryRequestStreamObserver.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Sebastian Schepens <[email protected]>
e2c8c54
to
5f91376
Compare
@jakubdyszkiewicz @snowp addressed last comment |
Thank you! Great job |
@snowp could we get a release including the latest changes? |
@snowp we would like to know what's is the instruction for releasing a new version. Is there a link to it? If not, can you drop me the message at my mail (github profile) or Envoy Slack? |
@jakubdyszkiewicz - I haven't written any formal docs yet, but I'll send you the release instructions on slack. |
@jakubdyszkiewicz conflicts which prevent merging this? github isn't reporting any conflicts to me |
may be try a |
The objective of this PR is to reduce the complexity and overhead when not operating in ADS mode.
When working with separate XDS streams the StreamObserver logic can be much simpler and it does not need to store maps, thus reducing the memory overhead.
This also includes a change in
Watch
andStreamObserver
to useAtomic*FieldUpdaters
instead ofAtomic*
which reduces the memory overhead per instance.I realize this introduces a bit of indirection and probably code complexity, but this should be a win when not operating in ADS mode and having thousands of streams.