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

*: record execute runtime information in slow log #17573

Merged
merged 28 commits into from
Jun 9, 2020

Conversation

crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented Jun 1, 2020

Signed-off-by: crazycs crazycs520@gmail.com

What problem does this PR solve?

Close #15009

Record execute runtime information in slow log plan, such as below:

  1. Enable collect runtime execute information first:
set tidb_enable_collect_execution_info=1;
  1. Then when TiDB output the slow-log, the Plan field value will like below, It will contain the plan runtime execute information.
# Plan: tidb_decode_plan('2wLwlTAJNl84CTAJMQlmdW5jczpjb3VudCgxKS0+Q29sdW1uIzUwCTEJdGltZTo3NjYuMDk5NzZtcywgbG9vcHM6MiwgUGFydGlhbENvbmN1cnJlbmN5OjQsIEZpbmFsQ29uY3VycmVuY3k6NAkxMC43NDAwMDU0OTMxNjQwNjIgTUIJTi9BCjEJMV8xMQkwCTgwMDAJZXEoQwl7LDMxLCAwKQk3NjE0MBGDIDUuMzU5NjQ4bRWEODc2CTEuOTA5NjAzMTE4OAEdDDQ0IE0JWxgyCTExXzEyAeHwWzAwMDAJdGFibGU6U0xPV19RVUVSWSwgb25seSBzZWFyY2ggaW4gdGhlIGN1cnJlbnQgJ3RpZGItc2xvdy5sb2cnIGZpbGUJNzY0NjkJdGltZTo2NTEuODk5NDAzHY4kNwlOL0EJTi9BCg==')
  1. Decode the plan
