-
-
Notifications
You must be signed in to change notification settings - Fork 318
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
Reduce buffering between watcher and Store #1494
Reduce buffering between watcher and Store #1494
Conversation
14df858
to
7d8ec65
Compare
8732b66
to
2797cbf
Compare
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 like this a lot, thanks a lot for doing this. Had a deeper dig into the watcher code and the way this is enabled in watcher
's trampolines (by injecting extra events via the state machinery) and bubbled up to store and swap buffered is just great.
Left some questions and suggestions here and there initially. Unsure of best way forward for subscribers atm.
90c310f
to
045b6b5
Compare
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.
Looking great so far! I left some nitpicks and a larger comment around the dispatch / subscribe interface. It's relatively new so I don't think we need to be too conservative in the changes we make there.
I'll do a more thorough review once I get my bearings a bit more. It's a pretty big change. Super exciting though!
I got tests to pass in #1497. you can cherry pick the last commit there and i think this should work. the complications I ran into:
so have stopped matching on explicit objects (in tests), and moved some tests towards Apply events only (but kept one, without backpressure). |
@clux I've cherry-picked the commit, please let me know if some action is needed from my side to move forward. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1494 +/- ##
=======================================
+ Coverage 74.8% 74.9% +0.1%
=======================================
Files 78 78
Lines 6808 6860 +52
=======================================
+ Hits 5091 5136 +45
- Misses 1717 1724 +7
|
Signed-off-by: Fabrizio Sestito <[email protected]>
Signed-off-by: Fabrizio Sestito <[email protected]>
Signed-off-by: Fabrizio Sestito <[email protected]>
Signed-off-by: Fabrizio Sestito <[email protected]>
Signed-off-by: Fabrizio Sestito <[email protected]>
Signed-off-by: Fabrizio Sestito <[email protected]>
Signed-off-by: Fabrizio Sestito <[email protected]>
Signed-off-by: Fabrizio Sestito <[email protected]>
Signed-off-by: Fabrizio Sestito <[email protected]>
Signed-off-by: Fabrizio Sestito <[email protected]>
Signed-off-by: Fabrizio Sestito <[email protected]>
Signed-off-by: clux <[email protected]> Signed-off-by: Fabrizio Sestito <[email protected]>
952f616
to
d573f4f
Compare
I think this should be in a good state now. Feel free to mark it as ready if you are, because I am perfectly happy with this as it stands. Real world usage is also in-line with numbers in the PR, upgrade was trivial in cases where I was not using custom stores. There is one minor bikeshed to maybe consider: maybe there's potentially better It does this PR, as we could tweak this separately to spare you from that before release. |
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.
🚀 looks great! I think @clux's suggestion around event names is worth following up but I also don't see it as a blocker for this PR. Thanks a lot @fabriziosestito for doing the heavy lifting on this one. :)
Motivation
Fixes: #1487
This PR reduces allocations when the watcher is paging/streaming the initial list.
It updates the
watcher::Event
enum to emit events that can be used to update a buffer on the end side and it updated the reflector store accordingly.Solution
ListWatch strategy
When starting the paginated API request, a
RestartedStart
is returned,and the state is changed from
Empty
toInitPage
.When pages are received,
RestartedPage(objs)
events are returned till the end of the list, then the state is changed toInitPageDone
and theRestartedDone
event is returned.The Store is updated to react to the new events:
RestartedStart
it initializes the bufferRestartedPage(objs)
it extends the buffer with the objects received.RestartDone
it swaps the buffer with the internal store. This allowsto update the store atomically.
StreamingList strategy
The
RestartedStart
event is returned when theInitialWatch
is started, thenRestartedApplied(obj)
orRestartedDelete(obj)
events are returned till bookmark with the"k8s.io/initial-events-end"
annotation is received.Then, the
RestartedDone
event is returned.The store reacts to
RestartedApplied/RestartedDeleted
events by updating the buffer.Benchmarks
Watching 10000 RoleBindings:
ListWatch
strategy:StreamingList
strategy:NOTE:
This is a WIP, need to update tests.