Open hawkingrei opened 2 months ago
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.
I'll work on a global goroutine pool in TiDB. The goroutines with short lifetime benefit a lot from it.
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