-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
New implementation of watch cache using btree data structure. #126754
Conversation
👍 really great work! there is another #126753 seems duplicated? :) |
d086627
to
8a96c58
Compare
/retest |
48e1292
to
795c90f
Compare
Oh, found that original PoC had very inefficient implementation of Get (https://github.com/kubernetes/kubernetes/pull/108392/files#diff-7dbc4a86989f847d364c09b2370266542ccbb72edc66d0f346559771b1445e56R200-R211) that scanned whole keyspace. Fixed |
a3b8124
to
3c430e1
Compare
a2d0739
to
67f3f12
Compare
Just storage implementation using btree and tests. Removed integration to watch cache to avoid too many approvals on feature flags. |
@@ -53,6 +55,12 @@ type storeElement struct { | |||
Fields fields.Set | |||
} | |||
|
|||
func (t *storeElement) Less(than btree.Item) bool { | |||
return t.Key < than.(*storeElement).Key |
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.
Hmm - this is risky. In theory not every btree.Item
has to be storeElement
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.
In cacher yes, that's one of the assumption that allows us to simplify the code.
items = append(items, i.(interface{})) | ||
return true | ||
}) | ||
|
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.
nit: remove empty line
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.
Same in few more similar places below
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.
Done
|
||
if limit == 0 { | ||
s.tree.AscendGreaterOrEqual(&storeElement{Key: continueKey}, func(i btree.Item) bool { | ||
elementKey := i.(*storeElement).Key |
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.
Should we handle i not being storeElement?
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.
Btree store validates all inserted items are storeElement
67f3f12
to
55ad186
Compare
/lgtm |
LGTM label has been added. Git tree hash: 06b7f5e845b72661a9035b289a0ab22bc2425868
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: serathius, wojtek-t The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
55ad186
to
50d2fab
Compare
Fixed typo caught by verify. |
/lgtm |
LGTM label has been added. Git tree hash: 2b01e9e4c7f1726b96bee7c10dbc0ba07066a988
|
@serathius can we reflect what you mentioned in an earlier comment in the release notes? It currently says PS: probably need to do the same for the PR title too. |
@dims Done |
thanks @serathius ! will avoid unnecessary questions :) |
Changelog suggestion -New implementation of watch cache using btree data structure. Implementation is not enabled yet. If it's not enabled, I wouldn't changelog it. |
Continuing work of #108392
Started from taking the exact implementation by @MadhavJivrajani, however updated the btree factor to 32.
Using btree without any changes already is faster than existing ThreadedSafeStore. There are still many improvements that could be implemented.
Btree is awesome for watch cache due to:
Also etcd uses btree to serve ranges too.
Performance improvement:
/kind feature