Skip to content

[Subtask]: Reduce grouped SUM/AVG cost for measured update-locality shapes #30847

Closed

Description

@aunjgr

Parent Issue

#30838

Detail of Subtask

Evidence reassessment — 2026-10-28

Current delivery/performance status: An initialization-only word-store follow-up is open, ready for review, as PR #31482. It is isolated from other SUM implementations and preserves the existing combiner algorithm. Focused SUM/AVG regressions pass on main/candidate; all 615 aggregate test roots, the group consumer suite, scoped SIMD/v3 static analysis and the complete final pre-push gate pass locally. CI and review are pending.

The six-pair, local all-memory SF10 Q1-Q22 screen measured Q1 -1.24% (95% interval -2.98% to +2.10%) and Q18 -1.72% (-4.74% to +4.16%). These are lower observed medians, not statistically established query gains. No query has a slower interval in that screen; higher point estimates such as Q12 +3.36% remain inconclusive. The separate three-warm-call Q1/Q18 context measured +0.76% and +0.84%, also inconclusive, and is reported separately in the PR. The 30-case component screen and independent longer eight-case check have no slower interval and unchanged allocations. Warm fixed-work controls reduce cycles by about 13% (four groups) and 10% (sequential), but the whole-query effect is smaller.

All 24 retained timing arms passed the recorded host/all-memory gates: eight dedicated physical CPUs, 16 GiB CN cache, 32 GiB whole-application budget, maximum conservative footprint 22.86 GiB, zero measured physical reads/writes, spill or application swap. Cold calls are excluded; benchmark scripts do not verify inputs, schemas, rows, references or results. The full PR contains the timing tables and uncertainty. This is limited local SF10 evidence; SF100 and mixed-I/O acceptance and the broader state/update-locality work remain open. Earlier rejected copy revisions and their rejection evidence remain recorded.

Observed: Exact historical D64 batchFill leaves are 23.83% of SF10 and 32.61% of SF100 Q18 user samples, with Group -> buildOneBatch callers. SF100 has 150M global order-key groups and about 8.66 GiB inner state. Global NDV does not reveal distinct groups, repeated destinations or touched state chunks within a 256-row call; partial-aggregate input counters are not independent full scans.

Not yet established: The actual per-call update locality, group repetition, NULL/constant rate and chunk switching on current Q18/Q1. A local combiner can save destination writes even when global cardinality is high. The profile alone cannot choose direct scatter, combining or a state layout.

Next discriminating experiment: Characterize those distributions in a separate bounded diagnostic pass, then compare complete existing-combiner, chunk-local and direct-update costs on matched caller-sized inputs. Include proof/dispatch/state-view setup and destination traffic, not just arithmetic instructions. Reprofile state, hash and system CPU separately.

Measured target: Unchanged Q18 plus Q1/low-cardinality controls: reduce aggregate update/state CPU and improve target latency without shifting cost into probing, memory or kernel work.

Mandatory controls and total cost boundary: Real 256-row calls; separate 8192-row API controls; repeated/sparse/permuted groups; one/many chunks and the last admitted group; early/late transitions; unmatched prefixes; NULL/constant/empty/tiny; SUM/AVG, merge and reuse.

Performance acceptance and rejection

  • Freeze current-main/candidate sources, executables, real caller shapes and effective settings. Use the unchanged qualification SQL and complete result consumption; exclude cold runs and keep profiles separate from latency scoring.
  • Show the named work/CPU reduction and report uninstrumented target-query medians and their uncertainty. For this SUM PR, the requester accepted lower observed medians even when an interval includes zero. Include the controls below and full Q1-Q22 comparison; component wins, source changes, functional tests, SCA, merging and profile percentages are separate evidence.
  • A confirmed affected/control slowdown fails; unresolved slower signals are inconclusive. Confirm with an independent longer balanced run. No gain elsewhere, favorable average or self-approved tolerance waives a regression.
  • Complete applicable SF10/SF100 and memory/mixed-I/O acceptance before issue closure under the umbrella protocol. Report uncertainty, absolute CPU/instructions/work, allocations/copies and the same whole-application budget, effective cache, I/O/spill/swap/pressure evidence. Benchmark scripts do not verify input/table/schema/row counts/reference results/checksums.