test> select  tidb_decode_plan('2wLwlTAJNl84CTAJMQlmdW5jczpjb3VudCgxKS0+Q29sdW1uIzUwCTEJdGltZTo3NjYuMDk5NzZtcywgbG9vcHM6MiwgUGFydGlhbENvbmN1cnJlbmN5OjQsIEZpbmFsQ29uY3VycmVuY3k6NAkxMC43NDAwMDU0OTMxNjQwNjIgTUIJTi9BCjEJMV8xMQkwCTgwMDAJZXEoQwl7LDMxLCAwKQk3NjE0MBGDIDUuMzU5NjQ4bRWEODc2CTEuOTA5NjAzMTE4OAEdDDQ0IE0JWxgyCTExXzEyAeHwWzAwMDAJdGFibGU6U0xPV19RVUVSWSwgb25seSBzZWFyY2gga
   -> W4gdGhlIGN1cnJlbnQgJ3RpZGItc2xvdy5sb2cnIGZpbGUJNzY0NjkJdGltZTo2NTEuODk5NDAzHY4kNwlOL0EJTi9BCg==');
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_decode_plan('2wLwlTAJNl84CTAJMQlmdW5jczpjb3VudCgxKS0+Q29sdW1uIzUwCTEJdGltZTo3NjYuMDk5NzZtcywgbG9vcHM6MiwgUGFydGlhbENvbmN1cnJlbmN5OjQsIEZpbmFsQ29uY3VycmVuY3k6NAkxMC43NDAwMDU0OTMxNjQwNjIgTUIJTi9BCjEJMV8xMQkwCTgwMDAJZXEoQwl7LDMxLCAwKQk3NjE0MBGDIDUuMzU5Nj |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|       HashAgg_8               root    1       funcs:count(1)->Column#50                                               1       time:766.09976ms, loops:2, PartialConcurrency:4, FinalConcurrency:4     10.740005493164062 MB   N/A                                                            |
|       └─Selection_11          root    8000    eq(Column#31, 0)                                                        76140   time:765.359648ms, loops:76                                             1.9096031188964844 MB   N/A                                                            |
|         └─MemTableScan_12     root    10000   table:SLOW_QUERY, only search in the current 'tidb-slow.log' file       76469   time:651.899403ms, loops:77                                             N/A                     N/A                                                            |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

As you see, the execute information was contain in the slow-log Plan field now. Since the decode plan field was become too many, we had better add some header column name to more readable, such as below, but we can do this in next PR:

test> select  tidb_decode_plan('2wLwlTAJNl84CTAJMQlmdW5jczpjb3VudCgxKS0+Q29sdW1uIzUwCTEJdGltZTo3NjYuMDk5NzZtcywgbG9vcHM6MiwgUGFydGlhbENvbmN1cnJlbmN5OjQsIEZpbmFsQ29uY3VycmVuY3k6NAkxMC43NDAwMDU0OTMxNjQwNjIgTUIJTi9BCjEJMV8xMQkwCTgwMDAJZXEoQwl7LDMxLCAwKQk3NjE0MBGDIDUuMzU5NjQ4bRWEODc2CTEuOTA5NjAzMTE4OAEdDDQ0IE0JWxgyCTExXzEyAeHwWzAwMDAJdGFibGU6U0xPV19RVUVSWSwgb25seSBzZWFyY2ggaW4gdGhlIGN1cnJlbnQgJ3RpZGItc2xvdy5sb2cnIGZpbGUJNzY0NjkJdGltZ
   -> To2NTEuODk5NDAzHY4kNwlOL0EJTi9BCg==');
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_decode_plan('2wLwlTAJNl84CTAJMQlmdW5jczpjb3VudCgxKS0+Q29sdW1uIzUwCTEJdGltZTo3NjYuMDk5NzZtcywgbG9vcHM6MiwgUGFydGlhbENvbmN1cnJlbmN5OjQsIEZpbmFsQ29uY3VycmVuY3k6NAkxMC43NDAwMDU0OTMxNjQwNjIgTUIJTi9BCjEJMV8xMQkwCTgwMDAJZXEoQwl7LDMxLCAwKQk3NjE0MBGDIDUuMzU5Nj |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|       id                      task    estRows operator info                                                           actRows execution info                                                          memory                  disk                                                       |
|       HashAgg_8               root    1       funcs:count(1)->Column#50                                               1       time:766.09976ms, loops:2, PartialConcurrency:4, FinalConcurrency:4     10.740005493164062 MB   N/A                                                        |
|       └─Selection_11          root    8000    eq(Column#31, 0)                                                        76140   time:765.359648ms, loops:76                                             1.9096031188964844 MB   N/A                                                        |
|         └─MemTableScan_12     root    10000   table:SLOW_QUERY, only search in the current 'tidb-slow.log' file       76469   time:651.899403ms, loops:77                                             N/A                     N/A                                                        |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

What is changed and how it works?

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test(ing)
  • Manual test (add detailed scripts or steps below)

Side effects

  • Performance regression
    • Consumes more CPU
    • Consumes more MEM

Release note

  • record execute runtime information in slow log.

Signed-off-by: crazycs <crazycs520@gmail.com>
@crazycs520 crazycs520 added the type/enhancement The issue or PR belongs to an enhancement. label Jun 1, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Jun 1, 2020

@github-actions github-actions bot added the sig/planner SIG: Planner label Jun 1, 2020
Signed-off-by: crazycs <crazycs520@gmail.com>
Signed-off-by: crazycs <crazycs520@gmail.com>
Signed-off-by: crazycs <crazycs520@gmail.com>
Signed-off-by: crazycs <crazycs520@gmail.com>
Copy link
Contributor

@qw4990 qw4990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@qw4990
Copy link
Contributor

qw4990 commented Jun 2, 2020

/run-all-tests

@qw4990 qw4990 requested a review from Reminiscent June 2, 2020 03:36
@crazycs520
Copy link
Contributor Author

/run-all-tests

@codecov
Copy link

codecov bot commented Jun 2, 2020

Codecov Report

Merging #17573 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #17573   +/-   ##
===========================================
  Coverage   79.4174%   79.4174%           
===========================================
  Files           520        520           
  Lines        139973     139973           
===========================================
  Hits         111163     111163           
  Misses        19819      19819           
  Partials       8991       8991           

analyzeInfo = "time:0ns, loops:0"
}
switch p.(type) {
case *PhysicalTableReader, *PhysicalIndexReader, *PhysicalIndexLookUpReader:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about PhysicalIndexMergeReader?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just extract those code from prepareOperatorInfo, I'm not sure whether it is a bug.... @qw4990 PTAL

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can ignore this problem here since it's another thing, the PhysicalIndexMergeReader doesn't support collecting read-stats now. @wjhuang2016 @crazycs520

@zz-jason
Copy link
Member

zz-jason commented Jun 2, 2020

What's the performance impact when we enable this by default?

Copy link
Member

@wjhuang2016 wjhuang2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

qw4990 and others added 4 commits June 8, 2020 16:37
@wjhuang2016 wjhuang2016 added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. labels Jun 9, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Jun 9, 2020

Sorry @wjhuang2016, you don't have permission to trigger auto merge event on this branch. You are not a committer for this part

@crazycs520
Copy link
Contributor Author

/run-all-tests

1 similar comment
@crazycs520
Copy link
Contributor Author

/run-all-tests

@crazycs520
Copy link
Contributor Author

/run-integration-ddl-test

@crazycs520 crazycs520 merged commit 36ea109 into pingcap:master Jun 9, 2020
@crazycs520 crazycs520 deleted the slow-log-plan-info branch June 15, 2020 06:56
@crazycs520
Copy link
Contributor Author

/run-cherry-picker

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jun 17, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #18072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/config component/expression sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UCP: Add more specified execution information for executor and record in slow log.
7 participants