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

restore: shift rewrite ranges before split ranges #51653

Merged
merged 9 commits into from
Mar 12, 2024

Conversation

3pointer
Copy link
Contributor

@3pointer 3pointer commented Mar 11, 2024

What problem does this PR solve?

Issue Number: close #51685

Problem Summary:

  1. when handing files of drainRange result. restore will check the match rewrite rules for each file. this time could be saved when flatten the rewrite rules with map.

What changed and how does it work?

  1. speed up handling millions of rewrite rules with new split approach by move rewrite ranges forward.
  2. reduce the memory allocation of files object copy.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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.

None

Copy link

ti-chi-bot bot commented Mar 11, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-tests-checked do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 11, 2024
Copy link

tiprow bot commented Mar 11, 2024

Hi @3pointer. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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/test-infra repository.

@3pointer
Copy link
Contributor Author

/test all

Copy link

tiprow bot commented Mar 11, 2024

@3pointer: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test all

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/test-infra repository.

Copy link

codecov bot commented Mar 11, 2024

Codecov Report

Merging #51653 (6b45741) into master (5cb6c0e) will increase coverage by 2.1927%.
Report is 17 commits behind head on master.
The diff coverage is 80.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #51653        +/-   ##
================================================
+ Coverage   70.6982%   72.8909%   +2.1927%     
================================================
  Files          1472       1473         +1     
  Lines        437001     441023      +4022     
================================================
+ Hits         308952     321466     +12514     
+ Misses       108653      99434      -9219     
- Partials      19396      20123       +727     
Flag Coverage Δ
integration 48.8651% <61.3333%> (?)
unit 70.4956% <68.0000%> (-0.0062%) ⬇️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 51.1793% <80.0000%> (+5.3232%) ⬆️

@3pointer 3pointer marked this pull request as ready for review March 12, 2024 05:47
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 12, 2024
@@ -35,7 +40,10 @@ type MergeRangesStat struct {
// By merging small ranges, it speeds up restoring a backup that contains many
// small ranges (regions) as it reduces split region and scatter region.
func MergeFileRanges(
Copy link
Contributor

Choose a reason for hiding this comment

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

It is strange that MergeFileRanges rewrites the key. Maybe rename it to MergeAndRewriteFileRanges.

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 12, 2024
br/pkg/restore/batcher.go Outdated Show resolved Hide resolved
@@ -82,7 +81,7 @@ func (rs *RegionSplitter) ExecuteSplit(

// Sort the range for getting the min and max key of the ranges
// TODO: this sort may not needed if we sort tables after creatation outside.
sortedRanges, errSplit := SortRanges(ranges, rewriteRules)
sortedRanges, errSplit := SortRanges(ranges)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we have the structure before:

map [new table id] ranges

Now it is flatten to []ranges.
Actually, we can sort by new table id instead of range's key

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it has no performance issue.

Copy link

ti-chi-bot bot commented Mar 12, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Leavrth, YuJuncen

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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 12, 2024
Copy link

ti-chi-bot bot commented Mar 12, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-03-12 08:22:55.03945895 +0000 UTC m=+760202.061705339: ☑️ agreed by YuJuncen.
  • 2024-03-12 09:42:15.030378178 +0000 UTC m=+764962.052624567: ☑️ agreed by Leavrth.

@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 Mar 12, 2024
@3pointer
Copy link
Contributor Author

/test check-dev2

Copy link

tiprow bot commented Mar 12, 2024

@3pointer: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test check-dev2

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/test-infra repository.

@ti-chi-bot ti-chi-bot bot merged commit 0639290 into pingcap:master Mar 12, 2024
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. 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.

Enhancing performance in multi-table scenarios
3 participants