Skip to content

perf(aggexec): accelerate fixed-width COUNT(DISTINCT) - #28431

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/clickbench-q10-distinct-20260908
Sep 8, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/clickbench-q10-distinct-20260908

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #27672

What this PR does / why we need it:

ClickBench Q10 is dominated by exact COUNT(DISTINCT) state maintenance. The old path probed an arena-backed ordered skiplist for every candidate and rebuilt that representation during state merges. This change keeps the existing skiplist wire/compatibility path for legacy and variable-width states, while adding an exact columnar open-addressing membership/index for one fixed-width DISTINCT argument.

The index stores complete (group, value) keys, so hash collisions cannot change results. Batch preflight performs bounded local deduplication and reserves the exact index/log capacity before publication; BatchFill reuses that admission decision. Fixed-state merges import keys directly, including cross-state-chunk groups, and spill/recovery preserves the fixed-width payload contract. Empty optional indexes can fall back before publication under a tight hard account; published states never switch representation silently. Malformed payloads and corrupt full-table probes fail with bounded invariant errors. Signed zero remains canonicalized and NaN payload identity remains unchanged from the existing aggregate key contract.

Test plan

  • make -j12
  • GOWORK=off .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/group
  • GOWORK=off .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/group
  • Focused tests cover batch-local duplicates, cross-state-chunk group identity, merge deduplication, fixed-state serialization round-trip, NaN/plus-or-minus-zero equivalence with the legacy path, mismatched spill payload rejection, empty fixed rows, and a full malformed index probe.
  • On 10.222.1.55, latest binary was run against 42,203,164 rows: RegionID + COUNT(DISTINCT UserID) completed in 0.844--0.875s (three runs); text-group surrogate completed in 1.077--1.109s; the existing composite SUM/COUNT/AVG/DISTINCT query completed in 1.842--2.047s.
  • The official DuckDB Q10 is MobilePhoneModel + COUNT(DISTINCT UserID); the checked-in 55 fixture has no MobilePhoneModel, so the text surrogate is reported separately rather than presented as an apples-to-apples result.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Independent GPT-6 (medium-effort) review of current PR head 2188292784d1995f01e77a786473a28442d566ea (feature commit b557d4ae62 plus the main merge).

Conclusion: REQUEST_CHANGES (GitHub cannot create a formal request-changes review from the PR author account, so this is recorded as a comment).

  1. P1 — BulkFill does not chunk inputs to the UnitLimit assumed by the new batch-local DISTINCT path. countColumnExec.BulkFill can pass a full vector directly to batchFillArgs. The fixed batch table has 512 slots and distinctFixedBatch.seenOrInsert probes forever when 513 distinct (group,value) pairs fill it. The legacy path similarly returns ErrAllocationAccountInvalid for a 257-row/9-distinct case where the old path was able to proceed. Split the public fill entry point into UnitLimit work units while preserving BulkFill semantics, and add deterministic fixed/legacy 257/513 boundary tests. This is not a claim that every SQL path currently hangs; the direct aggregate API contract is still broken.

  2. P2 — Admission reuse is invalidated by duplicates and NULLs. preflightFixedDistinctBatchFillArgs writes admission.groups only for rows that publish a new key, while matches compares the original full groups vector. Repeated values or NULLs leave zero entries and force re-decoding/re-probing. Results remain correct, but the claimed admission reuse does not work on duplicate-heavy workloads. Copy the complete group mapping and keep publication as a separate bitmap (or equivalent), then add tests with a real allocation account covering batch duplicates, resident duplicates, NULL, and GroupNotMatched. The current count2 tests do not bind an account, so Preflight returns early and does not exercise this code.

  3. P2 — Fixed target receiving a legacy source reserves the wrong representation. The generic merge admission path reserves skiplist arena capacity, but subsequent BatchMerge may insert into the target fixed index and allocate it only at publication. Under a tight hard account this makes preflight succeed and publication fail, breaking the intended admission/spill/retry boundary. Use the target representation for capacity planning and add fixed←legacy and legacy←fixed hard-account tests, including multi-chunk state. Remove any generic ordered-cursor assumption invalid for fixed sources.

Please also link the approved design/validation document in the PR body (this is a >500 production-LOC hot-path/state-representation change), and update the claimed evidence after these fixes.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

修复已推送(b3e57f7d42)。

根因:固定宽度 COUNT(DISTINCT) 的 admission 表只有 512 个槽位,但 BatchFill/BulkFill 可以直接收到超过 hashmap.UnitLimit 的整批输入;超过容量后原实现的线性探测没有终止条件,导致 TestTimeWinSplitDistinctResultAndReplace 卡满 10 分钟。

