Repository navigation
perf: bound set and cumulative min-max execution state - #27913
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 completed on exact head 27d454c.
Checked both independent changes from correctness, performance, and unhappy-path angles:
- INTERSECT keeps the existing set semantics: one output per build-side key, duplicate probe rows are suppressed across batches, and NULL/non-match behavior is unchanged. Replacing one pooled selection slice per key with one bool makes retained state O(unique keys) bytes with a much smaller constant; Reset/Free drop the state and hash-map cleanup remains intact.
- cumulative MIN/MAX opts into the existing running-window path only through the explicit source-preserving Merge contract. Fixed and varlen Merge copy/compare source state without consuming or aliasing it; NULLs, partition resets, chunk boundaries, cancellation/error cleanup, and final state release remain covered.
- no query- or benchmark-specific branch was introduced.
Validation: git diff --check; exact-head go test for ./pkg/sql/colexec/intersect, ./pkg/sql/colexec/aggexec, and ./pkg/sql/colexec/window passed. CI is green.
Merge Queue Status
This pull request spent 9 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 18 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 29 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 ↓. |
|
Addressed the cumulative MIN/MAX allocation review in fb38c39 with a per-partition cost gate: small partitions use direct prefix evaluation, while partitions whose saved Fill work exceeds one AggBatchSize state chunk retain the running aggregate. This keeps the O(N) path for large partitions without allocating one 8192-slot state chunk per singleton partition. BenchmarkCumulativeMaxPartitionShapes (2048 rows, 5 iterations):
Also extended the regression test across output chunks and a partition boundary, and verified cleanup/mpool reaches zero. Full window and aggexec package tests pass. |
There was a problem hiding this comment.
Deep review of exact head fb38c39 against base 34fb540.\n\nThe blocker from my previous review is closed. The cumulative-window path now selects the retained one-group aggregate per partition: partitions up to the cost crossover use direct prefix evaluation, while larger partitions keep the O(N) running path. This removes the 8192-state allocation churn for singleton/high-cardinality partitions without regressing large or mixed partitions.\n\nI also rechecked the change from the other relevant angles:\n\n- Correctness: cumulative state remains sequential across output chunks and resets exactly at partition boundaries; direct/running transitions preserve frame semantics. Fixed-width and varlen MIN/MAX merges copy values/null state into the destination and do not mutate or alias the retained source.\n- Lifecycle/unhappy paths: errors and cancellation release the running state; normal completion, Reset, and Free also close ownership. There are no new goroutines, waits, or lock/channel edges.\n- INTERSECT: replacing per-key pooled count slices with one boolean preserves set semantics (at most one output row per key), while bounding state by distinct build keys and retaining existing batch/hash ownership.\n- Performance: the threshold bounds direct work for small partitions and avoids the former approximately 64 KiB state chunk per singleton partition; the added singleton/mixed/large benchmarks and boundary/cross-chunk tests cover the intended crossover.\n- Validation: exact-head Ubuntu UT, SCA, coverage, shared build, proxy BVT, and pessimistic BVT are green. The local macOS focused wrapper could not start because the isolated worktree has no matching cgo/libmo.dylib; that is native-artifact provenance, not a code/test failure.\n\nNo remaining blocking issue found.
Merge Queue Status
This pull request spent 1 minute 17 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. Tick the box to put this pull request back in the merge queue (same as
|
…27913) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#26768 ## What this PR does / why we need it: Bound two executor hot paths that become pathological on large analytic inputs: - store one compact seen-state per `INTERSECT` key instead of allocating an unused selection buffer for every key; - let cumulative MIN/MAX use the source-preserving running aggregate path, avoiding a partition-prefix rescan for every output row. Both changes preserve the existing operator and aggregate semantics and contain no benchmark- or query-specific conditions. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: XuPeng-SH <[email protected]>
…27913) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#26768 ## What this PR does / why we need it: Bound two executor hot paths that become pathological on large analytic inputs: - store one compact seen-state per `INTERSECT` key instead of allocating an unused selection buffer for every key; - let cumulative MIN/MAX use the source-preserving running aggregate path, avoiding a partition-prefix rescan for every output row. Both changes preserve the existing operator and aggregate semantics and contain no benchmark- or query-specific conditions. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: XuPeng-SH <[email protected]>
…27913) ## What type of PR is this? - [ ] API-change - [ ] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#26768 ## What this PR does / why we need it: Bound two executor hot paths that become pathological on large analytic inputs: - store one compact seen-state per `INTERSECT` key instead of allocating an unused selection buffer for every key; - let cumulative MIN/MAX use the source-preserving running aggregate path, avoiding a partition-prefix rescan for every output row. Both changes preserve the existing operator and aggregate semantics and contain no benchmark- or query-specific conditions. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Related to #26768
What this PR does / why we need it:
Bound two executor hot paths that become pathological on large analytic inputs:
INTERSECTkey instead of allocating anunused selection buffer for every key;
avoiding a partition-prefix rescan for every output row.
Both changes preserve the existing operator and aggregate semantics and contain
no benchmark- or query-specific conditions.