-
Notifications
You must be signed in to change notification settings - Fork 10.1k
adt: split interval tree by right endpoint on matched left endpoints #19768
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
base: main
Are you sure you want to change the base?
adt: split interval tree by right endpoint on matched left endpoints #19768
Conversation
…dpoints, to improve find() performance Signed-off-by: redwrasse <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: redwrasse The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @redwrasse. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@@ -701,16 +716,29 @@ func (ivt *intervalTree) Visit(ivl Interval, ivv IntervalVisitor) { | |||
|
|||
// find the exact node for a given interval | |||
func (ivt *intervalTree) find(ivl Interval) *intervalNode { |
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 was not able to find a proper tests for the Find
method. Would you mind preparing some tests before we change the logic?
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.
Yes,I'll add tests. I was thinking of just adding assertions on the Find
operation to the existing TestIntervalTreeRandom
here as say
for ab := range ivs {
for xy := range ivs {
v := xy.x + int64(rand.Intn(int(xy.y-xy.x)))
require.NotEmptyf(t, ivt.Stab(NewInt64Point(v)), "expected %v stab non-zero for [%+v)", v, xy)
require.Truef(t, ivt.Intersects(NewInt64Point(v)), "did not get %d as expected for [%+v)", v, xy)
}
iv := ivt.Find(NewInt64Interval(ab.x, ab.y))
assert.NotNil(t, iv)
assert.Equal(t, NewInt64Interval(ab.x, ab.y), iv.Ivl)
assert.Truef(t, ivt.Delete(NewInt64Interval(ab.x, ab.y)), "did not delete %v as expected", ab)
delete(ivs, ab)
}
In addition I can add a separate dedicated unit test for the Find
op to test edge cases if that's warranted.
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.
Thanks, please send a separate PR. It should be much easier to review and merge a new tests that don't change the logic.
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.
@serathius opened up a separate MR with IntervalTree.Find()
tests: #19801
Please include benchmark from #19769 in the PR. |
Will do, I'll investigate using benchstats. |
Splits interval trees by right endpoint on matched left endpoints, to improve exact interval matching performance.
This addresses the issue: #19769