修复:

  • DISTINCT 大批输入在 batchFillArgs 入口按 hashmap.UnitLimit 分片;驻留索引继续负责跨片去重。
  • 固定 admission 表探测增加有界循环,满表返回受控 invariant error,避免再次无界等待。
  • 增加 8209 行跨片去重回归测试及满表探测测试。

本地最终验证:

  • go test ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/timewin -count=1
  • go test -race ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/timewin -count=1

两组均通过。

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Follow-up closure (e49b831, rebased on the latest PR branch):

  • Fixed direct DISTINCT BatchFill inputs larger than one UnitLimit by preserving the logical offset and splitting into bounded work units; cross-unit duplicate values remain exact.
  • Fixed mixed fixed/legacy DISTINCT merge admission: fixed sources use exact target membership (their iterator is reverse insertion order), legacy sources retain the ordered cursor fast path, and earlier source groups are deduplicated according to their actual representation.
  • Added bounded fixed admission probing, complete admission mapping for duplicate/NULL/GroupNotMatched rows, mixed-representation merge tests, boundary capacity tests, and direct/BulkFill >UnitLimit tests.

Validation on the rebased tree:

  • aggexec package normal: PASS
  • aggexec package race: PASS
  • git diff --check: PASS
  • GPT-6 final pre-submit review: APPROVE

No CI wait was used.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Rebased the PR branch onto the latest main (9f87b62498) and pushed the rewritten feature history. New head: ecaaf64176 (PR run 34259004738 started; not waiting on CI).

The previous failed run 34248405946 was investigated before changing code:

  • UT Coverage failed only in unchanged pkg/tests/issues:
    TestIssue28317ViewSnapshotGateOrderSQL/ordinary_tenant_SNAPSHOT_and_PITR_restore and TestIssue23861FulltextSnapshotRestore failed while querying the SNAPSHOT feature registry. No aggexec stack or assertion was involved; the same package passed in neighboring PR runs.
  • Compose + Pessimistic BVT completed the SQL suite successfully (including aggregate cases). The job failed while finalizing the coverage artifact with an intermediary 403 Forbidden; retries then hit artifact-name 409 Conflict. The readiness connection errors were transient and the BVT proceeded.
  • Utils Coverage was correctly blocked because the failed producers did not publish a complete profile; it calculated no coverage verdict.

Therefore no unrelated snapshot/CI workaround was added to this PR. Rebased-head local validation remains:

GOWORK=off .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/sql/colexec/aggexec
GOWORK=off .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/sql/colexec/aggexec
git diff --check

All passed. The aggexec changes and boundary/mixed-representation regression tests are unchanged in behavior; only the base was refreshed.

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Final re-review on rebased head ecaaf64176:

APPROVE (advisory; author account cannot submit a formal approval). GPT-6 re-checked the complete fixed-width DISTINCT change, including fixed/legacy admission, both merge directions, spill/serialization, BulkFill chunking, bounded probing, and allocation boundaries. No reproducible blocker belonging to this PR was found; git diff --check is clean and the previously recorded normal/race aggexec suites remain green.

The previous failed run was unrelated to this change: UT Coverage failed in unchanged SNAPSHOT issue tests, pessimistic BVT completed SQL execution but failed finalizing a coverage artifact (403, then duplicate-artifact 409), and the aggregate coverage job was correctly blocked by missing producer profiles. The rebased-head CI run is allowed to proceed independently; no test skip/retry workaround or unrelated product-code change was added.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

GPT-6 Astra, medium-effort review of ecaaf64176cb2e2f1edc818c991f63b4cef9869f, against base/merge-base 9f87b6249889107c3c108c133a4c3c8f3bc273ee.

Recommendation: REQUEST_CHANGES — mandatory design evidence is still missing. This is a normal COMMENT because this is XuPeng-SH's own PR.

The remaining blocker is the design gate already raised in the earlier review. This change replaces the authoritative saved-argument representation with an open-addressed membership table and per-group log, adds a retained preflight/publication plan, and changes merge, spill and allocation fallback behavior. It is a core-state/hot-path refactor, well above the 500-production-line trigger. The repository's design-review contract at this head explicitly says: “The implementation PR must link the exact reviewed revision”. The current PR body, review/comment history and #27672 provide implementation/performance evidence, but no such design revision and approval record. docs/design/exact_distinct_key_local_prededup.md covers #27790's planner/shuffle topology and explicitly introduces no new aggregate state; it does not cover this representation change.

