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

ddl: determine whether to use merge sort by each index separately #52000

Merged
merged 8 commits into from
Mar 22, 2024

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Mar 21, 2024

What problem does this PR solve?

Issue Number: close #52004

Problem Summary:

Before this PR, when TiDB adds multiple indexes with global sort, merge sort step is determined by external file count of ALL indexes. For example, the threshold is 4000, there are 3 indexes with 3000 files respectively, then there are 9000(>4000) files. Merge sort step will be executed. However, merge sort is not necessary in this case, because the records from different indexes are not overlap.

What changed and how does it work?

  • Use file count from each index to determine whether use merge sort.
  • Refine a error message and add a test case.
  • Use average row size to determine reader count for ingest mode.
  • Increase system session pool from 128 to 512, because readers could increase a lot and block session allocation.

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

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 21, 2024
Copy link

tiprow bot commented Mar 21, 2024

Hi @tangenta. 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.

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Merging #52000 (0d37418) into master (69c26ae) will decrease coverage by 17.7628%.
Report is 7 commits behind head on master.
The diff coverage is 85.8585%.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #52000         +/-   ##
=================================================
- Coverage   72.3939%   54.6311%   -17.7628%     
=================================================
  Files          1481       1592        +111     
  Lines        365286     608874     +243588     
=================================================
+ Hits         264445     332635      +68190     
- Misses        81270     253092     +171822     
- Partials      19571      23147       +3576     
Flag Coverage Δ
integration 36.6009% <85.8585%> (?)
unit 70.4451% <60.6060%> (-1.8294%) ⬇️

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

Components Coverage Δ
dumpling 53.9957% <ø> (-2.3014%) ⬇️
parser ∅ <ø> (∅)
br 51.4451% <ø> (+5.0921%) ⬆️

@@ -1175,7 +1175,7 @@ func (do *Domain) Init(
sysFac := func() (pools.Resource, error) {
return sysExecutorFactory(do)
}
sysCtxPool := pools.NewResourcePool(sysFac, 128, 128, resourceIdleTimeout)
sysCtxPool := pools.NewResourcePool(sysFac, 512, 512, resourceIdleTimeout)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What 128 to 512 mean?

Copy link
Collaborator

@Benjamin2037 Benjamin2037 left a comment

Choose a reason for hiding this comment

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

rest LGTM

for i, g := range kvMetaGroups {
dataFiles := make([]string, 0, 1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not generate subtasks for each index that really needs merge sort?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we do this, in step 3, we need to scan subtasks meta from both step 2 and step 1.

@tangenta
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Mar 22, 2024

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

In response to this:

/retest

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.

@tangenta
Copy link
Contributor Author

/ok-to-test

Copy link

ti-chi-bot bot commented Mar 22, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, wjhuang2016

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 the approved label Mar 22, 2024
Copy link

ti-chi-bot bot commented Mar 22, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-03-22 00:59:15.016006978 +0000 UTC m=+1597582.038253365: ☑️ agreed by Benjamin2037.
  • 2024-03-22 06:22:35.431758908 +0000 UTC m=+1616982.454005291: ☑️ agreed by wjhuang2016.

@ti-chi-bot ti-chi-bot bot merged commit b9d83d3 into pingcap:master Mar 22, 2024
23 checks passed
@ti-chi-bot
Copy link
Member

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

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.0 ok-to-test release-note-none size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-schema adding index should not trigger merge step
5 participants