-
Notifications
You must be signed in to change notification settings - Fork 2.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
Improve efficiency of vtorc
topo calls
#17071
Improve efficiency of vtorc
topo calls
#17071
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
17e2786
to
e725df8
Compare
617f306
to
2afa448
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17071 +/- ##
==========================================
+ Coverage 67.17% 67.41% +0.23%
==========================================
Files 1571 1569 -2
Lines 252246 252171 -75
==========================================
+ Hits 169458 170002 +544
+ Misses 82788 82169 -619 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
c8095c0
to
f42dbcf
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.
This is looking good! ❤️ I only had some minor nits and suggestions. Let me know what you think.
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.
Apart from Matt's comments, everything else LGTM. It can be merged once they have been addressed.
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Thanks for the review! Updated with @mattlord's suggestions 👍 |
Whoops, meant to add ^^^ backport labels to a different PR. Removed |
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
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.
We're super close! I really only had the one open question about shard filtering when there's no Keyspace provided.
Co-authored-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
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 good! The only remaining issue is whether or not we want to support filtering by shard w/o a keyspace. I'm OK either way, but if we do want to support that then we should add a test case for it. That make sense?
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
@mattlord I don't plan to support this because I can't think of a use case. I've updated to make keyspace required 👍 |
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Looks like the new unit test is flaky:
That's the only thing left! Thank you for sticking this out, @timvaillancourt ! This will be a nice improvement. |
Hmm, this flakiness is weird. Perhaps I need to sort the |
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
@mattlord I believe moving |
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.
Great work on this, @timvaillancourt ! You can merge any time, just please don't forget to squash and merge.
One last note, up to you if you want to add it:
slices.SortFunc(out, func(i, j *topo.TabletInfo) int {
return cmp.Compare(i.Alias.Uid, j.Alias.Uid)
})
for i, tablet := range out {
expected := tt.expectedTablets[i]
require.Equal(t, expected.Alias.String(), tablet.Alias.String())
require.Equal(t, expected.Keyspace, tablet.Keyspace)
require.Equal(t, expected.Shard, tablet.Shard)
}
Right now you're ordering all of the entries in expectedTablets
by Uid in the test cases. IMO it's worth sorting that slice as well so that things do not become flaky in the future if someone modifies the existing test cases or adds new ones where that slice is not ordered:
slices.SortFunc(out, func(i, j *topo.TabletInfo) int {
return cmp.Compare(i.Alias.Uid, j.Alias.Uid)
})
slices.SortFunc(tt.expectedTablets, func(i, j *topo.TabletInfo) int {
return cmp.Compare(i.Alias.Uid, j.Alias.Uid)
})
for i, tablet := range out {
expected := tt.expectedTablets[i]
require.Equal(t, expected.Alias.String(), tablet.Alias.String())
require.Equal(t, expected.Keyspace, tablet.Keyspace)
require.Equal(t, expected.Shard, tablet.Shard)
}
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
@mattlord thanks for the reviews, added that! |
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> Co-authored-by: Matt Lord <mattalord@gmail.com>
* Move to native sqlite3 queries (vitessio#17124) Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> Co-authored-by: Tim Vaillancourt <tim@timvaillancourt.com> * missing updates Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * fix % Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * missing comma Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> * Improve efficiency of `vtorc` topo calls (vitessio#17071) Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> Co-authored-by: Matt Lord <mattalord@gmail.com> --------- Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com> Co-authored-by: Dirkjan Bussink <d.bussink@gmail.com> Co-authored-by: Matt Lord <mattalord@gmail.com>
Description
This PR adds a similar optimization to this PR to
vtorc
by moving to usingts.GetTabletsByCell(...)
and the newts.GetTabletsByShard(...)
methods to fetch tablets. These methods respect the concurrency limit flag for the topo and seem to be more efficient overallSupport for filtering by keyspace/shard was added to
ts.GetTabletsByCell(...)
which is called byts.GetTabletsByShard(...)
Related to this discussion, we're unfortunately forced to fetch "all" records from the cell just to filter them out by keyspace/shard using
x != y
. In our production when fetching topo records for a single shard, < 0.5% of the topo records fetched are actually used - but that's nothing newRelated Issue(s)
Resolves #17073
Checklist
Deployment Notes