Please link the reviewed design revision and its approval, covering representation eligibility (including the other DISTINCT aggregates that share aggExec), exact key/type identity, admission and fallback, merge/serialization compatibility, retained-memory limits, and performance acceptance. If that artifact does not exist, provide and review it before implementation approval. The later advisory implementation approval and green CI do not supply the missing design record.

Implementation inspection completed for all 14 changed files, grouped into index/key identity, fill/preflight, merge/serialization/spill, shared DISTINCT consumers, and tests. The earlier reported >UnitLimit fill, admission-map and mixed-representation merge issues have corresponding fixes and focused regression cases at this head. I found no additional verified runtime blocker in this inspection; this is not an implementation approval while the upstream design gate remains open.

Unhappy-path closure Inspected result
Q1: ownership Index-column partial-allocation rollback, growth replacement, state Free, drain commit/abort, rehome and decoder error cleanup were traced.
Q2: termination Batch and resident lookup/insert probes are bounded; the change adds no goroutine, lock or external wait. Group retries repeat preflight before publication.
Q3: bounds Batch scratch is UnitLimit-bounded; retained index/log columns use the allocation account and participate in DISTINCT retained-byte reporting. Only unpublished empty indexes may fall back.

Evidence: CI run 34259004738 is completed/success and its API head SHA exactly matches the reviewed commit. Shared build, Linux UT, arm64 SCA, UT coverage, proxy BVT and pessimistic multi-CN BVT are successful. Skipped Darwin/upgrade lanes are not treated as passed compatibility evidence. The author also recorded normal/race aggexec passes for this rebased head. git diff --check passes. Performance numbers remain author-reported measurements on the documented 55 fixture, with the surrogate/full-Q10 distinction preserved; they are not an independent before/after benchmark from this review.

Reviewed in a clean detached worktree; no source/test changes or new local test run. Head was rechecked immediately before this COMMENT. No CI polling requested or performed.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Implementation review is clear: no new confirmed runtime blocker was found, and the three previously reported code issues are fixed. The only remaining advisory gate is the missing exact approved design revision/approval record for the core DISTINCT representation change. As this is self-authored, GitHub permits COMMENT only; this is not a code-level request for changes.

@XuPeng-SH
XuPeng-SH merged commit 98171c2 into matrixorigin:main Sep 8, 2026
15 of 18 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/clickbench-q10-distinct-20260908 branch September 8, 2026 20:39
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8431)

## 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#27672

## What this PR does / why we need it:

ClickBench Q10 is dominated by exact COUNT(DISTINCT) state maintenance.
The old path probed an arena-backed ordered skiplist for every candidate
and rebuilt that representation during state merges. This change keeps
the existing skiplist wire/compatibility path for legacy and
variable-width states, while adding an exact columnar open-addressing
membership/index for one fixed-width DISTINCT argument.

The index stores complete (group, value) keys, so hash collisions cannot
change results. Batch preflight performs bounded local deduplication and
reserves the exact index/log capacity before publication; BatchFill
reuses that admission decision. Fixed-state merges import keys directly,
including cross-state-chunk groups, and spill/recovery preserves the
fixed-width payload contract. Empty optional indexes can fall back
before publication under a tight hard account; published states never
switch representation silently. Malformed payloads and corrupt
full-table probes fail with bounded invariant errors. Signed zero
remains canonicalized and NaN payload identity remains unchanged from
the existing aggregate key contract.

## Test plan

- `make -j12`
- `GOWORK=off .agents/skills/mo-dev/scripts/mo-cgo-test -count=1
-timeout=300s ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/group`
- `GOWORK=off .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=300s ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/group`
- Focused tests cover batch-local duplicates, cross-state-chunk group
identity, merge deduplication, fixed-state serialization round-trip,
NaN/plus-or-minus-zero equivalence with the legacy path, mismatched
spill payload rejection, empty fixed rows, and a full malformed index
probe.
- On 10.222.1.55, latest binary was run against 42,203,164 rows:
`RegionID + COUNT(DISTINCT UserID)` completed in 0.844--0.875s (three
runs); text-group surrogate completed in 1.077--1.109s; the existing
composite SUM/COUNT/AVG/DISTINCT query completed in 1.842--2.047s.
- The official DuckDB Q10 is `MobilePhoneModel + COUNT(DISTINCT
UserID)`; the checked-in 55 fixture has no `MobilePhoneModel`, so the
text surrogate is reported separately rather than presented as an
apples-to-apples result.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8431)

