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 sort: speed up 2-level iterator #49832

Merged
merged 21 commits into from
Dec 29, 2023
Merged

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Dec 27, 2023

What problem does this PR solve?

Issue Number: ref #49717

Problem Summary:

What changed and how does it work?

Currently when mergeIter drains a reader, limitSizeMergeIter opens next reader. Opening reader maybe slow if the reader needs network actions. So in this PR we open more readers in background in advance.

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

Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
@ti-chi-bot ti-chi-bot bot added do-not-merge/invalid-title do-not-merge/needs-linked-issue 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 27, 2023
Copy link

tiprow bot commented Dec 27, 2023

Hi @lance6716. 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 Dec 27, 2023

Codecov Report

Merging #49832 (69f02ef) into master (36cafb2) will increase coverage by 0.3341%.
The diff coverage is 0.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #49832        +/-   ##
================================================
+ Coverage   70.9300%   71.2642%   +0.3341%     
================================================
  Files          1368       1430        +62     
  Lines        395429     416154     +20725     
================================================
+ Hits         280478     296569     +16091     
- Misses        95293     100789      +5496     
+ Partials      19658      18796       -862     
Flag Coverage Δ
integration 43.9363% <0.0000%> (?)
unit 70.9300% <ø> (ø)

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

Components Coverage Δ
dumpling 53.9663% <ø> (ø)
parser ∅ <ø> (∅)
br 46.8968% <0.0000%> (-6.0626%) ⬇️

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 28, 2023
@lance6716 lance6716 changed the title [WIP]500 stat 2 global sort: speed up 2-level iterator Dec 28, 2023
@ti-chi-bot ti-chi-bot bot removed do-not-merge/invalid-title do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-linked-issue labels Dec 28, 2023
// we need to call next once because mergeIter doesn't use h[0] as current value,
// but a separate curr field
if mergeIterDrained && i.mergeIter.h.Len() > 0 {
_, ok = i.mergeIter.next()
Copy link
Contributor

Choose a reason for hiding this comment

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

will this close another 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.

in this case mergeIter's curr is empty, so calling next once should only pop from the heap to curr.

defer close(asyncTask)
rd, err := newStatsReader(ctx, exStorage, path, 500*1024)
select {
case <-closeCh:
Copy link
Contributor

Choose a reason for hiding this comment

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

close rd?

}
}()
select {
case <-closeCh:
Copy link
Contributor

Choose a reason for hiding this comment

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

drain preOpenCh and all it's item before return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: lance6716 <[email protected]>
@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 Dec 28, 2023
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 29, 2023
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.

LGTM

Copy link

ti-chi-bot bot commented Dec 29, 2023

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Dec 29, 2023
Copy link

ti-chi-bot bot commented Dec 29, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-29 02:42:21.67545744 +0000 UTC m=+1792832.712684367: ☑️ agreed by D3Hunter.
  • 2023-12-29 03:41:33.531876787 +0000 UTC m=+1796384.569103714: ☑️ agreed by Benjamin2037.

@ti-chi-bot ti-chi-bot bot merged commit 8a79c0d into pingcap:master Dec 29, 2023
24 of 30 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.

3 participants