pingcap / pingcap/tidb

time of buildCopTask should be recorded into RuntimeStatistics

Open
#35,057 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/enhancement
Dominant language
Go
Stars
40.6k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

Enhancement

The most time-consuming part of buildCopTasks is loading region cache. When there is a mass of regions metadata needs to be loaded, buildCopTasks will spend a lot of time. But we have no way to track this part of time except the log message like [2022/05/31 11:10:05.946 +08:00] [WARN] [coprocessor.go:232] ["buildCopTasks takes too much time"] [elapsed=10.001662187s] ["range len"=1] ["task len"=1].
This may pose a problem that we find a slow sql, but we can not figure out why even if we get the slow log and explain analyze.

We need to record this part of time consumption into the RuntimeStatistics.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in store/copr/coprocessor.go at buildCopTasks and trace how its elapsed time relates to RuntimeStatistics. Review the existing slow-log message and the slow log and EXPLAIN ANALYZE context described in the issue. Done means the time spent by buildCopTasks, including region-cache loading, is available through RuntimeStatistics.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
database, performance
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.