## 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#27672

## What this PR does / why we need it:

ClickBench Q10 is dominated by exact COUNT(DISTINCT) state maintenance.
The old path probed an arena-backed ordered skiplist for every candidate
and rebuilt that representation during state merges. This change keeps
the existing skiplist wire/compatibility path for legacy and
variable-width states, while adding an exact columnar open-addressing
membership/index for one fixed-width DISTINCT argument.

The index stores complete (group, value) keys, so hash collisions cannot
change results. Batch preflight performs bounded local deduplication and
reserves the exact index/log capacity before publication; BatchFill
reuses that admission decision. Fixed-state merges import keys directly,
including cross-state-chunk groups, and spill/recovery preserves the
fixed-width payload contract. Empty optional indexes can fall back
before publication under a tight hard account; published states never
switch representation silently. Malformed payloads and corrupt
full-table probes fail with bounded invariant errors. Signed zero
remains canonicalized and NaN payload identity remains unchanged from
the existing aggregate key contract.

## Test plan

- `make -j12`
- `GOWORK=off .agents/skills/mo-dev/scripts/mo-cgo-test -count=1
-timeout=300s ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/group`
- `GOWORK=off .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=300s ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/group`
- Focused tests cover batch-local duplicates, cross-state-chunk group
identity, merge deduplication, fixed-state serialization round-trip,
NaN/plus-or-minus-zero equivalence with the legacy path, mismatched
spill payload rejection, empty fixed rows, and a full malformed index
probe.
- On 10.222.1.55, latest binary was run against 42,203,164 rows:
`RegionID + COUNT(DISTINCT UserID)` completed in 0.844--0.875s (three
runs); text-group surrogate completed in 1.077--1.109s; the existing
composite SUM/COUNT/AVG/DISTINCT query completed in 1.842--2.047s.
- The official DuckDB Q10 is `MobilePhoneModel + COUNT(DISTINCT
UserID)`; the checked-in 55 fixture has no `MobilePhoneModel`, so the
text surrogate is reported separately rather than presented as an
apples-to-apples result.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8431)

## 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#27672

## What this PR does / why we need it:

ClickBench Q10 is dominated by exact COUNT(DISTINCT) state maintenance.
The old path probed an arena-backed ordered skiplist for every candidate
and rebuilt that representation during state merges. This change keeps
the existing skiplist wire/compatibility path for legacy and
variable-width states, while adding an exact columnar open-addressing
membership/index for one fixed-width DISTINCT argument.

The index stores complete (group, value) keys, so hash collisions cannot
change results. Batch preflight performs bounded local deduplication and
reserves the exact index/log capacity before publication; BatchFill
reuses that admission decision. Fixed-state merges import keys directly,
including cross-state-chunk groups, and spill/recovery preserves the
fixed-width payload contract. Empty optional indexes can fall back
before publication under a tight hard account; published states never
switch representation silently. Malformed payloads and corrupt
full-table probes fail with bounded invariant errors. Signed zero
remains canonicalized and NaN payload identity remains unchanged from
the existing aggregate key contract.

## Test plan