Semantics and lifecycle requirements retained

  • A reviewed design states state layout, null/overflow semantics, memory admission/publication and bounded algorithm choice.
  • Focused tests cover low/high cardinality, repeated keys, nulls, empty groups, merge, admission failure and reset/reuse.
  • Report same-work aggregate CPU/instructions and state/peak memory, then warmed unchanged Q18 and a low-cardinality negative control.
  • Keep user-mode improvements distinct from Q18 kernel/page-fault costs, which are tracked separately.

Describe implementation you've considered

Retain useful combining; use an exact resident-chunk proof or direct chunk-local prefix only if measured cheaper, without a losing whole-batch pre-scan. Evaluate state-layout changes as a separate semantic/ownership design. Do not turn an observed NDV into a heuristic or treat the existing table-full fallback as a new optimization.

Coordination: #30846 owns lookup cost, #30857 repeated measures, #30851 system/allocator CPU. Sparse/direct counterexamples remain rejection evidence, not evidence that the SUM hotspot is unimportant.

Additional information

Pinned implementation / plan references

Activity

  1. self-assigned this
    on Oct 22, 2026
  2. added
    severity/s0
    on Oct 22, 2026
  3. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    QA finding for PR #30886 — head f4beca7

    The submitted XuPeng-SH review reports a P2 performance regression in pkg/sql/colexec/aggexec/sumavg2.go:1481 for production-sized grouped-SUM batches. The public aggregation caller caps BatchFill at 256 rows; the new benchmark feeds 8192 rows in one call. With a 256-row workload whose nonmonotonic group IDs are (1999*i)%8192+1, the local table becomes full and subsequent misses keep routing through sumFullLocalIndex.nextProbe. The review reports baseline/candidate medians of 186,970→213,937 ns per 8192 rows (+14.4%) for permuted IDs and 125,359→137,529 ns (+9.7%) for a high-endpoint case, with allocations unchanged.

    This evidence is from the submitted review, not an execution I performed. I inspected the patch and confirmed the mismatch in coverage: the committed benchmark uses an 8192-row BatchFill and i%cardinality group order, so it does not represent the 256-row caller boundary or the reported reordered-ID pattern.

    Please avoid adding per-collision overhead when the remaining IDs are inside the already-proven range, and add a benchmark that calls the dispatcher in repeated 256-row chunks with reordered IDs (plus an in-range control and outside-range misses). The current review reports 18 focused top-level tests passing, but those do not resolve this performance regression.

    Issue #30847 stays open and assigned to aunjgr; no status or assignment change.

  4. XuPeng-SH commented on Oct 23, 2026

    @XuPeng-SH
    Contributor

    QA checkpoint for PR #30886 at final head b9b8d10a99fa2eda770898005c75caa9a0e227ff (2026-10-23): the earlier P2 performance regression reported against f4beca75 no longer exists in this PR's final diff because the range-index and production probe changes have been fully removed. The current PR is limited to sum_local_table_test.go and docs/design/tpch-sum-local-table-validation.md; it adds caller-sized 256-row reordered-ID coverage and preserves explicit large-call controls. The latest review is APPROVED and reports 583 aggexec test roots / 1,940 subtests, all nine benchmark smoke cases, and configured SCA passing; these are reviewer-reported results, not tests I executed in this run.

    The exact-head combined status is empty. MatrixOne ALL CI run 39895488902 failed its Ubuntu/x86 UT job in TestCDCNoFullPublicTakeoverLifecycle at ddl_test.go:1325; the downloaded job log shows a Dragonboat-related timeout in the test trace. This test is outside this PR's two-file final diff. I inspected the GitHub job log but did not rerun or reproduce the failure, so its root cause remains unconfirmed. The successful Iceberg Connector E2E workflow is unrelated.

    Keep #30847 open: this PR withdraws the candidate optimization and does not satisfy the broader optimization objective. No issue status or assignee change.

  5. changed the title [-][Subtask]: Optimize high-cardinality grouped SUM updates and aggregate state[/-] [+][Subtask]: Reduce grouped SUM/AVG cost for measured update-locality shapes[/+] on Oct 25, 2026
  6. aunjgr commented on Oct 27, 2026

    @aunjgr
    ContributorAuthor

    Local-only execution-kernel experiment: rejected; no PR. The optimization issue remains open.

    The final private candidate (6438ba1c10) specializes only an exactly one-resident-chunk Decimal64 SUM/AVG update. It preserves public dispatch, DISTINCT handling, logical count bounds and the original multi-chunk combiner algorithm. Comparison base: b3ed505b729ecb7f33566e551ff135b0f4fca2ce. No optimizer or #31034 changes are included.

    Matched normal Go 1.27.1 builds, GOAMD64=v3 / GOEXPERIMENT=simd, identical fixtures, CPU0/GOMAXPROCS1. Each measurement uses six balanced process pairs, discards the first result of each process, and admits only complete compiler-free pairs. Production owners are separate clean worktrees. No benchmark input/result verification.

    The full 22-case component matrix gives about 32% lower time for four-group SUM/AVG and 54% lower time for several one-chunk shapes, but multiple sparse controls lose. An independent longer confirmation uses 1 second per selected case. Each selected benchmark operation consists of 32 calls with 256 logical rows each; constant NULL exercises dispatch and skips data updates. The table reports nanoseconds for that fixed work:

    Control Main median (ns) Candidate median (ns) Paired change 95% ratio-change interval
    avg_sparse 21351.00 23106.50 +8.42% +7.14% to +9.74%
    const_null 137.50 140.15 +1.89% +1.71% to +2.07%
    unmatched_prefix 7912.00 9613.50 +21.40% +21.22% to +22.77%

    Both sides report zero allocations in every measured component case. Owning aggregate/group correctness suites pass; these results do not satisfy the performance gate. No TPC-H latency/profile campaign or SF100 result is claimed for this candidate, and no benchmark MO service is left waiting.

    Earlier experiments also rejected the multi-chunk local-prefix route. Generated-code inspection found a duplicated out-of-line NULL check and register spills in one dispatcher variant; removing that duplication did not resolve the slower controls. The additional profiles below identify the dominant kind of stall and a plausible layout trigger; they do not prove that grouped updates cannot improve. Broader SF10/SF100 and mixed-I/O acceptance remains outstanding; performance verification for this task is local only.

    Follow-up local diagnosis, warm runs: The shared-owner candidate leaves multi-chunk updates on the combiner. In two independent paired profiles of sparse AVG, the candidate used about 9–10% more cycles per fixed operation. AMD's frontend-empty-dispatch-slot counter rose 3.2–3.5×, while dispatched loads and stores were effectively unchanged (within about 1%) and backend-stalled slots fell 17–23%. Separate CPU samples put about 97% of cycles in the combiner on both sides.

    The combiner initializes a 256-byte slot table on each call. In the unmatched-prefix profiles, samples near that initialization loop rose from about 15% to 28% of samples in the combiner. The older rejected one-chunk dispatcher had an instruction-for-instruction identical combiner body, but its location shifted: the slot-initialization loop moved from byte offset 15 to 47 in a 64-byte instruction-cache line and crossed into the next line. The final shared-owner version placed the loop at offset 59, also across a line boundary. This code-placement change is a plausible contributor to the measured frontend stall; the profiles do not isolate it as the sole cause. Sampling skid limits instruction-level attribution.

    These are separate, warm-only diagnostic recordings using the frozen Go 1.27.1 binaries, not TPC-H measurements. Counters were normalized to benchmark work using the warm run and task-clock. The earlier six-pair latency confirmation remains the rejection evidence. An unrelated Cargo build interrupted other profiles; those interrupted arms were excluded.

  7. aunjgr commented on Oct 27, 2026

    @aunjgr
    ContributorAuthor

    Closing as not planned, based on the local evidence below. This is a decision not to pursue these designs under the current acceptance criteria; it is not a claim that the historical SUM/AVG hotspot can never be improved.

    The first locality-aware direct-update candidate made several one-chunk cases faster, but independent longer controls confirmed sparse AVG at +8.4% and unmatched-prefix updates at +21.4%. A zero-sentinel combiner then confirmed +5.7% for four groups, +7.3% for sparse AVG and +10.5% for permuted groups. A one-based revision removed most of those losses but independent longer controls still confirmed +2.67% for four-group SUM (95% interval +2.16% to +3.10%) and +2.53% for low-cardinality AVG (+1.90% to +2.89%). The many-chunk confirmation remained inconclusive. Gains in other cases do not waive these regressions.

    The exact one-based candidate 77bf8cb48e was also compared with clean main 1231f06468 locally on unchanged SF10 Q1 and Q18. Six balanced independent process pairs used three warm calls per query after an excluded cold warmup:

    Query Main median Candidate median Median paired change 95% interval
    Q1 1.434 s 1.404 s -0.51% -3.67% to +0.15%
    Q18 1.009 s 0.990 s -1.78% -4.56% to +0.50%

    Paired changes are medians of per-pair ratios and need not equal the ratio of the two marginal medians. Both query intervals cross zero, so neither establishes an end-to-end improvement. All 12 retained arms used eight physical cores, a 16 GiB CN cache and a 32 GiB application cap, with zero measured physical I/O, spill and application swap. The maximum conservative application footprint was 19.25 GiB. Whole pairs affected by other compilation were excluded and rerun. The local worker executed and drained queries without validating input, schemas, rows or references, or serializing or hashing results. SF100 was not measured locally.

    Owning aggexec/group tests, the focused race test and scoped static checks passed. No production PR was opened. A future proposal can reopen this issue if it demonstrates a workload benefit without the affected/control regressions.

  8. aunjgr commented on Oct 27, 2026

    @aunjgr
    ContributorAuthor

    A further isolated candidate 6f13c894b9 initialized the existing 256-byte 0xff slot table eight bytes at a time, keeping the per-row combiner logic unchanged. The 22-case owner matrix showed faster signals in 17 cases, no slower signals, and no allocation increase; representative CPU profiles showed about 5–7% fewer cycles and instructions. Owning aggexec/group tests, focused race checks and scoped static analysis passed.

    The required current-main local SF10 latency improvement was not established. Each independent confirmation used six balanced process pairs, nine warm calls per arm, and an excluded cold warmup:

    Query Main median Candidate median Median paired change 95% interval
    Q1 1.427 s 1.415 s -0.76% -1.43% to +0.11%
    Q18 0.968 s 0.965 s -0.64% -1.95% to +0.76%

    Paired change is the median of per-pair ratios, so it need not equal the ratio of the two marginal medians. Both intervals cross zero. The earlier three-call target comparison was also inconclusive for both queries. All 36 target and confirmation arms passed host/all-memory gates, with zero measured physical I/O, spill and application swap; peak conservative application memory was 19.25 GiB. Profiles were separate, and queries were executed and drained without input, schema, row, reference, result or checksum verification. SF100 was not measured locally.

    The requester confirmed that a demonstrated TPC-H speedup is required. The unfinished full Q1–Q22 run was therefore stopped, with completed samples retained but not treated as a pass. No PR was opened; the issue remains closed as not planned. This does not establish that the candidate or the broader hotspot is impossible to optimize, only that this candidate did not meet the requested delivery gate.

  9. aunjgr commented on Oct 27, 2026

    @aunjgr
    ContributorAuthor

    Follow-up: refreshed-main SUM slot initialization

    The requester subsequently directed creation of the SUM PR based on the previously observed faster query medians, even though their intervals included zero. That direction removes the earlier requirement for a statistically confirmed speedup; it does not waive a confirmed slowdown. I therefore refreshed main and independently checked the candidates before opening a PR. None of the tested revisions met the no-regression gate.

    The common baseline was MatrixOne main 802376360c574f44aea23db5eef3cfcebf0527fd. Each TPC-H SF10 measurement used isolated normal Go 1.27.1 builds, six balanced process pairs and nine warm executions per query per arm; the first cold run was excluded. The table shows medians across process arms and the median of within-pair ratios. The marginal median ratio need not equal the median paired change.

    Candidate SF10 Q18 main median Candidate median Paired change 95% paired interval
    Eight-byte table initialization (d8dcf7a573) 0.9851 s 0.9947 s +1.03% +0.38% to +2.57%
    One-chunk-only eight-byte initialization (2f455d0ac4) 0.9697 s 0.9876 s +1.11% +0.52% to +3.71%

    The broad version retained the original per-row combiner, but its Q18 slowdown independently reproduced after full-suite screening. Restricting the new initialization to one state chunk did not remove the Q18 slowdown: all six pairs in its separate nine-call confirmation were slower. For context, the narrow version's earlier Q1/Q18 target run showed Q1 −1.76% (95% interval −3.38% to +3.69%) and Q18 +2.47% (−0.79% to +3.84%). Its full Q1–Q22 screening did not individually establish a slower query interval; a subsequent independent Q18 confirmation produced the result in the table. These are separate contexts, not a claim that every run regressed.

    A further constant-copy revision (44de52621a) fills the 256-byte sentinel table from one immutable constant without a state-shape branch. Its initial 22-case component matrix showed ten faster signals and eight slower signals. A separate longer confirmation using the same source-isolated builds reproduced four slower cases:

    Grouped SUM/AVG control Main median (ns/op) Candidate median (ns/op) Paired change 95% paired interval
    Low-cardinality AVG, 256-row calls 20,949.5 21,210.0 +1.30% +0.88% to +1.46%
    Permuted groups, 256-row calls 55,986.0 61,112.0 +9.00% +8.71% to +9.99%
    Sparse many-chunk groups, 256-row calls 50,050.0 52,331.5 +4.32% +2.70% to +5.46%
    Sequential groups, one 8,192-row call 16,154.0 17,276.5 +6.67% +5.04% to +8.68%

    Each operation covers 8,192 rows. The confirmation used six balanced, compiler-free process pairs, one second per case and an excluded first result; both sides reported zero allocations per operation. The owner aggexec/group tests and focused race check passed for this candidate. No TPC-H latency run was performed for the constant-copy revision after its control regressions were confirmed; its query effect is unknown.

    TPC-H used eight local physical CPUs, a 16 GiB CN cache and a 32 GiB whole-application budget. Retained arms passed the recorded all-memory and host gates, with no measured physical I/O, spill or application swap. Profiling was separate from scored latency. The worker executed and drained queries without validating input, schemas, rows or results or computing checksums. SF100 was not measured for these revisions.

    Disposition: no SUM PR was opened for these revisions, and this issue remains closed as not planned for them. The results do not prove the grouped SUM/AVG hotspot is impossible to optimize. A different design needs independent caller-shaped controls and TPC-H evidence without confirmed regressions.

  10. reopened this on Oct 27, 2026
  11. MatrixAdventurer commented on Oct 28, 2026

    @MatrixAdventurer
    Contributor

    【每日核实】结论:部分修复(优化载体已合入,子任务验收未完成,不建议关闭)。
    证据:PR #31482(2026-10-27 22:17 合入 main,6 文件 +504/-2)将 256B 槽位表初始化改为 32×8B word store(encoding/binary.LittleEndian.PutUint64),保持 0xff 哨兵与原算法/索引。PR 报告:新增 wraparound(255→0)、final slot、repeated-group fallback、offsets、多 chunk 回归;615 聚合 test roots、SCA 零问题、pre-push 门通过;组件级用户周期 −13.0%/−12.6%(four groups)、−10.5%/−10.2%(sequential);SF10 Q1-Q22 无变慢区间,Q1 −1.24%/Q18 −1.72% 多数区间跨零。此前同型候选曾确认 Q18 +1.03% 变慢,本 PR 最终筛选未复现,需跟进。
    还缺:SF100 与 mixed-I/O 验收未做、查询级收益未确认。建议保持 open,由 @aunjgr 按验收标准判定。
    本操作由LW授权的MOI智能体提交

  12. assigned and unassigned on Nov 18, 2026
  13. XuPeng-SH commented on Nov 18, 2026

    @XuPeng-SH
    Contributor

    转交 QA:已合入的 decimal SUM/AVG state 优化

    @Ariznawlll 请接手回归验证。本次为转测,不代表性能验收通过或关闭 issue。

    • 交付:perf(aggexec): fill Decimal64 combiner slots with word stores #31482 的初始化优化已合入 main(8d63bb709665a6ab084cd63c707a5771a2856f7d);后续 perf(group): reuse compact group IDs and dense decimal states #32097 已合入 main(781ebc03d905d646c38a1699488cb80e3288ecb1),交付有界小组数 dense decimal SUM/AVG state 路径,复用已有 group ID/state,保留 generic/多 chunk/不适用输入回退。不能再仅凭旧正文将 state/locality 工作描述为未交付。
    • 正确性证据来自作者与 review,非本次巡检实测:perf(group): reuse compact group IDs and dense decimal states #32097 早期 review 的 checked Decimal256 大 BatchFill 累加顺序反例已在 75887fb222c78bc50774f280b8f7f00dab4172a7 修正。checked 且超过 256 行的调用保留 legacy combiner;作者报告 SUM/AVG、两种 cancellation 符号、真实正负溢出及 256/257-group 对照共 16 个测试单元通过,完整 aggexec/group、focused race 和 SCA 通过。最终 review 为 approve,无未解决 correctness/design finding。
    • 性能证据:独立源版本比较覆盖 SF10 RAM/disk 及 server129 SF100 RAM/disk Q1–Q22;初始 Q13 slower signal 在后续独立确认中未复现。它们属于较早 114f1218a2 / main dbf3efd4b5 的源版本,不是最终修正后合并 SHA 的新基准;不声称统计等价或当前 main 无任何回退。
    • 验证边界:最终 reviewer 的本地执行因缺少 libmo 前置条件未完成,复用了作者测试报告和所提供 CI 结论。本次仅核查远端状态与完整讨论,没有运行本地 SQL、package/race 或性能测试。最终 merge 的性能、其他部署/规模仍由 QA 核验。
    • 建议重点覆盖 255/256/257 组、单/多 state chunk、256 与更大行数、非零 offset、重复/稀疏/排列 group ID、NULL/constant/unmatched、SUM/AVG 正负取消及真正溢出、reset/spill/rebuild 和分配失败回退;保持标量语义、累加顺序和生命周期。
    • 独立开发边界:跨多个 aggregate executor 的 shared traversal 仍由 [Subtask]: Fuse eligible expression and aggregate loops with measured SIMD specialization #30860 跟踪,不在本次已交付 dense-state 组件中宣称完成。更广优化与最终性能验收不因本次转测自动完成。
  14. Ariznawlll commented on Nov 19, 2026

    @Ariznawlll
    Collaborator

    QA 本轮验收:resident SQL 与 Go spill 通过;真实 SQL spill 被资源配额阻断,保持 OPEN

    本轮验证已合入 main 的 #31482(merge 8d63bb709665a6ab084cd63c707a5771a2856f7d)和 #32097(merge 781ebc03d905d646c38a1699488cb80e3288ecb1)。resident 功能结果未发现错误,Go 单测中的 spill 已通过;但独立真实 SQL spill 场景没有跑通,因此不能宣称完整验收通过。

    验证版本与范围

    • 本地运行实例:035af996806917b23d9428695e0295b65cb16356,git_version()=035af99680,version()=8.0.30-MatrixOne-v1.3.0。
    • focused Go 验证树 HEAD:3b95c0878f88b3da58bf3e65c369b7ef4d13104e。
    • 两个交付 merge commit 均已核对为上述运行实例和 Go 验证树的祖先。
    • 本轮只覆盖 main 交付线,不外推到 4.2-dev/hotfix;没有修改产品源码或放宽资源保护。

    resident SQL:实际通过

    构造了 32,770 行确定性数据,覆盖 7 个双 CHAR 分组、空串/尾空格、nullable 分组、Decimal64/128 的 NULL、大负数和超过 18 位的 Decimal128。每个结果集均与独立 SQL oracle 比较。

    通过的消费者场景包括:

    • 单 CHAR 分组:6 行;双 CHAR 分组:7 行。
    • nullable fallback:5 行;宽键 fallback:676 行。
    • Decimal64/128 SUM、AVG、COUNT,包括大负数及高精度值。
    • 常量 Decimal 投影:6 行;空输入:0 行。
    • 同连接重复执行结果一致。
    • prepared Decimal 参数及第二范围:首次 6 行、空第二范围 0 行、非空第二范围 1 行、重复执行 1 行,均符合 oracle。

    EXPLAIN ANALYZE PREPARE/EXECUTE 在当前版本不受支持,所以 prepared 用结果 oracle 验证;Analyze 改为显式绑定相同参数值的 SQL。该替代计划的 Aggregate inputRows=2 outputRows=1 不作为 prepared 内部优化命中统计。

    focused Go:实际通过

    • TestCompactGroupCanonicalKeysAndSpill:single、tuple、spill、dictionary 全部 PASS。
    • spill 子测试真实记录到 GroupCompactLookupRows=256、GroupSpillWriteCalls=1、GroupSpillReloadRows=5。
    • TestCompactGroupFallbackAndGeneration、TestCompactGroupAdmissionFailure PASS。
    • TestDecimal64DenseBatchMatchesRowFill PASS,覆盖 0/1/100/255/256/257/8193 groups,以及 ordinary、nullable、constant、all-null、SUM/AVG。
    • TestDecimal64BatchConstNullPreservesState、TestDecimal64DenseBatchGrowthBoundary、TestDecimal64DenseBatchPreservesUncheckedPrefixSemantics PASS。

    真实 SQL spill:未完成,原因是环境资源阻断

    独立 SQL spill 执行失败,服务端原始错误为:

    resource exhausted: group spill disk budget exceeded
    (requested=462, used=0, limit=1)
    

    当前低可用空间下自动磁盘预算被压到 1 字节;实现仍保留 minimumHeadroom = uint64(16 << 30) 的保护。失败 SQL 的服务端诊断出现了 GroupCompactLookupRows=15360 和 spill write 尝试,但没有完成可校验的 spill/reload 结果。

    准确结论是“真实 SQL spill 场景环境阻断”,不是“spill 功能已被证明错误”,也不是“spill 验收通过”。 本轮没有调大 processLimitationSpillSize、删除旧数据或绕过保护来制造通过。

    此外,普通 SQL EXPLAIN ANALYZE 未公开 compact/dense state 的完整命中统计;上述失败诊断不能替代 Decimal dense batch 全路径证明。reset/rebuild、多 chunk 生命周期及原 issue 的固定版本性能、SF100/mixed-I/O 和资源矩阵仍未完成。

    QA 结论

    resident SQL 和 focused Go(含 Go spill)通过;真实 SQL spill/reload、完整生命周期及性能验收未闭环,本 issue 保持 OPEN。 后续应在具备真实可用 spill 配额的隔离环境中重跑,完成结果 oracle 与 reload 证据,不能用本次资源错误替代产品通过/失败判断。

  15. Ariznawlll commented on Nov 20, 2026

    @Ariznawlll
    Collaborator

    QA Re-verification 2026-11-20: blocked real-SQL spill now verified end to end — all assertions PASS

    Follow-up to the 2026-11-19 comment: the real-SQL spill scenario that was environment-blocked (resource exhausted: group spill disk budget exceeded (requested=462, used=0, limit=1) caused by a 100%-full local disk pinning automaticSpillDiskCap to 1 byte) has been re-run in a clean environment and now completes with full correctness and real spill evidence.

    Environment

    • Isolated single-CN cluster (LogService 33301 / TN 34300 / CN 17304), max_dop=1. No product source, config or resource-limit change; spill is forced purely via the documented session variable agg_spill_mem.
    • Binary: live git_version()=035af99680 (version()=8.0.30-MatrixOne-v1.3.0), the same accepted build as 2026-11-19; both deliveries perf(aggexec): fill Decimal64 combiner slots with word stores #31482 (8d63bb709665...) and perf(group): reuse compact group IDs and dense decimal states #32097 (781ebc03d905...) are ancestors (verified 2026-11-19).
    • Trigger modes (white-box from pkg/sql/colexec/group/types2.go setSpillMem / helper.go): agg_spill_mem<10000 is a group-count injection, >=10000 is a byte budget. Both are exercised.

    Results — fixture 60,000 rows / 1,300 distinct groups, all vs independent SQL oracles

    Scenario Rows Result
    single-char group SUM/AVG/COUNT (D64+D128) 130 match, sha256 673ac5...8507
    two-char tuple group 1300 match, sha256 87b9d3...4962
    nullable group, all-NULL groups keep SUM=NULL 131 match
    repeat on same connection (reset under spill) 130 identical sha256
    prepared full range / narrow range 130 / 2 match
    resident cross-check (agg_spill_mem=0) 130 identical to spilled

    Real spill evidence (EXPLAIN ANALYZE spill_rows SpillRows=1040 / SpillSize=211.89 KiB); byte-budget mode (agg_spill_mem=1MiB) spills 3120 rows / 996.09 KiB (pair: 10400 → 1.59 MiB and 31200 → 8.04 MiB). Result sha256 sums are identical between the two spill modes and the resident run. Three consecutive repeats stable. The ERROR lines in the run log are QA script authoring iterations (a CAST clamp and an oracle column typo), not product failures; the final script passes clean.

    Regression case delivered to motr (main-only)

    Conclusion

    The delivered #31482/#32097 grouped-aggregate work is correct under real forced spill in both trigger modes, with row-level identical answers across spill and resident paths — the last open correctness item for this subtask is closed. Remaining performance/lifecycle scope (multi-chunk reset/rebuild, SF100/mixed-I/O, resource matrix) stays with the still-open parent #30838. Closing this subtask as completed.

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

Metadata

Metadata

Assignees

Labels

kind/subtaskseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions