[opt](sort) avoid copying whole blocks during merge#63429
Open
Mryange wants to merge 2 commits into
Open
Conversation
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: MergeSorterState used the generic row-copy merge path even when the current top run could return its whole remaining block before any other run. This adds a direct whole-block path guarded by a total-order check.
### Release note
None
### Check List (For Author)
- Test: Unit Test
- BE UT: sh run-be-ut.sh --run --filter='MergeSorterStateTest.*'
- Behavior changed: No
- Does this need documentation: No
ca5da84 to
a2e0238
Compare
Contributor
Author
|
/review |
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 31977 ms |
Contributor
TPC-DS: Total hot run time: 169378 ms |
Contributor
Author
|
run buildall |
dd5aa44 to
1e5bf1c
Compare
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 31585 ms |
Contributor
TPC-DS: Total hot run time: 171135 ms |
Contributor
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
Contributor
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
Contributor
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
Contributor
TPC-H: Total hot run time: 30985 ms |
Contributor
TPC-DS: Total hot run time: 169153 ms |
Contributor
Author
|
/review |
Contributor
There was a problem hiding this comment.
Review summary: no blocking issues found in the actual PR diff.
Critical checkpoint conclusions:
- Goal/test coverage: the PR adds a whole-block fast path for merge-sort reads and adds focused BE unit coverage for block swapping and smaller-than-batch behavior. Existing sort operator/heap sorter tests were adjusted to consume multiple output batches, which matches the new behavior.
- Scope: the actual GitHub PR contains only sort fast-path/test changes and is focused.
- Concurrency/lifecycle: no new shared state, threads, locks, or special lifecycle concerns were introduced.
- Configuration/compatibility/persistence: no new config items, storage formats, RPC/thrift/proto changes, or rolling-upgrade compatibility concerns in the actual PR diff.
- Parallel paths: FullSorter/HeapSorter/TopNSorter all use MergeSorterState, so the optimization is applied at the common merge-sort read path.
- Error handling/memory: no Status paths are discarded. The fast path transfers Block ownership by swap only when the current run can be returned whole, avoiding extra copies; it preserves the existing two-call EOS contract.
- Performance: the optimization is reasonable and avoids per-row/per-column copying when one sorted block is wholly before the next run.
- User focus: no additional user-provided review focus was present.
Residual risk: I did not run BE unit tests in this review environment; the conclusion is based on code inspection and the PR patch from GitHub.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary:
MergeSorterStateused the generic copy-based merge path even when the current top sorted run could return its whole remaining block before any other run. This adds a direct whole-block fast path guarded by a total-order check, avoiding unnecessaryinsert_range_fromwork in inner merge.What is changed?
MergeSortCursor::totally_less_or_equals()to detect when the current run is wholly before the next child.MergeSorterState::_merge_sort_read_impl()when the whole-block condition is satisfied.Release note
None