- `make -j12`
- `GOWORK=off .agents/skills/mo-dev/scripts/mo-cgo-test -count=1
-timeout=300s ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/group`
- `GOWORK=off .agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1
-timeout=300s ./pkg/sql/colexec/aggexec ./pkg/sql/colexec/group`
- Focused tests cover batch-local duplicates, cross-state-chunk group
identity, merge deduplication, fixed-state serialization round-trip,
NaN/plus-or-minus-zero equivalence with the legacy path, mismatched
spill payload rejection, empty fixed rows, and a full malformed index
probe.
- On 10.222.1.55, latest binary was run against 42,203,164 rows:
`RegionID + COUNT(DISTINCT UserID)` completed in 0.844--0.875s (three
runs); text-group surrogate completed in 1.077--1.109s; the existing
composite SUM/COUNT/AVG/DISTINCT query completed in 1.842--2.047s.
- The official DuckDB Q10 is `MobilePhoneModel + COUNT(DISTINCT
UserID)`; the checked-in 55 fixture has no `MobilePhoneModel`, so the
text surrogate is reported separately rather than presented as an
apples-to-apples result.
XuPeng-SH added a commit that referenced this pull request Nov 13, 2026
… (#32646)

## 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 #27672.

Backports #27693 (`dfef35f7dd94de507d40dd18082b64e7f4b84e40`) and #28431
(`98171c28dbeb7ad1291ce9b0eb5beff7a84cbc32`) together to `4.2-dev`.

## What this PR does / why we need it:

On 4.2, mixed aggregates containing COUNT(DISTINCT) are forced through
one worker/CN, while fixed-width DISTINCT values use ordered skiplist
lookups and repeated arena rebuilding. This adapts the two source
optimizations to the existing 4.2 aggregate owners:

- Allow COUNT-only DISTINCT to merge across workers/CNs, cost retained
distinct arguments when selecting group shuffle, and bypass normal
shuffle only when there is one physical group owner. Other DISTINCT
aggregates and ordered GROUP_CONCAT retain their conservative execution
path.
- Add an exact fixed-width `(group, value)` index and direct merge with
MPool-backed arrays, finite probing, checked growth, coherent
partial-error state, and deterministic cleanup. Keep the existing
aggregate wire format and legacy representation fallback.
- Include the prerequisites needed on this branch: cached-Inserter
successor equality, safe arena relocation/growth, signed-zero
canonicalization, and state reuse after Free. Restrict JOIN-to-GROUP
shuffle reuse to INNER joins so NULL extension cannot split one logical
group between owners.

The [versioned
design](https://github.com/XuPeng-SH/matrixone/blob/a717091e1d8437911f8e90a17463d18ea668ee5a/docs/design/4.2-count-distinct-backport.md)
records the ownership, compatibility, failure and resource contracts.
The design-only phase was approved at
`98387de8fc82d834188df5d42eb84d057cedeecc` before implementation. Final
implementation: `a717091e1d8437911f8e90a17463d18ea668ee5a` against base
`db0a7e76881bba94c2a86504ed8e3b2463fc6835`.

**Validation:** Linux amd64, Go 1.26.4, CGO, `GOAMD64=v1`,
`GOMAXPROCS=4`; native libraries built in this worktree. Repository
`mo-cgo-test` wrapper, `-mod=readonly -p=2 -parallel=2 -short
-tags=matrixone_test -count=1`:

- Full arena, aggregate execution, Group, planner and compiler packages
passed normally and under `-race`; the planner retains three existing
unrelated skipped subtests. The final compiler runs selected 1,514
tests/subtests each with no skips.
- Real three-CN `TestDistinctBackportMultiCN` passed normally and under
`-race`: exact optimized/no-shuffle result equality, executed shuffle on
multiple CNs, DOP 1, duplicate/NULL/tuple and non-COUNT controls, and
LEFT JOIN NULL-group correctness.
- Deterministic failure controls reproduce the missing cached-successor
check and unsafe outer-join reuse; corrected tests pass. Coverage
includes fixed/legacy merges, cross-chunk group identity, old wire
readers, signed zeros/NaN payloads, allocation failure, partial merge
state and cleanup/reuse.
- Configured golangci-lint 2.6.2: zero issues across the six affected
packages/consumers. Configured molint vet: exit 0, no introduced
warnings (nine existing recover diagnostics match the base). Formatting
and `git diff --check` passed.
- Compiler Parquet fixture failures were traced to hidden `.codex` in
GOTMPDIR, which the existing file enumerator skips. Both full compiler
modes passed after setting TMPDIR and GOTMPDIR to a nonhidden disk
directory; no tests were skipped or unrelated source changed.

Paired local executor benchmark, identical 65,536 values/128 groups,
`-benchmem -benchtime=3x -count=3` (median):

| Operation | 4.2 base | This PR |
| --- | ---: | ---: |
| fill | 46.86 ms | 4.99 ms |
| merge 16 states | 43.10 ms | 4.29 ms |

This is a small warm microbenchmark on a shared host, not a production
SQL latency claim. Go allocations fell from roughly 65–68k to 17 per
operation; benchmem excludes MPool off-heap memory.

**Branch limits:** DISTINCT spill and later-main aggregate
preflight/accounting are outside this backport. Existing
operator-pool/shared-global allocation limits remain authoritative;
parallel non-shuffle states and a live merge destination can increase
peak memory. No per-query or tenant-isolated memory bound is added.
Upgrade remains a full shutdown.

**Review:** `gpt-6.1-terra` with `max` reasoning approved the design
before implementation and the complete committed change at
`a717091e1d8437911f8e90a17463d18ea668ee5a` before push. Final review:
PASS, no unresolved material blocker. Base-to-head binary diff SHA-256:
`90694283dab3dd1847d4a7e13d095027f5dc14934c64b782899896ed4f4b1c22`.

GitHub CI has not been verified; local validation does not imply CI
success.

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants