Skip to content
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

use goroutine pool to copr.(*copIteratorWorker).run #52887

Open
hawkingrei opened this issue Apr 25, 2024 · 1 comment · May be fixed by #53299
Open

use goroutine pool to copr.(*copIteratorWorker).run #52887

hawkingrei opened this issue Apr 25, 2024 · 1 comment · May be fixed by #53299

Comments

@hawkingrei
Copy link
Member

Enhancement

github.com/pingcap/tidb/pkg/store/copr.(*copIteratorWorker).run will always do the runtime.newstack and it will take many time on it. so we can use goroutine pool to resolve it.

https://flamegraph.com/share/7adb104e-02f1-11ef-a542-36adf59c1176

image
@you06
Copy link
Contributor

you06 commented May 15, 2024

Nice catch! This issue impacts the latency and cpu usage more when the coprocessor tasks are small.

I've test a read case with tiny coprocessor queries.

without goroutine pool with goroutine pool diff
93091qps 96475qps +3.2%

The newstack sections in framegraph are gone, and the cpu usage slightly went down in my test! See the total cpu usage of 3 tidb nodes in the metrics.

image

  • Without goroutine pool

image

  • With goroutine pool

image

I'll work on a global goroutine pool in TiDB. The goroutines with short lifetime benefit a lot from it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants