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

*: global index support index_merge and mem_index_merge #52971

Merged
merged 13 commits into from May 7, 2024

Conversation

Defined2014
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #43013

Problem Summary:

What changed and how does it work?

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 release-note-none size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/planner SIG: Planner labels Apr 29, 2024
Copy link

tiprow bot commented Apr 29, 2024

Hi @Defined2014. 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 Apr 29, 2024

Codecov Report

Attention: Patch coverage is 89.47368% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 74.0324%. Comparing base (3fc5704) to head (743b8ec).
Report is 25 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #52971        +/-   ##
================================================
+ Coverage   72.3804%   74.0324%   +1.6520%     
================================================
  Files          1482       1508        +26     
  Lines        428743     440608     +11865     
================================================
+ Hits         310326     326193     +15867     
+ Misses        99117      94208      -4909     
- Partials      19300      20207       +907     
Flag Coverage Δ
integration 48.8144% <88.7218%> (?)
unit 71.2354% <63.9097%> (+0.0176%) ⬆️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 44.2196% <ø> (+3.0757%) ⬆️

@Defined2014 Defined2014 changed the title *: global index support index_merge and mem_index_merge *: global index support index_merge and mem_index_merge Apr 29, 2024
@Defined2014
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 29, 2024

@Defined2014: 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.

@Defined2014 Defined2014 requested review from AilinKid, guo-shaoge, mjonss and tiancaiamao and removed request for AilinKid and guo-shaoge April 29, 2024 09:30
Copy link
Contributor

@mjonss mjonss left a comment

Choose a reason for hiding this comment

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

LGTM, with some minor suggestions and questions.

pkg/executor/index_merge_reader.go Outdated Show resolved Hide resolved
pkg/executor/index_merge_reader.go Show resolved Hide resolved
pkg/executor/mem_reader.go Outdated Show resolved Hide resolved
cnt := 1
hMap.Set(handle, &cnt)
} else {
*(v.(*int))++
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know much about this part of the executor, can you help me understand what this means? That only if every memory reader has a match, it should be included if intersect later?
Can it be that a single (reader) handle is found multiple times for the same reader?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That only if every memory reader has a match, it should be included if intersect later?

Yes.

Can it be that a single (reader) handle is found multiple times for the same reader?

No, each handle will only appear once in the same index worker.

pkg/planner/core/find_best_task.go Outdated Show resolved Hide resolved
pkg/planner/core/indexmerge_path.go Outdated Show resolved Hide resolved
@Defined2014
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 30, 2024

@Defined2014: 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.

@Defined2014
Copy link
Contributor Author

/hold Awaiting review by planner team and executor team.

@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 Apr 30, 2024
Copy link
Contributor

@AilinKid AilinKid 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

// [partNum][rangeNum]
var readerKvRanges [][]kv.KeyRange
if m.partitionMode {
if r, ok := reader.(*memIndexReader); ok && r.index.Global {
Copy link
Contributor

Choose a reason for hiding this comment

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

seems it's part of range build-related logic, can we move this to buildTableKeyRanges?

Copy link
Contributor

Choose a reason for hiding this comment

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

and here we can only start with L1044

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, PTAL @AilinKid

pkg/planner/core/indexmerge_path.go Outdated Show resolved Hide resolved
readerKvRanges = [][]kv.KeyRange{m.indexMergeReader.keyRanges[i]}
}

for j, kr := range readerKvRanges {
Copy link
Contributor

Choose a reason for hiding this comment

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

this function looks so long, why remove the original encapsulation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the original loop order is

for each partition {
    for each index {
        for each range {
            ....
        }
    }
    do union or intersection
}

Now I changed it to

for each index {
    for each partition {
        for each range {
            ....
        }
    }
}

do union or intersection

The order of loops is same as indexMergeExec. The reason is for global index which is in partition mode, but it only has one partition. And it's hard to create table ranges by distsql.TableHandlesToKVRanges function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I divided this function into two functions

@Defined2014
Copy link
Contributor Author

/test pull-mysql-client-test

@Defined2014
Copy link
Contributor Author

/test check-dev2

Copy link

ti-chi-bot bot commented May 7, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, mjonss

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

Copy link

ti-chi-bot bot commented May 7, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-04-29 12:42:55.849555681 +0000 UTC m=+274729.606691255: ☑️ agreed by mjonss.
  • 2024-05-07 03:16:54.648737871 +0000 UTC m=+931968.405873444: ☑️ agreed by AilinKid.

@Defined2014
Copy link
Contributor 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 May 7, 2024
@Defined2014
Copy link
Contributor Author

/retest

@Defined2014
Copy link
Contributor Author

/test mysql-test

Copy link

ti-chi-bot bot commented May 7, 2024

@Defined2014: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test canary-notify-when-compatibility-sections-changed
  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test mysql-test

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.

@Defined2014
Copy link
Contributor Author

/test mysql-test

@ti-chi-bot ti-chi-bot bot merged commit b66a85c into pingcap:master May 7, 2024
21 checks passed
@Defined2014 Defined2014 deleted the support-index-merge branch May 7, 2024 04:44
3AceShowHand pushed a commit to 3AceShowHand/tidb that referenced this pull request May 7, 2024
terry1purcell pushed a commit to terry1purcell/tidb that referenced this pull request May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The global index not work with IndexMerge executor
3 participants