Repository navigation
perf(group): reduce fixed-width DISTINCT spill overhead - #28108
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of exact head 56f61f1a822e9bf67791f211a2078fa70646c2c8 with counterexample-oriented checks across fixed-width hash-key sizing/encoding, DISTINCT versus aggregate spill fanout, recursive repartition/reload, selection codec wire symmetry, null/grouping/string-source/prepare-kind metadata, empty/all-null/乱序 selections, short writes/truncated input, cancellation, allocation bounds, and cleanup.
The 64-way DISTINCT fanout is consistent from initial bucket creation through partitioning and recursive reload; aggregate paths retain 32-way fanout. Fixed-width selection metadata is written and read symmetrically, while row metadata correctly falls back to the general path. I found no reachable correctness, data-loss, bounds, leak, hang, or compatibility blocker.
The exact-head repository CI run 33834102710 passed its substantive checks, including UT, SCA, coverage, and BVT. Local focused execution was not available in the isolated macOS worktree because thirdparties/install/lib/libmo.dylib is absent.
Merge Queue Status
This pull request spent 12 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Requeued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 32 minutes 45 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #28108 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
…#28108) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#26768 ## What this PR does / why we need it: TPC-DS 1T Q75 spends most of its time repeatedly serializing and re-spilling fixed-width, high-NDV DISTINCT keys. This change: - batches the private fixed-width selected-row spill codec; - coalesces sparse fixed-width spill writes into bounded buffers; - adds an allocation-free fast path for flat nullable fixed keys; - widens spill fanout from 32 to 64 only for aggregation-free DISTINCT and keeps the selected fanout stable across spill waves. The optimization is independent of planner cardinality estimates. Aggregate group spill remains at 32 partitions, limiting the change to the workload shape that benefits and avoiding extra fanout for aggregate-heavy queries. On TPC-DS 1T Q75, wall time fell from 1127.935 s to 546.935 s (51.5%). Against the comparable optimized 32-partition run, it fell from 768.150 s to 546.935 s (28.8%); Group spill serialization fell from 27.756 GB to 13.853 GB and re-spill events from 64 to 0. Controlled current-main A/B runs on the same data and 128 MiB spill limit also showed Q97 improving from 228.200 s to 160.351 s (29.7%) and Q87 from 323.889 s to 241.683 s (25.4%). Q38 was neutral within run-to-run variance (271.555 s to 277.852 s), and Q54 did not enter Group spill. Compared query outputs were byte-for-byte identical, and scan rows/bytes were unchanged. Validation: - package tests for vector codec, hash map, aggregate spill, and Group; - codec/key-path equivalence and malformed-input coverage; - stable fanout and cleanup/error-path tests; - TPC-DS 1T Q75, Q97, Q87, and Q38 result/plan comparisons, plus Q54 and Q64 no-spill controls; - focused spill-writer and flat-key microbenchmarks. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…#28108) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#26768 ## What this PR does / why we need it: TPC-DS 1T Q75 spends most of its time repeatedly serializing and re-spilling fixed-width, high-NDV DISTINCT keys. This change: - batches the private fixed-width selected-row spill codec; - coalesces sparse fixed-width spill writes into bounded buffers; - adds an allocation-free fast path for flat nullable fixed keys; - widens spill fanout from 32 to 64 only for aggregation-free DISTINCT and keeps the selected fanout stable across spill waves. The optimization is independent of planner cardinality estimates. Aggregate group spill remains at 32 partitions, limiting the change to the workload shape that benefits and avoiding extra fanout for aggregate-heavy queries. On TPC-DS 1T Q75, wall time fell from 1127.935 s to 546.935 s (51.5%). Against the comparable optimized 32-partition run, it fell from 768.150 s to 546.935 s (28.8%); Group spill serialization fell from 27.756 GB to 13.853 GB and re-spill events from 64 to 0. Controlled current-main A/B runs on the same data and 128 MiB spill limit also showed Q97 improving from 228.200 s to 160.351 s (29.7%) and Q87 from 323.889 s to 241.683 s (25.4%). Q38 was neutral within run-to-run variance (271.555 s to 277.852 s), and Q54 did not enter Group spill. Compared query outputs were byte-for-byte identical, and scan rows/bytes were unchanged. Validation: - package tests for vector codec, hash map, aggregate spill, and Group; - codec/key-path equivalence and malformed-input coverage; - stable fanout and cleanup/error-path tests; - TPC-DS 1T Q75, Q97, Q87, and Q38 result/plan comparisons, plus Q54 and Q64 no-spill controls; - focused spill-writer and flat-key microbenchmarks. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…#28108) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#26768 ## What this PR does / why we need it: TPC-DS 1T Q75 spends most of its time repeatedly serializing and re-spilling fixed-width, high-NDV DISTINCT keys. This change: - batches the private fixed-width selected-row spill codec; - coalesces sparse fixed-width spill writes into bounded buffers; - adds an allocation-free fast path for flat nullable fixed keys; - widens spill fanout from 32 to 64 only for aggregation-free DISTINCT and keeps the selected fanout stable across spill waves. The optimization is independent of planner cardinality estimates. Aggregate group spill remains at 32 partitions, limiting the change to the workload shape that benefits and avoiding extra fanout for aggregate-heavy queries. On TPC-DS 1T Q75, wall time fell from 1127.935 s to 546.935 s (51.5%). Against the comparable optimized 32-partition run, it fell from 768.150 s to 546.935 s (28.8%); Group spill serialization fell from 27.756 GB to 13.853 GB and re-spill events from 64 to 0. Controlled current-main A/B runs on the same data and 128 MiB spill limit also showed Q97 improving from 228.200 s to 160.351 s (29.7%) and Q87 from 323.889 s to 241.683 s (25.4%). Q38 was neutral within run-to-run variance (271.555 s to 277.852 s), and Q54 did not enter Group spill. Compared query outputs were byte-for-byte identical, and scan rows/bytes were unchanged. Validation: - package tests for vector codec, hash map, aggregate spill, and Group; - codec/key-path equivalence and malformed-input coverage; - stable fanout and cleanup/error-path tests; - TPC-DS 1T Q75, Q97, Q87, and Q38 result/plan comparisons, plus Q54 and Q64 no-spill controls; - focused spill-writer and flat-key microbenchmarks. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
issue #26768
What this PR does / why we need it:
TPC-DS 1T Q75 spends most of its time repeatedly serializing and re-spilling
fixed-width, high-NDV DISTINCT keys. This change:
keeps the selected fanout stable across spill waves.
The optimization is independent of planner cardinality estimates. Aggregate
group spill remains at 32 partitions, limiting the change to the workload shape
that benefits and avoiding extra fanout for aggregate-heavy queries.
On TPC-DS 1T Q75, wall time fell from 1127.935 s to 546.935 s (51.5%). Against
the comparable optimized 32-partition run, it fell from 768.150 s to 546.935 s
(28.8%); Group spill serialization fell from 27.756 GB to 13.853 GB and re-spill
events from 64 to 0.
Controlled current-main A/B runs on the same data and 128 MiB spill limit also
showed Q97 improving from 228.200 s to 160.351 s (29.7%) and Q87 from 323.889 s
to 241.683 s (25.4%). Q38 was neutral within run-to-run variance (271.555 s to
277.852 s), and Q54 did not enter Group spill. Compared query outputs were
byte-for-byte identical, and scan rows/bytes were unchanged.
Validation:
no-spill controls;