[branch-4.1] pick some sort pr#62856
Merged
yiguolei merged 2 commits intoapache:branch-4.1from Apr 28, 2026
Merged
Conversation
…ache#59207) Timsort is faster than pdqsort for partially-ordered data. Introduce a HybridSorter that samples at sort time to choose between timsort and pdqsort. This optimization can be disabled with enable_use_hybrid_sort; it is enabled by default. ``` Run on (128 X 2250.02 MHz CPU s) CPU Caches: L1 Data 32 KiB (x64) L1 Instruction 32 KiB (x64) L2 Unified 1024 KiB (x64) L3 Unified 16384 KiB (x8) Load Average: 36.25, 46.31, 138.22 -------------------------------------------------------------------------------- Benchmark Time CPU Iterations UserCounters... -------------------------------------------------------------------------------- BM_PdqSort/10000000/0 350 ms 350 ms 2 items_per_second=28.5574M/s random BM_PdqSort/10000000/1 216 ms 216 ms 3 items_per_second=46.3077M/s ascending_saw BM_PdqSort/10000000/2 217 ms 217 ms 3 items_per_second=46.1045M/s descending_saw BM_PdqSort/10000000/3 274 ms 274 ms 3 items_per_second=36.4636M/s generic BM_PdqSort/10000000/4 326 ms 326 ms 2 items_per_second=30.6559M/s random_tail BM_PdqSort/10000000/5 346 ms 346 ms 2 items_per_second=28.8922M/s random_half BM_PdqSort/10000000/6 230 ms 230 ms 3 items_per_second=43.5162M/s wave BM_TimSort/10000000/0 1113 ms 1113 ms 1 items_per_second=8.98417M/s random BM_TimSort/10000000/1 89.9 ms 89.9 ms 8 items_per_second=111.209M/s ascending_saw BM_TimSort/10000000/2 91.0 ms 91.0 ms 8 items_per_second=109.926M/s descending_saw BM_TimSort/10000000/3 533 ms 533 ms 1 items_per_second=18.7505M/s generic BM_TimSort/10000000/4 228 ms 228 ms 3 items_per_second=43.7805M/s random_tail BM_TimSort/10000000/5 559 ms 559 ms 1 items_per_second=17.8817M/s random_half BM_TimSort/10000000/6 87.4 ms 87.4 ms 8 items_per_second=114.384M/s wave ```
`VSortExecExprs` was a legacy wrapper class (ported from Impala) that held `VExprContextSPtrs _ordering_expr_ctxs` along with a dead `_materialize_tuple` branch. Investigation showed that FE's `SortInfo.toThrift()` never sets `sort_tuple_slot_exprs` in `TSortInfo`, so `_materialize_tuple` is always `false` and the materialization code path is unreachable dead code. This PR removes the `VSortExecExprs` class entirely and replaces all usages with direct `VExprContextSPtrs`. - Delete `vsort_exec_exprs.h` and `vsort_exec_exprs.cpp` - Replace `VSortExecExprs&` with `const VExprContextSPtrs&` in all sorter constructors (`FullSorter`, `TopNSorter`, `HeapSorter`, `PartitionSorter`) - Update all operator/sink files: `sort_sink_operator`, `local_merge_sort_source_operator`, `exchange_source_operator`, `partition_sort_sink_operator`, `viceberg_sort_writer` - Remove dead materialization block in `Sorter::partial_sort` and `Sorter::_prepare_sort_columns` - Update all affected unit tests
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
FE Regression Coverage ReportIncrement line coverage |
Contributor
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
yiguolei
approved these changes
Apr 27, 2026
Contributor
|
PR approved by at least one committer and no changes requested. |
Contributor
|
PR approved by anyone and no changes requested. |
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?
#59207
#62428
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)