pingcap / pingcap/tidb

Improve Top SQL performance in sysbench

Open
#33,377 0 comments 0 reactions 1 assignee Claimed by @crazycs520 View on GitHub
type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

After Top SQL is introduced sysbench workload degrades from 6% to 10% in different workloads when CPU utilization is full. This issue is to track the optimizing process.

Possible optimizations:

**AttachSQLInfo**:

- [ ] Reduce allocations in `linkSQLTextWithDigest` and `linkPlanTextWithDigest` #33378

- [ ] Reduce number of calls to `AttachSQLInfo`

For 10 QPS oltp_point_select, 30 QPS calls to this function can be observed. We should be able to reduce the calls to 20 QPS (10 for SQL digest, 10 for Plan digest).

- [ ] Further reduce number of calls to `AttachSQLInfo`

It is possible to only call `pprof.SetGoroutineLabels` once per request, as long as we attach a ID to the goroutine, instead of attaching SQL digests and plan digests. This also fully resolves the problem of "Unknown Plan".

- [ ] Hack

`pprof.SetGoroutineLabels` builds the `g.labels` via `runtime_setProfLabel(unsafe.Pointer(ctxLabels))`. So may be we can build and maintain our own map so that it can be reused instead of allocated each time.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.