Repository navigation
perf(group): reuse compact group IDs and dense decimal states - #32097
Conversation
|
Independent current-main Q1–Q22 acceptance under the user-updated no-confirmed-regression criterion. Cold full suites excluded; no data/result verification. group / memory3 matched independent process blocks; full cold suite excluded per startup. No data/result verification.
Total sums per-query medians. A lower Total never waives slower-query signals. group / disk3 matched independent process blocks; full cold suite excluded per startup. No data/result verification.
Total sums per-query medians. A lower Total never waives slower-query signals. group / memory3 matched independent process blocks; full cold suite excluded per startup. No data/result verification.
Total sums per-query medians. A lower Total never waives slower-query signals. group / disk3 matched independent process blocks; full cold suite excluded per startup. No data/result verification.
Total sums per-query medians. A lower Total never waives slower-query signals. The SF10 broad Q13 signal was not reproduced by three longer independent confirmations (20 samples per arm), -0.11% with95% interval [-2.45%,+2.28%]. Both SF100 modes have no slower-query interval. Accepted RAM mode uses216GiB, cache192GiB; disk84GiB/cache16GiB; all64 CPUs and identical interleaved NUMA policy. Spilling trials are excluded. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 114f1218a2d990d661cd301fc99685424d4d418f
Assessment: request_changes
The derived lookup reuses the generic grouping owner with bounded accounting and generation cleanup, and the supplied performance evidence supports the scoped no-confirmed-regression criterion. One checked-decimal correctness regression remains: the dense 256-group path changes accumulation order for supported large BatchFill calls and can reject an otherwise valid SUM/AVG with overflow.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
- P2
pkg/sql/colexec/aggexec/decimal_dense.go:96: For non-DISTINCT DECIMAL256 SUM/AVG with 256 resident groups, seed group 256 with six -9e75 values. Call BatchFill with 255 distinct zero-valued groups followed by seven +9e75 rows for group 256 (262 rows total). The previous 255-slot combiner updates that last group's existing state directly; the new dense path instead accumulates all seven positive values locally.
Impact: The local subtotal overflows signed Decimal256 before combining with the existing -5.4e76, although every scalar prefix and the final sum 9e75 fit. Both SUM and AVG now return an error where the baseline dispatcher succeeds. This is a supported large-call component regression; ordinary Group's <=256-row chunks were not shown to hit it.
Evidence: TestReviewDenseCheckedOverflow in review_dense_overflow_test.go reproduces both candidate failures; the same candidate's 257-group controls pass. With the assigned base sumavg2.go overlaid, all four cases pass and serialized intermediate state matches scalar Fill. See candidate-overflow.log, baseline-overflow.log, their overlays and receipts in frozen-audit.json. Large BatchFill calls are also exercised by decimal_dense_test.go:41. Preserve the former checked arithmetic behavior at this boundary, for example by narrowing dense eligibility for checked large calls, and add the existing-state/mixed-sign overflow regression.
Validation:
-
Reviewed every changed hunk in all ten files, the exact versioned design, complete indexed discussion, relevant linked-issue context and the grouping/decimal owners and consumers; retained the source and resource model in source-assessment.md.
-
Reused supplied exact-head SUCCESS conclusions for build, UT, SCA, coverage and compose BVT. Current-main performance reports and independent Q13 confirmation were assessed as attributed evidence; skipped/neutral lanes were not counted as passes.
-
Isolation preflight passed. Fresh top-level make cgo built prerequisites from 193 fingerprinted current inputs in the diagnostic workspace; Go 1.27.1 checks used only assigned caches and supplied test-exec.
-
Focused candidate probe exited 1 with two expected 256-group regression failures and passing 257-group controls. The identical probe using the assigned base dispatcher exited 0 for all four cases. Probe sources, exact overlays, terminal logs and command/source/exit receipts are retained.
-
Frozen-source audit passed: clean exact HEAD, supplied patch match, full change/discussion coverage, git diff --check, verified native inputs and baseline overlay identity, and receipt/log reconciliation.
Limitations:
-
No SQL reproduction of this defect is claimed; the counterexample exercises the maintained large BatchFill API boundary.
-
Raw CI/performance/author package logs were not supplied; local_validation is empty. No broad package, race or performance campaign was repeated. Bulky superseded raw timing/log blocks in linked issue history were not reused as candidate evidence.
Restrict dense SUM/AVG dispatch to widening-safe accumulation or calls of at most 256 rows. Larger checked calls keep the legacy 255-slot combiner, whose overflow-group updates use the existing aggregate state directly instead of creating a potentially overflowing local subtotal. Centralize the shared eligibility check at BatchFill so SUM and AVG cannot diverge. Keep ordinary Group chunks and widening-safe dense accumulation unchanged. Add positive/negative cancellation and real-overflow controls at 256/257 resident groups, comparing successful intermediate SUM state and AVG counts with scalar Fill, and clarify the design bound.
|
@XuPeng-SH Confirmed and fixed in 75887fb222. The legacy combiner holds 255 distinct groups and adds later cache misses directly to their existing aggregate state. Buffering those rows in the dense kernel can introduce a Decimal256 overflow even when every direct update fits. Checked calls with more than 256 rows now keep the unchanged legacy dispatcher. Normal Group chunks (at most 256 rows) and widening-safe dense accumulation retain their optimization. SUM and AVG share the eligibility check at BatchFill. Added Merged main |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 75887fb222c78bc50774f280b8f7f00dab4172a7
Assessment: approve
The bounded derived lookup preserves generic grouping identity, admission and generation cleanup, while dense kernels reuse existing aggregate state and interfaces. The prior checked-decimal accumulation-order defect is resolved by the shared large-call fallback and a focused scalar-oracle regression. No actionable correctness or design findings remain.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Reviewed the complete ten-file delta, versioned design, all seven chronological discussion entries, relevant linked issue bodies/comments, grouping/hash/account/spill/reset consumers and decimal dispatch/state/serialization paths; detailed closure is retained in source-assessment.md.
-
Verified the shared SUM/AVG guard against the legacy 255-slot combiner and inspected all 16 cancellation/overflow test cells plus 256/257-group controls. The new regression preserves the earlier review's distinct failing boundary.
-
Reused the supplied assigned-head terminal SUCCESS conclusions for MatrixOne build, Ubuntu/x86 UT and UT coverage, Linux/arm64 SCA, both active compose BVT lanes, coverage merge and CI Required. Skipped and neutral lanes were not counted as passes.
-
Considered the author's assigned-head reports of full aggexec/group normal suites and focused dense-decimal race tests, and the separately pinned SF10/SF100 RAM/disk measurements with independent Q13 confirmation. These are supplied reports, not fresh local executions.
-
Local isolation preflight passed. The focused five-test selection was attempted through the repository CGo wrapper with supplied test-exec but stopped before compilation because libmo.so is absent and primary-worktree native inputs differ (focused-tests.log); this is an environment diagnostic.
-
Final frozen-source static audit passed: clean exact head, supplied patch matches the range after terminal-newline normalization, diff whitespace check, gofmt on nine changed Go files, named test presence and unchanged kernel-file identities relative to the prior reviewed head. See static-audit.log and matching command/source/exit receipts.
Limitations:
-
No fresh MatrixOne package/race/SQL execution succeeded locally because native prerequisites are unavailable; approval reuses the supplied exact-head CI conclusions and reported focused tests alongside source reasoning. Raw author/CI reports were not included in local_validation.
-
Performance measurements remain pinned to earlier sources. Main's expression-fusion/native changes and the corrective guard were not freshly benchmarked; no current-head speedup or statistical equivalence is claimed. Broader optimization issue acceptance remains open.
-
Bulky superseded timing/code blocks in linked issue #30841 comment 6518924634 were omitted and not reused; its contract/provenance narrative and the other supplied linked discussion were assessed. External material outside frozen evidence was not fetched.
🚫 Left the queue · pull request dequeued34 min in the queue, with no time running CI. So far
Reason Pull request #32097 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.
To get back in the queue
Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
What type of PR is this?
Which issue(s) this PR fixes:
Related to #30841 and #30847. Larger-scale performance acceptance remains open.
What this PR does / why we need it:
Repeated small CHAR grouping re-encodes and hashes keys even after their group identities are established. Keep the generic hash table authoritative and derive a bounded canonical-key-to-group-ID index for eligible one/two-column non-Unicode CHAR(1) inputs after 512 rows. Reuse IDs only for all-hit chunks; misses retain transactional preview, allocation preflight and commit. Publish derived IDs only after aggregate growth and fill succeed, and discard them with the resident generation on reset, rebuild or spill. Charge the index and bounded scratch to the existing group allocation account, and fall back when optional capacity is unavailable.
For non-DISTINCT decimal SUM/AVG with one resident state chunk and at most 256 groups, address existing state directly by group ID, combine local updates, and scatter once per touched group. Limit checked dense accumulation to calls of at most 256 rows; larger checked calls retain the existing combiner so its direct updates cannot become overflowing local subtotals. Widening-safe accumulation keeps the dense path for larger calls. Preserve NULL, constant, offset, overflow and per-group accumulation-order behavior. Existing executor interfaces, decimal types, output grouping, spill format and generic fallbacks remain unchanged.
Review correction
Addressed the checked Decimal256 accumulation-order finding in
75887fb222, after merging main007dd57a61.aggexecandgroupsuites pass; focused dense-decimal tests pass under the race build. Full repository static checks pass.Eligibility clarification: updated design.
Readiness verification at
114f1218a2The reviewed head met the user's no-confirmed-regression criterion. A confirmed speedup was not required.
Clean main
dbf3efd4b5was compared against this PR alone; measured production code matches reviewed head114f1218a2(the measured merge head differs only in documentation). Three balanced independent process blocks covered Q1–Q22 in both storage modes. Cold full suites were excluded; any SF100 spill invalidated the attempt. No data/result verification was added.114f1218a2. This is historical verification; the review correction is recorded below.Totals sum per-query medians. Earlier uncontrolled-placement and spilling attempts are retained and excluded. Historical results below keep their original source pins.
Design
Approved before implementation on 2026-11-03 as an independent part of the three-PR plan. Versioned design: compact-group-state.md. This branch is based directly on main and does not depend on cache PR #32093 or the other optimization branch.
Prior validation
aggexecandgrouppackage tests passed after the borrowed-vector main merge (e358371aa0): 2.635 s and 4.354 s.8aa69be1cf: custom MO checks, license headers, dependency checks and golangci-lint (0 issues).Performance acceptance
The results below remain pinned to the earlier main and reviewed head.
The complete five-pair SF10 screen below is retained evidence against main
54a6b17328, not acceptance for the newly merged main. Q1 improved 19.42% (paired 95% interval -23.80% to -14.80%); the screen had no confirmed slower-query interval. Total latency improved 1.52% by the sum of per-query medians, while its paired interval overlaps zero. Separate instruction measurements were approximately 31% lower for Q1.The previously completed independent checks retain their source pins; the following table is historical evidence. Cold runs are excluded and profiling is separate from scored latency.
Complete historical SF10 per-query wall-time comparison
bench-revised-sf10-compact-group-memory-20261103T234150
Main
54a6b173282c1df71fcbf54fff42869a27cf4fc5; candidate90eca6a7aa1964b1dd20cbad675dd663487f5d57.5 independent process pair(s), SF10, memory database, 32 application CPUs, 48 GiB application limit/no swap, 16 GiB CN cache, 32 GiB aggregate spill threshold. Cold passes excluded; profiles separate. Common release metadata and build flags. All cold/scored/profiling windows completed with zero observed spill activity.
Total/subtotal times sum per-query medians. Paired changes use log ratios of matching process pairs. Paired suite change: -1.42%; interval: [-3.11%, +0.30%].
Confirmed slower-query intervals: none in this campaign; intervals overlapping zero remain inconclusive.