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

statistics: optimize stats delta dumping with batch processing #58791

Merged
merged 12 commits into from
Jan 13, 2025

Conversation

Rustin170506
Copy link
Member

@Rustin170506 Rustin170506 commented Jan 8, 2025

What problem does this PR solve?

Issue Number: close #57869

close #58331

Problem Summary:

What changed and how does it work?

In this PR I changed DumpStatsDeltaToKV to dump the stats in batch instead of one by one. This will significantly improve the performance of the dump process. From my tests, the duration dropped from 40 minutes to 20 seconds under 100m table workload.

See more: #57869 (comment)

Check List

Tests

  • Unit test
  • Integration test
  • Manual test
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

提升 TiDB 在大量表和高负载下 dump stats delta 更新比较慢的问题
Improve TiDB's slow update of dump stats delta under large number of tables and high loads

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 8, 2025
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 8, 2025
Copy link

codecov bot commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 69.86301% with 44 lines in your changes missing coverage. Please review.

Project coverage is 73.9479%. Comparing base (d966219) to head (4d40e1b).
Report is 32 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58791        +/-   ##
================================================
+ Coverage   73.0741%   73.9479%   +0.8738%     
================================================
  Files          1676       1708        +32     
  Lines        463762     477248     +13486     
================================================
+ Hits         338890     352915     +14025     
+ Misses       104006     102683      -1323     
- Partials      20866      21650       +784     
Flag Coverage Δ
integration 45.7064% <0.0000%> (?)
unit 72.3073% <69.8630%> (+0.0401%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 45.7120% <ø> (-0.0240%) ⬇️

@Rustin170506
Copy link
Member Author

/retest

1 similar comment
@Rustin170506
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 8, 2025
@Rustin170506
Copy link
Member Author

Rustin170506 commented Jan 9, 2025

I tested this PR on the real cluster:

image Before this change: image

After this change:
image

@Rustin170506
Copy link
Member Author

/retest

Copy link
Member Author

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)

@Rustin170506 Rustin170506 requested a review from qw4990 January 9, 2025 09:42
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 13, 2025
Copy link

ti-chi-bot bot commented Jan 13, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-01-08 19:15:03.155221866 +0000 UTC m=+381046.444053592: ☑️ agreed by winoros.
  • 2025-01-13 03:59:54.59333345 +0000 UTC m=+758137.882165154: ☑️ agreed by qw4990.

@Rustin170506
Copy link
Member Author

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 13, 2025
…g of table IDs and enhance assertions for batch updates

Signed-off-by: Rustin170506 <[email protected]>
@Rustin170506 Rustin170506 force-pushed the rustin-patch-dump-batch branch from 590f4e5 to dc8ce37 Compare January 13, 2025 05:48
@Rustin170506
Copy link
Member Author

/retest

@Rustin170506 Rustin170506 force-pushed the rustin-patch-dump-batch branch from dc8ce37 to 6a5bd41 Compare January 13, 2025 07:25
Copy link

ti-chi-bot bot commented Jan 13, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qw4990, winoros

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Rustin170506 Rustin170506 force-pushed the rustin-patch-dump-batch branch from 6a5bd41 to 24f6f64 Compare January 13, 2025 07:36
… table handling and preventing write conflicts

Signed-off-by: Rustin170506 <[email protected]>
@Rustin170506 Rustin170506 force-pushed the rustin-patch-dump-batch branch from 24f6f64 to 4d40e1b Compare January 13, 2025 07:37
@Rustin170506
Copy link
Member Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 13, 2025
@Rustin170506 Rustin170506 added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Jan 13, 2025
Copy link

tiprow bot commented Jan 13, 2025

@Rustin170506: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow 4d40e1b link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@ti-chi-bot ti-chi-bot bot merged commit 7ca323f into pingcap:master Jan 13, 2025
24 of 25 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #58885.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Excessive Stats Updaing Duration in Clusters with Over One Million Tables and Active Workloads
4 participants