-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
executor: run idxlookup workers in a pool #58033
Conversation
Signed-off-by: zyguan <zhongyangguan@gmail.com>
Skipping CI for Draft Pull Request. |
Hi @zyguan. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with 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. |
Signed-off-by: zyguan <zhongyangguan@gmail.com>
/ok-to-test |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #58033 +/- ##
================================================
+ Coverage 73.1477% 73.7279% +0.5802%
================================================
Files 1674 1676 +2
Lines 461685 467809 +6124
================================================
+ Hits 337712 344906 +7194
+ Misses 103209 101995 -1214
- Partials 20764 20908 +144
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: zyguan <zhongyangguan@gmail.com>
/retest |
1 similar comment
/retest |
Signed-off-by: zyguan <zhongyangguan@gmail.com>
pkg/executor/utils.go
Outdated
|
||
type gopool struct { | ||
lock sync.Mutex | ||
head *gotask |
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.
How about using a lock free queue to store the pending task pointers, so the Mutex
could be avoided?
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.
Here gopool is mainly for concurrency control, each IndexLookupExecutor has its own pool, that is, there are only about indexLookupConcurrency goroutines access the pool at most 2xNumOfTableTasks times. I think it's acceptable, no need to introduce additional complexity.
pkg/executor/utils.go
Outdated
next *gotask | ||
} | ||
|
||
type gopool struct { |
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.
There is some GoroutinePool
like structures in other packages, how about renaming it to IndexLookupWorkerPool
or CopWorkerPool
it we do not want it to be a generic used type?
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.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cfzjywxk, crazycs520 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 |
[LGTM Timeline notifier]Timeline:
|
Signed-off-by: zyguan <zhongyangguan@gmail.com>
What problem does this PR solve?
Issue Number: ref #56649
Problem Summary: IndexLookupExecutor always starts 1+indexLookupConcurrency goroutines which is expensive for common queries.
What changed and how does it work?
Use a goroutine pool for workers and spawn new goroutine on demand.
Let prepare sysbench dataset with
--secondary
and run point select workload.Previously, tidb spawns 6 goroutines for each query and only two of them are used (non-concurrently).
With this PR, only 1 goroutine are created for both index task and table task.
Here are benchmark results.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.