-
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
vtorc
: cleanup discover queue, add concurrency flag
#17825
base: main
Are you sure you want to change the base?
vtorc
: cleanup discover queue, add concurrency flag
#17825
Conversation
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
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
|
Signed-off-by: Tim Vaillancourt <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17825 +/- ##
==========================================
+ Coverage 67.44% 67.47% +0.03%
==========================================
Files 1592 1592
Lines 258076 258159 +83
==========================================
+ Hits 174051 174201 +150
+ Misses 84025 83958 -67 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
vtorc
: lockless discover queue, add concurrency flagvtorc
: cleanup discover queue, add concurrency flag
Signed-off-by: Tim Vaillancourt <[email protected]>
|
||
// QueueLen returns the length of the queue. | ||
func (q *Queue) QueueLen() int { | ||
return len(q.queue) |
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.
The previous code did return len(q.queue) + len(q.queuedKeys)
and I'm not sure why 🤔
If we see a reason I can restore this but it adds a lock. I think only metrics call this lock
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Description
This PR cleans up the VTOrc discover queue code, mainly by removing all locking from
.Consume()
; this was achieved by addingtype queueItem struct
and pushing this to the channel instead, with the key andtime.Time
included. Previously thistime.Time
was stored in amap
with mutex locksThe
.QueueLen()
now returns just thelen()
of the queue channel. Before this metric would include the length of the channel plus all that are "in processing" (between.Consume()
and.Release()
), which I'm unsure is necessary. Simplifying this removed the need for a lock in.QueueLen()
Finally, the
--discovery-max-concurrency
flag was added to control how many workers consume the discovery queueBenchmark:
tvaillancourt@tvailla-ltmawfe vitess % go test -v -bench=. ./go/vt/vtorc/discovery/... === RUN TestQueue --- PASS: TestQueue (0.00s) goos: darwin goarch: arm64 pkg: vitess.io/vitess/go/vt/vtorc/discovery cpu: Apple M3 Max BenchmarkQueues BenchmarkQueues/New BenchmarkQueues/New-14 4726 244573 ns/op BenchmarkQueues/Legacy BenchmarkQueues/Legacy-14 3610 338468 ns/op PASS ok vitess.io/vitess/go/vt/vtorc/discovery 3.923s
NOTE:
New
== this PR,Legacy
== current queueRelated Issue(s)
#17330
Checklist
Deployment Notes