Skip to content

perf: improve large-query planning and adaptive memory control - #29646

Merged
XuPeng-SH merged 12 commits into
matrixorigin:mainfrom
aptend:perf/tpcds-big-queries-integration-20260922
Oct 7, 2026
Merged

XuPeng-SH merged 12 commits into
matrixorigin:mainfrom
aptend:perf/tpcds-big-queries-integration-20260922

Conversation

@aptend

@aptend aptend commented Oct 6, 2026 •

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:

Related to #26768 and #25866. The umbrella optimizer roadmap remains open.

#26744 #26742

What this PR does / why we need it:

Measured 129 TPC-DS 1T progress: recorded query time falls from 4h55m02s to 1h44m03s (-64.7%), successful queries increase from 89/99 to 98/99, all five former 40 GiB budget failures complete, and four of the five former 1800-second timeouts complete. The earlier assembled successful 99-query reference totals 1h29m07s (-69.8%). These are historical workload measurements, not a fresh latest-head acceptance or an isolated code-only speedup.

Performance results

Reference: mo-auto-test run 34458444313. The integration column is the last complete 129 rerun at f731a6a002, before the included Q67 costing correction and final review fixes.

Metric Historical workflow Integration measurement
Successful queries 89/99 98/99
Hash-build budget failures 5 0
1800-second timeouts 5 1 (Q67)
Sum of query elapsed time, including failures/timeouts 17,702.204 s (4:55:02.204) 6,242.844 s (1:44:02.844), 64.7% less
Earlier successful assembled 99-query reference — 5,347.461 s (1:29:07.461), 69.8% less

The improvement is not just relaxing a cap: the recorded executions also remove substantial redundant/serial work.

Query Historical workflow Integration rerun
Q2 1800 s timeout PASS, 31.342 s
Q4 40 GiB budget failure PASS, 214.555 s
Q13 PASS, 1775.743 s PASS, 20.274 s
Q14 1800 s timeout PASS, 341.362 s
Q23 40 GiB budget failure PASS, 413.212 s
Q48 1800 s timeout PASS, 15.188 s
Q51 1800 s timeout PASS, 454.937 s
Q64 40 GiB budget failure PASS, 460.490 s
Q67 1800 s timeout 1800.702 s timeout; follow-up below
Q75 PASS, 402.762 s PASS, 297.004 s
Q78 40 GiB budget failure PASS, 226.037 s
Q95 PASS, 189.649 s PASS, 97.321 s
Q97 40 GiB budget failure PASS, 71.988 s

Q67 had previously completed on 129 in 596.599 s, but a main rebase exposed early grouping-set costing of unnormalized comma joins as Cartesian products. The included fix normalizes producer inputs before costing without changing the correct Cartesian cardinality formula. It restores the intended plan and passes locally in 556.967 s, with identical recorded output under the historical local 128 MiB spill profile. Its restored 129 runtime under automatic/default spill is still pending; the last measured 129 timeout above is not replaced with a local result.

Measurement conditions: 129 has 64 logical CPUs; integration measurements use the sorted 1T lab dataset, sequential execution, a 232 GiB service cap, GOGC=200, automatic merge off, and max_dop/agg_spill_mem/join_spill_mem/sort_spill_mem=0/0/0/0. The historical workflow differed in data layout/background merge and had statements surviving client timeouts. The 99-query successful reference assembles whitespace-corrected Q21/Q40 reruns; it is a SQL-time sum, not uninterrupted workflow wall time. These differences prevent attributing the entire percentage improvement to code alone.

Design amendment and review status

Documentation revision: 71b9f8b62c0f26616649fde1725688e8a6a9b8bc (docs only relative to the successful CI revision).

  • Adaptive execution policy — adaptive-execution-v1: default/explicit isolation trade-off, exact capacity versus physical rejection versus advisory shares, concurrent-query limitations, registration/retirement, recovery transfers, sampling locks, and drain-before-owner-retirement.
  • Analytic integration closures — integration-v1: direct-stream/split grouping guards, normalized costing, UNION/set/window closures, compatibility and rollback boundaries.
  • The formal review at the design revision accepts the core ownership/policy design and closes the missing-design-record finding. Global performance acceptance remains under review; green CI is not presented as that decision.
  • Completed bounded Linux sampling/concurrency control: six alternating 60-second windows at the reviewed head, real 100 ms provider versus one real sample cached for 1 h, with exact budgets kept enabled. Every result checked; no spill/OOM; terminal memory/disk/FD charges zero. Small-query p99 window medians 18.009 vs 17.261 ms (+0.748 ms), with mixed per-round directions; maximum observed sample 14.366 ms. A separate mutex profile records about 57.89 ms cumulative wait at the provider critical section over 60 s. These are mechanism-scoped observations, not zero-overhead proof or a complete declared-base/current-head resident/spill-policy A/B. Existing allocation and pressure controls are consolidated with their scope limits in that reply.
  • Completed current declared-base/head resource-policy controls, 281ca809d6 vs 15fa399ed9: six independent Linux service runs, identical finite limits/data/SQL, plus existing nine-sample allocation/HashBuild benchmarks. All results, complete spill queries, terminal-zero memory/disk/FD charges, and fresh-connection queries after a real bounded spill-disk rejection pass; no OOM. Observed costs are not hidden: accounted allocation +1.59%-3.53%; resident HashBuild +0.15%-0.52% with extra per-operator Go allocations; concurrent small-query throughput -4.56%, p99 13.256 → 13.395 ms. Small cache-friendly spill median 127.588 → 239.428 ms (+87.66%), while whole-fixture cgroup memory-peak median 1,770.2 → 1,238.4 MiB (-30.0%). Actual current-provider samples and read/write/cancelled-write counters are reported. This quantifies a memory-versus-I/O trade-off, not zero regression, automatic rollout approval, a full 1T acceptance, or reproduction of the old 129 physical cap=0 state. Raw fixtures/artifacts stay outside the PR.
  • TPCH 1T-only auto-test on shared 129, MO revision 71b9f8b6: FAILED. Q1-Q3 passed; Q4 rejected at join-spill/scatter-hash, and subsequent new connections failed in authentication's internal sort (cap=0). This predates the included clean-active-cache fix and is not current-head acceptance. The workflow did not report a new host or lane OOM. The failure and its source-qualified limits are confirmed in the latest review.
  • TKE TPCH 1T-only auto-test, MO revision 71b9f8b6: PASSED, all 22 queries result-checked in an initial round (926.620 s), then two timed rounds (915.020 / 927.303 s). The different deployment profile and absence of a matched base control limit the claim; this is not a current-head Linux pressure comparison.
  • Post-cache-fix manual 84 GiB TPCH 1T run on 129: Q1-Q18 passed result checks, including Q4 in 33.723 s. An external service stop interrupted Q19; Q19-Q22 have no completed acceptance result. Do not count this as a full 22-query pass or post-pressure connection-recovery proof.

General changes

  • Planning and shared work: isolate nested CTE hash-build requirements; share eligible grouping-set producers and split eligible direct ROLLUP levels; normalize join inputs before costing; remove redundant fixed-width UNION-chain deduplication. Preserve zero/dynamic LIMIT laziness, SINGLE join build/drain semantics, and filters above grouping expansion.
  • Pipeline throughput: retain UNION ALL consumer parallelism; avoid replicated broadcast distinct-set work; wake producers on receive; coalesce producer-local shuffle tails while respecting allocation provenance. Drain transferred batches before retiring their capacity owners.
  • Operator hot paths: reuse set-operation iterators and cumulative window prefix states; batch membership projection and nullable fixed-width vector copies; reuse spill decode/framing storage; avoid unnecessary scalar SUM/AVG scratch and ASCII substring rune conversion.
  • Memory and spill safety: replace the implicit 40 GiB cap at processLimitationSize=0 with the cgroup/host/mpool-derived CN ceiling, preserving explicit caps. Adapt automatic spill to live query/CN/physical headroom and active participants; separately reserve recovery capacity; bound sort recovery and local spill-disk/descriptor usage. Reclaim completed spill page-cache ranges and freed libc arena pages, and make ETL traversal/retry cancellation terminate.

The adaptive growth share is advisory: exact allocation-accounted admission remains authoritative. Pending allocations, replacement backing, and unused recovery reservations cannot create headroom during an OS sample refresh. Allocator capacity is not resident RSS; this is not an unconditional whole-process OOM guarantee.

Eligibility is based on SQL structure, types, semantics, and allocation ownership, not query IDs or benchmark-specific thresholds. No forced 128 MiB spill setting, DOP override, automatic-merge disablement, runner, benchmark fixture, or development diary enters this PR. The two existing owning design documents now include the reviewed-scope amendments below.

Completed validation and commit organization

  • Service build; full planner/compile/process/mpool and dispatch/hashbuild/message/function/group/order/shuffle consumer tests pass.

  • Process/compile race runs pass; allocation/backing/release race regressions also pass 100 repetitions each. Incremental static analysis reports zero issues.

  • Public SQL regressions pass twice on one isolated instance: ROLLUP 230/230, UNION/UNION ALL 206/206, with teardown verified.

  • Earlier rebase on main@c65991043b: TPCH 100G ordinary EXPLAIN was 22/22 identical to the immediate pre-rebase integration binary. TPC-DS key problem-query plans, including Q67, remained unchanged; other join-order/shuffle/runtime-filter choices varied between captures, including unchanged-binary controls. This historical comparison is not relabeled as a new latest-base plan comparison.

  • Prior TPCH 100G runtime comparison passes 22/22, with identical plans/results versus its immediate pre-fix integration control: 224.239 s vs 222.237 s (+0.90% in one loop). This is not a fresh latest-main runtime A/B.

  • Review regressions cover LIMIT/SINGLE drain contracts, pending/replacement backing, and grouping-expansion NULL/empty-input filters.

  • CI follow-up at 0a647334ea: fix custom SCA error-construction violations without losing typed pressure/error identity; retain the ROLLUP fixture's real two-reader materialized-fanout contract; preserve ordinary SQL expression error codes/messages; fix a bounded pipeline capacity wake-up deadlock exposed by the multi-CN shuffle BVT.

  • CI follow-up validation: service build and make err-check pass; full normal tests pass in 11 owning/consumer/planner packages and full race tests pass in seven owning/consumer packages. The deterministic capacity test fails before the fix (only 1 of 4 producers wakes), passes afterward, and passes 100 race repetitions. Public multi-CN range-shuffle joins pass on both coordinators with automatic and explicit spill, also under race; ROLLUP, vector-dimension error, and multi-CN regressions pass in coverage mode. Incremental SCA reports zero issues. Repository CI run 37427131266 subsequently completed successfully at 0a647334ea, including SCA, UT, coverage and pessimistic/proxy multi-CN BVT.

Current source: 15fa399ed9, rebased onto declared base 281ca809d6, with eight commits: the five implementation groups above plus Linux clean-active-cache headroom, removal of a flaky live-filesystem-capacity test, and test-call/formatter adaptation to updated main. Production/test files are no longer claimed identical to the older 0a647334ea revision. The original seven commits survived the latest rebase unchanged under range-diff; the eighth only adapts test arguments and formatting. Current repository CI run 37560919628 passed all required checks at this exact head, including Ubuntu UT, ARM64 SCA, coverage, proxy and pessimistic BVT; skipped jobs are not counted as passes. Revision-pinned evidence remains in the two existing owning designs; raw experiment artifacts and fixtures stay outside the PR. No latest-head complete 129 TPC-DS runtime is claimed.

@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 →

@mergify mergify Bot added kind/bug Something isn't working kind/enhancement labels Oct 6, 2026
@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Oct 6, 2026
@aptend
aptend force-pushed the perf/tpcds-big-queries-integration-20260922 branch from 7009f5d to 50a8e32 Compare October 6, 2026 05:08
@aptend
aptend force-pushed the perf/tpcds-big-queries-integration-20260922 branch from 50a8e32 to 0a64733 Compare October 6, 2026 07:01

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Supplemental behavior/ownership/complexity review of 15fa399ed9d18b7c1bd08458be5f466845aac317, against declared base / merge-base 281ca809d688f7ff727e813a48436aff1cfbea36.

Three verified P3 findings are attached: retire the now-unreachable persistent-FD writer path; avoid activating libc-trim bookkeeping/timers on an unsupported backend; destroy the new nullable-range test's MPool fixtures. These are bounded cleanup/efficiency/test-isolation findings, not three new production-correctness blockers. The existing P2 performance-validation item remains open; this COMMENT supplements the existing REQUEST_CHANGES review.

The necessary distinctions still hold: exact allocation ownership, sampled physical headroom and advisory growth limits answer different questions and have real consumers. Recovery-capacity ownership and drain-before-retirement cover actual borrower lifetimes. Removing these simply because they all mention memory would lose behavior. Conversely, the writer no longer assigns its persistent FD fields at all: retaining the old ownership protocol and test fixtures for it adds a second path without a production consumer. Preserve useful ownership/error assertions while moving their fixtures onto the actual protocol.

Focused reviewer-only Go-overlay probes at this exact head (native prerequisites rebuilt, Go 1.27.0 / Darwin arm64):

Probe Observed result
Real allocator activation and 1,024 actual 64 KiB allocate/free operations, using the production 64 MiB / 1 s settings Freed-byte counter reached 67,108,864, a timer was queued, and the unsupported trim backend produced one no-op callback. The assertion that an unsupported backend does no asynchronous work failed. The timer was drained using testing/synctest. This is not a measurement of Linux/TPCC regression.
Run the actual new TestUnionBatchFixedNullableRange, with public MPool-report counts before/after All six existing subtests passed, but retained must_new_zero registrations grew from 0 to 6; the fixture-retirement assertion failed.
MakeBucketWriters → two real writes → handoff → BucketReader.ResetForSpillFile → read/close; also remove the file before reopen Passed: concatenated payload read correctly, dormant writers held no FD, the active reader held one, and both success and reopen failure ended with zero disk/FD charges. This checks the real replacement path, not a mocked writer.

No tracked source edits or subagents. These probes close the stated supplemental questions; they do not replace the outstanding Linux base/head resident and complete spill-pressure controls, or certify all runtime paths.

Change accounting is unchanged: implementation +4,482 / -630 (net +3,852); tests and SQL expected results +4,206 / -287 (net +3,919); documentation +261 / -0. Useful test dimensions are retained in the recommendations; test bulk does not excuse incomplete fixture ownership, and line removal alone would not establish correctness.

Comment thread pkg/sql/colexec/spillutil/join_spill.go Resolved
Comment thread pkg/common/malloc/sane_allocator.go Resolved
@aptend

aptend commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Completed the remaining bounded Linux declared-base/current-head controls requested in the P2 review.

The comparison is now measured, not assumed. Functional cleanup/reconnection passes, but the small cache-friendly spill case has a real performance cost. This is not a zero-regression claim or an automatic rollout approval.

Identity and controls

  • Declared base / merge-base: 281ca809d688f7ff727e813a48436aff1cfbea36; current head: 15fa399ed9d18b7c1bd08458be5f466845aac317. The PR worktree stays clean; no production/test source changes, permanent fixtures, or benchmark records enter the PR.
  • Linux amd64, i7-11700, kernel 6.12.63+deb13-amd64, glibc 2.41, Go 1.27.0, GOEXPERIMENT=simd, GOAMD64=v3, CGO enabled. Both revisions use the same verified native generation; Makefile/cgo/thirdparties source inputs are byte-identical.
  • Three independent pairs of one-CN embedded services: order base/head, head/base, base/head. Each has its own data. Identical cgroup: CPUs 2-5, CPUQuota=400%, MemoryMax=8 GiB, MemoryHigh=7 GiB, no swap; GOMAXPROCS=4, GOMEMLIMIT=6 GiB; query cap=512 MiB, spill-disk cap=512 MiB, max_dop=4. No synthetic background load. The unrelated existing local service was left running throughout, so these are controlled host measurements, not hardware isolation or a statistical zero-overhead proof.
  • Dataset: 1,048,576 rows of BIGINT k/v plus a 96-byte payload; small control has 1,024 BIGINT rows. Resident SQL uses join_spill_mem=0. Spill SQL uses a fresh physical session and join_spill_mem=1048576, identical on both revisions, to prove actual spill with bounded data. This is not an automatic-threshold 1T acceptance claim.
  • Diagnostic overlays only export observational budget snapshots, atomically record spill payload/read bytes, and record real provider duration in a fixed atomic array. The current Linux provider, its production 100 ms TTL, physical guard, exact ledgers, and recovery policy stay enabled. No mocked headroom or borrowed capacity.

Resident SQL and current-provider refresh

Each pair has three warmups and a 20-second concurrent two-client window: the 1M-row INNER JOIN/aggregate plus the small GROUP BY. Every result is checked analytically; no spill, OOM, or remaining memory/disk/FD charge at window completion.

Pair Base big q/s Head big q/s Base small q/s Head small q/s Base small p99 ms Head small p99 ms Head real OS samples Sample p99 / max ms
1 11.822 11.786 949.4 899.9 13.229 13.368 196 0.454 / 0.627
2 12.154 11.878 936.1 893.4 13.256 13.395 195 0.962 / 5.604
3 11.633 11.660 927.7 860.3 13.297 13.792 197 0.810 / 1.207

Window medians: big throughput -0.31%; small throughput -4.56%; small p99 13.256 → 13.395 ms (+0.139 ms, +1.05%). Every current-head provider observation was measured. These measurements refresh the provider-dependent evidence after the clean-active-cache/host-bound change; the older live-versus-cached experiment remains valid only for its old-head sampling/mechanism question. No strict OS latency bound is claimed.

Allocation and complete non-spill HashBuild controls

Used the existing BenchmarkExecutionResourceBudgetAllocationAccount and BenchmarkHashBuildNonSpillE2E fixtures on both revisions, without new tracked tests. CPU2 pinned, GOMAXPROCS=1, 300 ms/sample, nine samples/case/revision across alternating runs. All selected benchmarks completed with PASS. Allocation cases add 0 B/op and 0 Go allocs/op on both revisions.

Allocation bytes Unaccounted base → head ns/op Change Accounted base → head ns/op Change
64 250.6 → 260.6 +3.99% 535.9 → 554.8 +3.53%
4,096 294.6 → 309.2 +4.96% 589.8 → 608.0 +3.09%
65,536 1,020 → 1,033 +1.27% 1,318 → 1,339 +1.59%
Complete resident HashBuild Base → head ms/op Change Base → head B/op Base → head allocs/op
INT64 1.784 → 1.791 +0.38% 20,289 → 21,860 86 → 93
INT64_PLUS_ZERO 2.224 → 2.229 +0.21% 20,960 → 21,447 90 → 92
VARCHAR_INLINE 5.739 → 5.761 +0.38% 27,907 → 33,552 86 → 112
VARCHAR_AREA_128 9.560 → 9.610 +0.52% 27,912 → 36,686 86 → 127
VARCHAR_32X128 6.001 → 6.010 +0.15% 33,893 → 39,634 56 → 83

The allocation microbenchmark exercises the common backing/controller hot path, not an installed live OS provider; the public resident SQL above covers that provider. The existing HashBuild benchmark times the operator body, not fixture preparation or final cleanup. Its oracles still verify the published non-spilled map, unique key/group counts, admitted capacity, and terminal-zero release. The extra per-operator Go allocations above are explicitly reported rather than hidden behind elapsed-time stability.

Complete bounded spill and failure recovery

Three complete, result-checked spill queries per service, nine per revision. Logical payload written/read is essentially equal. Every query ends with zero CN memory/spill-disk/FD charges and a successful new physical connection executing a checked small query.

Median/query Base Head
Elapsed 127.588 ms 239.428 ms (+87.66%, +111.840 ms)
Spill payload written 153.321 MiB 153.322 MiB
Spill file bytes read 153.321 MiB 153.322 MiB
Process rchar / wchar 159.209 / 153.570 MiB 159.112 / 153.331 MiB
Process read_bytes 5.262 MiB 147.473 MiB
Process write_bytes 153.973 MiB 169.457 MiB
Process cancelled_write_bytes 153.840 MiB 0 MiB

The larger reads and disappearance of cancelled dirty writes are consistent with the new writeback/cache-discard policy: this fixture fits in RAM and the base often reads cached spill data, then unlinks before dirty writes are completed. This is a source-consistent explanation, not an isolated same-head policy-off causal experiment. /proc/self/io includes storage/background work, and write_bytes is not completed hardware-write traffic; cancelled writes are shown separately. Thus this reports the spill-policy tax rather than mislabeling both sides' device traffic as equal.

The pressure fixture then loads 262,144 rows with an actually stored 3,072-byte payload and joins it to the big table. All six services reject through the real SQL 512 MiB spill-disk admission limit, not a mocked failure. Base reject durations: 0.327 / 0.322 / 0.326 s; head: 0.633 / 0.629 / 0.634 s. Each then:

  1. drains the failed query to memory=0, disk=0, FD=0;
  2. opens a fresh mysql client with no idle connection reuse;
  3. passes authentication and SELECT sum(k) FROM review_resource.small, expected 524800;
  4. returns again to terminal-zero resource charges.

This proves recovery after bounded disk-admission pressure. It does not recreate the historical 129 physical-headroom cap=0 condition, nor replace a full 84 GiB/1T workload acceptance. No such claim is made.

Whole-fixture cgroup memory peaks (including load, resident windows, successful spill, and rejected spill): base 1,748.6 / 1,770.2 / 1,780.9 MiB, head 1,238.4 / 1,242.8 / 1,226.7 MiB; medians 1,770.2 → 1,238.4 MiB (-30.0%). This is not a spill-only RSS measurement. Monitors recorded no cgroup OOM/kill; all six service processes and all benchmark processes exited successfully, with no surviving owned service. The original unrelated service remained running.

Reproduction and delivery limits

Public SQL/oracles, identical across revisions:

CREATE TABLE big(k BIGINT NOT NULL,v BIGINT NOT NULL,payload VARCHAR(96));
INSERT INTO big SELECT result,result,repeat('x',96)
  FROM generate_series(1,1048576) g;
CREATE TABLE small(k BIGINT NOT NULL);
INSERT INTO small SELECT result FROM generate_series(1,1024) g;
SELECT sum(a.v+b.v),sum(length(b.payload)) FROM big a JOIN big b ON a.k=b.k;
-- Expected: 1099512676352,100663296.
SELECT sum(c) FROM (SELECT mod(k,17) g,count(*) c FROM small GROUP BY mod(k,17)) x;
-- Expected: 1024.
CREATE TABLE wide(k BIGINT NOT NULL,v BIGINT NOT NULL,payload VARCHAR(3072));
INSERT INTO wide SELECT result,result,repeat('y',3072)
  FROM generate_series(1,262144) g;
SELECT sum(a.v+b.v),sum(length(b.payload)) FROM big a JOIN wide b ON a.k=b.k;
-- Expected: finite spill-disk admission rejection under the stated 512 MiB cap.

Local evidence: /d/mo-worktrees/tpcds-lab/results/pr29646-resource-ab-20261007.Vl05Fa/ contains source-qualified overlays, build.sh / run.sh, six raw result/latency/resource reports, memory monitoring, nine-sample benchmark logs, the complete summary and native/binary hashes. TestReviewMatchedResourcePolicy is the non-empty public test selection; run.sh carries the exact systemd profile. Probe source SHA256: c880e5362ae3fbec87a6aa85bb2bcbffa0bf7dea8219e1c05106807e1493299f; base/head public-test binaries: 85bc4a8addf07f3b916d2d7246051f36360263f693ce885d35e93806c9211155 / 8edc06f05bb73ebc625fb6900d6f81e5d155a201cc8639e7ef17a75c60d120c7.

One initial fixture-selection attempt is retained but excluded: changing the used session to an 8 MiB threshold produced no spill, so the positive-spill-byte assertion failed. Both revisions were rebuilt and all final pairs rerun with the same fresh-session 1 MiB fixture. This was not counted as spill acceptance or fixed by weakening an assertion.

The PR body is being corrected to reflect actual completed 129/TKE outcomes, eight current commits, the latest base/head and exact-head green required CI, without claiming identity to the older production tree. The three supplemental P3 cleanup suggestions remain separate from this measurement-only update. The missing base/head controls are now supplied; the measured memory-versus-I/O cost remains an explicit rollout trade-off for review, not a missing-data or zero-regression assertion.

@gouhongshen gouhongshen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codex automated review

Reviewed PR #29646 at head 15fa399 against origin/main (136 files, +8949/-917; production +4482/-630). I loaded all six submitted reviews, the six inline review threads, and the issue comments first, and I raise no finding that duplicates XuPeng-SH's still-open P2 evidence thread on docs/design/query_memory_control_and_attribution_impl.md:181 or the three P3 threads (spillutil/join_spill.go:482 dead persistent-FD writer protocol, common/malloc/sane_allocator.go:124 libc-trim activation on an unsupported backend, container/vector/unionbatch_fastpath_test.go:502 undestroyed MPool fixtures). The author's replies and posted base/head evidence were treated as claims and re-checked against code, not accepted as instructions.

I found no new blocking or non-blocking defect. Areas verified from code in this pass, beyond the allocation/recovery/spill core:

  • Planner grouping-set rewrite (pkg/sql/plan/grouping_set_input.go). The new direct-output and direct-split forms are gated fail-closed: directGroupingSetOutput requires an exact single UNION ALL root whose leaves are precisely the candidate branch nodes, identical rewritten projections (proto.Equal), and no limit/offset/order/filter/runtime-filter state; shareDirectGroupingSetSplit performs every validation (directGroupingSetSplitFits, SORT-ancestor walk, union projection shape) before its first appendNode, so a rejection leaves no orphan nodes. Skipping groupingSetSharingFitsCostAndStorage/reserveSharedMaterialization when directOutputOK is true is correct, not a bypassed gate: that path converts the UNION root into a PROJECT over sharedOutputID and never creates the SINK materialization those gates bound.
  • The residual-filter normalization loop (grouping_set_input.go:349-359) mutates branches[i].agg.Children[0] ahead of later fail-closed returns. I confirmed this is semantics-preserving: pushdownFilters re-attaches child-level unpushables to their own FILTER node, residual predicates are re-wrapped exactly as pushdown.go itself does, and the rewrite runs before createQuery, whose own pushdown pass performs the same transformation. The appendNode(..., nil) context matches the established idiom at pkg/sql/plan/pushdown.go:507, :547 and :568, so it is not a new inconsistency.
  • pkg/sql/plan/cte_reuse.go drain-witness loosening is sound in direction. path.inputDrained is only set after visiting a blocking AGG/SORT below the current node, and is conservatively cleared at multi-input non-JOIN boundaries, so a positive literal LIMIT above an already-proven blocking operator genuinely cannot stop the occurrence subtree from draining. Switching to the pre-existing joinInputContainsCTEHashBuildScan (pkg/sql/plan/stats.go:2881) scopes a build marker to its own nested join instead of creating a false conflict at an ancestor. Adding Node_SINGLE alongside Node_LEFT is consistent with SINGLE preserving its logical-left input.
  • pkg/sql/colexec/order. The borrowed ctr.pendingInput cannot be dropped or lost: sortAndSend never mutates ctr.state, the only Build->Eval transition is on a nil child batch, and pendingInput is consumed at the top of the next Call before the child is re-invoked. Reset/Free drop the reference without cleaning, which is correct because the child owns that batch and its own Reset/Free is the cleanup owner. Prepare's growth-participant and recovery-capacity registration roll back symmetrically on error.
  • pkg/sql/colexec/top. Setting ctr.spilling in Prepare when resident recovery capacity cannot be admitted reuses the pre-existing runtime migration already performed at top.go:553, and topRecoveryMinimum (128 KiB) is far below topResidentRecoveryTarget (32 MiB), so the min/max clamp cannot under-reserve the spill write buffer. Removing the blanket defer wrapper in Call does not lose attribution: TerminalBudgetErrorForOperator returns non-capacity errors unchanged (pkg/sql/colexec/hashbuild/errors.go:79), and all three of top's own fallible sites (build, eval, trimRecoveryCapacity) remain wrapped while child errors stay raw.
  • pkg/sql/colexec/window/window.go prefix-state reuse is doubly gated. processAggregateFuncRange only reaches it when aggexec.MergePreservesSource holds, an opt-in marker implemented solely by minMaxExecFixed, minMaxExecBytes, sumDecimal64/128FastExec and sumAvgExec/sumAvgDecExec; the added !resultType.IsVarlen() && !IsDistinct() guard then excludes minMaxExecBytes and DISTINCT variants. The ordered-set aggregates whose results are fixed-width but whose states are pointer/area-backed (median, percentile_cont/disc, approx_percentile) do not implement sourcePreservingMerge and so cannot take this path. Self-Merge across distinct group indices is safe for the remaining executors, which merge per-slot state with no shared scratch, and defer ctr.freeAggFun() makes the executor per-output-chunk, so group indices are always fresh.
  • pkg/sql/colexec/group. The move from CreateAndRemoveFile to CreateFile plus explicit RemoveFile in spillBucket.free is required by the reopenable-bucket design and is bounded: free() is invoked on every queued/active/repartition path, ctr.free() sweeps currentSpillBkt and spillBkts, and cmd/mo-service/main.go:342 clears the whole spill directory at startup, so a missed free cannot outlive the CN. openSpillBucket now records fileFS/fdToken/diskToken before constructing the writer and routes failure through bkt.free(), which is a strict improvement over the previous partial cleanup. finishWriting/openReader keep disk bytes owned while releasing only the descriptor.
  • pkg/common/mpool committed-capacity accounting is symmetric: addCommittedCapacity(sz) in allocAccounted pairs with releaseCommittedCapacity(sz) in allocationLease.release, and every lease.release call site (mpool.go:581, :1322, :1378) is guarded by isOffHeap && isAccounted, so no on-heap lease can underflow the counter. CapacityReservation.Commit(actualCapacity)/CapacityLease.Release use the same value. The published flag prevents double release between the rollback defer and the lease.
  • pkg/sql/colexec/mergeorder consistently uses bat.Allocated() at all four spillMemUsage mutation sites (batch_sort.go:379, order.go:314, order.go:673, spill.go:695), so the Size/Allocated mix that would drift the counter is gone. shouldSpill's error branch returns true (spill), the safe direction, and growthParticipant release is idempotent across spillCachedRuns, Call EOF, Reset and Free.
  • pkg/sql/compile. compileParallelUnionAllInput is only entered by two explicit consumers, falls back to compilePlanScope for TP queries, releases the left scopes if the right branch fails, and calls ensureCoordinatorOnlyFunctions idempotently (a second call is a no-op once scopesRunOnCoordinator holds). canPreserveParallelUnionAllBranches excludes limit/offset/order/filter/barrier/lock-function nodes. The new dupOperatorWithContext vm.UnionAll case is a fix rather than a risk: before this PR any UnionAll duplication hit the trailing panic at pkg/sql/compile/operator.go:766, and the sequential-scheduler panic only names a case that previously panicked with a less specific message. compileMinusAndIntersect's broadcastDistinct routing is nil-safe through gogo getters and correct: a non-shuffle (broadcast) DISTINCT set op gives every worker the full input, so one owner is required, while the shuffle case keeps the parallel path.
  • Set-op iterator reuse (intersect, intersectall, minus) is safe: StrHashMap.NewIterator returns only &strHashmapIterator{mp: m} with no cached bucket count or mask, scratch is allocated lazily per call, and cleanHashMap clears the owner via hashmap.IteratorClearOwner before freeing the table.
  • The removal of the implicit 40 GiB defaultProcessLimitationSize is a deliberate, documented default-policy change covered by the design thread and its updated design doc; I do not re-raise it.

Not duplicated, for the controller's awareness only: XuPeng-SH's P2 admission/spill performance-validation thread remains open with the author's newest base/head resident and spill A/B evidence posted for re-review, and the three P3 cleanup threads are unanswered at this head. Those are existing review states, not findings from this review.

@aptend

aptend commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Current-head TPC-DS 1T full-suite evidence on host 129 — 2026-10-07

99/99 queries completed successfully in one uninterrupted run; 0 timeouts, 0 query failures, and 0 recorded OOM kills. Both summed query time and end-to-end query-suite wall time are below 90 minutes.

This is a fresh on-129 build and run of current PR head 15fa399ed9d18b7c1bd08458be5f466845aac317 (declared base 281ca809d688f7ff727e813a48436aff1cfbea36).

Measure Result
Queries completed 99/99
Ordinary EXPLAIN / query exit codes All 0
Sum of per-query elapsed times 5,124.093 s — 1:25:24.093
Suite wall time, excluding build/startup/shutdown 5,161.512 s — 1:26:01.512
Longest query Q67: 605.257 s
Timeouts / query failures / recorded OOM kills 0 / 0 / 0
Nonzero cgroup memory fail-counter samples 0 out of 99
Peak sampled anonymous RSS, MO cgroup 96.699 GiB
Minimum sampled host MemAvailable 136.128 GiB
Suite / driver / MO shutdown exit status All 0

Test profile: 2 × Xeon Silver 4314, 64 logical CPUs, approximately 251 GiB RAM; full-host single-process launch with CN/TN/log services, not the newer 84 GiB half-host workflow. MO service cgroup limit 232 GiB, no swap, GOGC=200, sequential Q1–Q99, 1,800 s per-query guard. Existing 1T data and prior launch configuration were reused; no LOAD, ANALYZE, or cache dropping. Session defaults were max_dop=agg_spill_mem=join_spill_mem=sort_spill_mem=0: no forced 128 MiB spill setting or DOP cap.

Compiled on 129 with Go 1.27.0, GCC 11.2.1, CGO enabled, GOAMD64=v3 and GOEXPERIMENT=simd. Tracked PR sources were unchanged. The only lab code overlay initializes the merge scheduler with allPaused=true, preventing automatic merge before SQL readiness; runtime merge-off was verified for every query. Q21/Q40 CAST ( and Q48 sum ( received only the previously recorded whitespace normalization in copied SQL.

Previously problematic or expensive queries all completed:

Query Elapsed (s) Peak sampled anonymous RSS (GiB)
Q2 31.341 5.827
Q4 206.478 84.098
Q14 457.962 14.102
Q23 417.395 76.364
Q48 14.187 12.253
Q51 427.638 24.765
Q64 477.931 82.810
Q67 605.257 73.301
Q75 292.043 26.837
Q78 224.176 96.699
Q95 95.308 45.427
Q97 73.045 51.500

Run window: 2026-10-07 16:08:52.040–17:34:53.552, UTC+08:00. The owned MO and observer stopped successfully, the host reservation was released, and the dataset was retained.

Raw SQL, ordinary EXPLAINs, outputs/output hashes, per-query timing/resource samples, build identity/library hashes and terminal/cleanup records are retained outside this PR:

  • 129: /data3/codex-tpcds-sorted-1t-lab/pr29646-full99-20261007-15fa399e-mlZKFF/
  • 52: /d/mo-worktrees/tpcds-lab/results/pr29646-tpcds1t-129-20261007.mlZKFF/
  • Executed binary SHA-256: cd170fda6f5a0cf602c4518b894ee3f7eb199d50a82fe16c4e21a9a860b03415

This adds current-head full-scale execution, performance and memory-budget evidence. “PASS” here means successful SQL execution with retained outputs, not an independent TPC result-oracle check; this candidate-only run does not by itself establish a matched base/head speedup or TPC-H non-regression.

Complete per-query timings (all 99 succeeded)
Query Elapsed (s)
Q1 12.202
Q2 31.341
Q3 8.103
Q4 206.478
Q5 18.230
Q6 6.072
Q7 13.161
Q8 5.066
Q9 23.301
Q10 10.119
Q11 127.536
Q12 4.065
Q13 20.263
Q14 457.962
Q15 4.052
Q16 8.108
Q17 17.242
Q18 28.470
Q19 7.102
Q20 4.061
Q21 2.028
Q22 54.865
Q23 417.395
Q24 41.596
Q25 15.180
Q26 6.087
Q27 12.168
Q28 42.521
Q29 21.320
Q30 6.089
Q31 28.351
Q32 6.093
Q33 12.161
Q34 8.109
Q35 64.130
Q36 11.154
Q37 2.031
Q38 133.171
Q39 13.169
Q40 5.070
Q41 62.945
Q42 5.063
Q43 9.105
Q44 8.110
Q45 4.051
Q46 12.157
Q47 60.806
Q48 14.187
Q49 19.247
Q50 28.441
Q51 427.638
Q52 5.071
Q53 6.082
Q54 15.177
Q55 5.061
Q56 10.132
Q57 44.677
Q58 9.125
Q59 116.382
Q60 13.191
Q61 13.189
Q62 7.093
Q63 6.080
Q64 477.931
Q65 33.430
Q66 10.139
Q67 605.257
Q68 14.179
Q69 10.122
Q70 23.275
Q71 10.122
Q72 36.593
Q73 7.097
Q74 76.916
Q75 292.043
Q76 1.021
Q77 15.220
Q78 224.176
Q79 15.206
Q80 21.293
Q81 7.106
Q82 3.041
Q83 3.053
Q84 1.021
Q85 7.105
Q86 4.057
Q87 150.536
Q88 29.363
Q89 7.090
Q90 3.046
Q91 1.019
Q92 3.041
Q93 13.201
Q94 5.075
Q95 95.308
Q96 5.072
Q97 73.045
Q98 7.094
Q99 13.168

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed 15fa399ed9d18b7c1bd08458be5f466845aac317 against merge-base 281ca809d688f7ff727e813a48436aff1cfbea36. Request changes: one newly reproduced P2, in the inline comment. No subagents or tracked source changes.

New blocker: a platform measurement error becomes false allocation rejection

The new production headroom gate trusts system.MemoryAvailableIncludingCache. The pinned gosigar Darwin implementation converts Mach page counts with << 12, although this Darwin/arm64 host uses 16,384-byte pages. Thus its free+inactive measurement is four times too small. Subtracting the new physical safety reserve can then leave zero effective headroom even for a 24-byte Group allocation. The dependency's conversion predates this PR; making it an unconditional hard admission input is the new behavior.

I reproduced this through the actual Group path and a small public-budget probe, not just a mocked provider. On this 16 GiB host, with an explicit 512 MiB query limit and no actual 512 MiB allocation:

Production admission probe Provider bytes Same counters with correct page conversion 512 MiB reservation
Original head 1,287,544,832 5,150,179,328 Rejected; effective cap 213,803,008
Same head, temporary page-conversion-only overlay 3,798,597,632 3,798,597,632 Passed; reservation released
Original head again 718,946,304 2,875,785,216 Rejected; effective cap 0

These are separate live samples, not a claim of identical host load. The conversion defect is exact; notably the corrected run passed with less correctly measured headroom than the first failing run. The overlay was diagnostic only.

Minimal probe body (testutil process, ordinary production generation):

proc := testutil.NewProcess(t)
defer proc.Free()
proc.Base.Lim.Size = 512 << 20
generation, err := proc.GetExecutionResourceBudget()
if err != nil { t.Fatal(err) }
reservation, err := generation.ReserveTransientMemory(512 << 20)
if reservation != nil { reservation.Release() }
if err != nil { t.Fatal(err) }

Design and existing comments

The documented ownership design remains coherent: AllocationAccount / ExecutionResourceBudget own exact admission and release; participant retention reports are advisory; recovery capacity reuses the existing generation owner; producer quiescence and borrower drain precede owner retirement. I did not find another demonstrated SQL-result defect in the grouping-set/CTE/UNION changes or inspected operator fast paths. This does not assert that every possible SQL or platform path was executed.

The previous performance-evidence request is now addressed by the declared-base/current-head comparisons. I am not retaining “comparison missing” as a blocker:

  • Reported resident allocation overhead is 1.6–3.5%, resident HashBuild about 0.2–0.5%; small concurrent throughput declines 4.6%, with small-query p99 13.256 → 13.395 ms.
  • The cache-friendly forced-spill case takes 127.588 → 239.428 ms (+87.7%). Whole-fixture cgroup peak falls 1770.2 → 1238.4 MiB (about 30%); this is not a spill-only memory measurement. Spill payload is essentially unchanged, while actual read/write counters support a cache-retention/I/O trade-off. These results demonstrate a material cost for this workload, not universal performance improvement.
  • The candidate 1 TiB run reports 99/99 successful executions. It is neither a matched speedup comparison nor an independent result oracle. I did not rerun that remote workload.

The three existing P3 findings remain unfixed at this unchanged head: retired persistent-FD writer protocol, trim scheduling with an unsupported backend, and unretired MPool fixtures. No duplicate findings are filed.

Local validation and test quality

With native artifacts for this checkout, Go 1.27.0 / Darwin arm64:

  • Focused process ownership/recovery/notification tests passed under -race -count=20.
  • Selected Order, Top, Shuffle and SpillUtil tests passed.
  • Exact-head Group tests failed: TestGroupAdaptiveSpillProjectsRecoveryGrowth spilled before its asserted boundary; TestAccountedGroupQueuedSpillDoesNotRetainFDs returned requested=24, used=0, limit=0 instead of reaching its cancellation path. Both passed with only the diagnostic page-conversion overlay.
  • Latest required CI, SCA, Linux UT/BVT and Connector/J checks pass. Darwin UT is skipped; Linux green does not exercise this 16 KiB-page defect.

The regression should repair the owning platform measurement contract, without bypassing the hard ledger or treating measured zero as unavailable. Test 4 KiB/16 KiB conversion and the measured-low/zero behavior. Operator boundary tests also need controlled budget/headroom inputs: they currently assume a static query cap while consuming live host pressure, so a failure can prevent their intended unhappy path from being reached. Retain a separate real-provider integration check; do not merely weaken their assertions.

Change accounting: implementation 79 files +4,482/-630 (net +3,852); tests/SQL results 55 files +4,206/-287 (net +3,919); documentation 2 files +261/-0. The additional test volume includes useful result, cancellation, accounting and reuse dimensions, but does not excuse the remaining fixture lifecycle defect or missing platform-unit boundary. The systemic miss here is promoting an existing measurement helper to an allocation authority without validating the stronger units/platform contract.

aptend added 11 commits October 7, 2026 19:30
Reuse set-operation hash iterators, isolate nested CTE build requirements,
stream equivalent grouping-set outputs, wake pipeline producers on receive,
and retain UNION ALL consumer parallelism.
Keep explicit query caps while deriving the automatic ceiling from CN
capacity; reclaim libc arena pages, account for live headroom and recovery,
and bound sort recovery and local spill-disk capacity. Preserve CTE drain
proof through blockers, bound residual inequality builds, split eligible
direct ROLLUP levels, and coalesce shuffle tails by allocation provenance.
Project streaming hash-build memory incrementally and retain exact recovery
capacity and refusal diagnostics. Release queued spill descriptors, cancel
ETL traversal/retry waits, avoid replicated broadcast distinct-set work,
resume equal-group searches at the current batch, and fast-path ASCII substring.
Avoid scalar SUM/AVG batch scratch; propagate uniform metadata once;
reuse cumulative window prefixes and admitted spill-decode/framing storage;
batch membership projection and nullable fixed-width copies. Eliminate
redundant fixed-width UNION dedup, preserve TP UNION ALL input, and drain
transferred batches before retiring capacity owners.
Normalize grouping-set inputs before costing; preserve zero/dynamic LIMIT
and SINGLE join drain/build semantics; keep output predicates above grouping
expansion, including VALUE_SCAN. Retain pending and replacement backing
across headroom refresh, consolidate orthogonal ownership tests, and adapt
test fixtures to explicit process ownership. Keep lab documentation outside
the delivery history.
Separate Statfs samples can differ because unrelated filesystem writes change free space. Exact equality between those samples is not a valid test oracle.

Keep the deterministic automatic spill quota boundary and live envelope tests, together with CN aggregate initialization and reuse coverage. Production behavior is unchanged. The process package passes with coverage enabled.
@aptend

aptend commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

SCA fix and rebase pushed: current head 92f663638994033f1ad48c2bc25b023695cf5e33, base 15cc6232efd2d1b048e9474f7d4aa692539fc1cc.

The failed SCA job stopped in Makefile err-check, before the analyzers: the two new host-memory files used fmt.Errorf. Both now use the repository's moerr constructors. The previous incremental golangci run did not cover this separate policy gate.

Validation after rebase, Linux/amd64, Go 1.27.0, CGO=1 and verified native artifacts:

  • Full make static-check-analysis passes, including err-check, pinned molint and whole-repository golangci-lint (0 issues).
  • All nine affected packages pass normal and race tests.
  • The newly pinned Dragonboat constructor-unwind regression passes all four cases; dependency license check also passes.
  • Rebase completed without conflicts; range-diff preserves all eleven patches. Planner and compile directory tree hashes are identical to the previous head.

No memory-headroom policy, page conversion, spill ownership or SQL plan logic changed in this follow-up. Prior performance runs are not presented as new-head reruns. The previously disclosed native Darwin build/execution gap remains; the Linux checks do not substitute for a native Mac check.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review of 92f663638994033f1ad48c2bc25b023695cf5e33, against declared base / merge-base 15cc6232efd2d1b048e9474f7d4aa692539fc1cc. APPROVE: the previously reported blockers and cleanup findings are addressed; no new blocking finding from this review. No subagents, production edits, rebase or push.

Design, scope and evidence continuity

The accepted design decision remains valid. Exact allocation admission/release stays with AllocationAccount / ExecutionResourceBudget; physical sampling adds a pressure restriction, not a second allocation ledger; growth participants supply advisory retention targets. Recovery capacity transfers within the same generation, and transport borrowers are drained before allocation owners retire. These distinctions have real consumers and justify the extra state; collapsing them into a single estimate would lose the ownership/progress contract.

The change map covers planning/shared computation, compiler topology, vector/aggregate/window fast paths, admission/recovery, shuffle/transport, spill ownership/cache, platform observation, and cancellation. Adjacent controls include lazy/conditionally skipped consumers versus guaranteed-drain consumers; explicit versus automatic limits; pending backing versus committed-and-retired backing; ordinary versus recovery allocations; dormant writer versus active reader; and platform-unavailable versus measured-zero memory. UNION multiplicity, grouping NULL provenance, prepared/string metadata, cancellation and same-instance reuse remain distinct oracles, rather than substitutes for each other. Persisted table/catalog formats are not changed; spill files are temporary and the existing service-start spill cleanup remains the crash-recovery owner. This is not a mixed-version rollout certification.

git range-diff shows the original eight patches unchanged through the rebase, followed by the three focused review/SCA fixes. The base advance is #29649; the plan/compile trees are identical to the previously reviewed 15fa399e. I reused qualifying prior implementation/SQL/performance evidence for unchanged paths and checked the new platform, fixture and ownership changes directly. The fixed-ledger test seam is instance-local and setup-only; it does not disable the production provider or mutate the shared CN budget.

Historical comments: closure

Review item Current closure
Performance controls The bounded declared-base/head comparison supplies resident admission, HashBuild, concurrent-query, spill I/O and post-failure recovery evidence. “Comparison missing” is no longer a blocker; costs are qualified below.
Darwin 4 KiB conversion used on 16 KiB pages Owning provider uses Mach counters and vm_kernel_page_size, releasing the host port after the observation. Native Darwin arm64 tests and the real production-admission probe pass. Measured zero remains a rejection; unavailable observation retains the finite-ledger fallback.
Retired persistent-FD writer path Removed writer FD/token fields, anonymous constructor and descriptor getter. Reopenable fixtures retain the transfer, rejection, corruption and exactly-once assertions. Actual two-write/readback and failure controls pass. Active-reader FD ownership is retained.
Unsupported libc trim work Capability is checked before enabling bookkeeping/timers. Native unsupported-backend real allocate/free probe passes; a supported trim returning false still remains enabled, as it should.
Nullable-range MPool fixture leak Cleanup now defers DeleteMPool before its zero-usage assertion, including assertion failure. All six nullable-range cases pass under race.

Independent native QA in this review

Go 1.27.0, Darwin arm64, 16,384-byte pages, 16 GiB host RAM. Matching native prerequisites were rebuilt in the isolated checkout. Initial attempts did not execute successfully because of inherited linker settings / missing native prerequisites; they are not counted as passes.

  • System provider/conversion/cgroup-parser cases passed under -race -count=1 (1.297 s): 4 KiB/16 KiB units, zero/invalid/overflow counts, real host snapshot, measured status, v1/v2 reclaimable-cache and hierarchy boundaries.
  • Six additional targeted packages passed under -race -count=1: malloc 4.469 s, Group 4.156 s, process 3.352 s, SpillUtil 2.952 s, message 1.505 s, vector 1.885 s. These are package-reported times, not a whole-suite performance measurement.
  • A reviewer-only public-production-budget probe used a fresh testutil Process and explicit 512 MiB query cap. The real provider reported 3,352,002,560 bytes available; reserving 536,870,912 bytes succeeded and releasing it returned generation usage to zero. No provider overlay or admission bypass was used. This is an admission test, not allocating/touching 512 MiB or proving host-OOM immunity.
  • Both formerly host-pressure-sensitive Group cases now reach their intended boundary: adaptive recovery projection and queued spill cancellation. Their accounting assertions pass. Separate measured-headroom tests reject zero, below/at safety and one-byte-short capacity, admit the exact boundary, and check the unavailable-provider fallback.
  • Independent real named-file probes covered handoff FD exhaustion then retry, reader FD exhaustion, file removed before reader open, and canceled reader open. Failed handoff retained writer ownership for retry; reader failures retired the payload; terminal memory/disk/FD usage was zero. The retained positive control appends twice and reads back the concatenated payload.
  • On Darwin, 1,024 real 64 KiB allocation/free operations with the production 64 MiB trim threshold did not accumulate trim bytes or queue a trim callback. A synctest timer drain also passed. The separate supported-backend/no-op control passed.

Reviewer probes changed only temporary test files, now archived outside the checkout. The tracked worktree remains unchanged. Current-head CI run 37616157272 is completed/success, including required checks, Ubuntu UT, ARM SCA, coverage and proxy/pessimistic BVT. Darwin CI is skipped, so the native evidence above matters. No CI waiting or broad redundant rerun was used.

Performance decision and limits

I accept the measured bounded-memory / spill-I/O trade-off for this design, not a universal speedup claim. The author's comparison at 281ca809 -> 15fa399e reports resident allocation +1.6–3.5%, resident HashBuild about +0.2–0.5%, small concurrent throughput -4.6%, and small-query p99 13.256 -> 13.395 ms. The cache-friendly forced-spill case is materially slower: 127.588 -> 239.428 ms (+87.7%), while the whole fixture's median cgroup peak falls 1770.2 -> 1238.4 MiB (~30%). That peak is not a spill-only measurement or isolated proof that cache dropping caused the entire reduction. Logical spill payload stays essentially unchanged; the I/O counters show the cost of writeback/cache eviction. The live-provider experiment also shows nonzero sampling tails while admission/release share the budget mutex; TTL is not a latency bound.

The 1 TiB TPC-DS run is useful completed execution evidence (99/99, ~86-minute wall time), not a matched performance comparison or independent SQL-result oracle. I did not rerun those remote benchmarks. Their original revision/environment qualifications remain in force; the later ownership cleanup and Darwin correction do not turn them into new exact-head measurements. Explicit caps remain the operational isolation tool; this design does not guarantee priority fairness, a minimum admission slice for every arriving query, or whole-process OOM prevention.

Engineering and test quality

Against the current base: implementation 82 files +4,605/-671 (net +3,934); tests/results 60 files +4,437/-336 (net +4,101); docs 2 files +261/-0. The production increase is substantial and was assessed independently of test volume. The new policy reuses existing accounting/recovery/spill owners, and the obsolete writer protocol has actually been removed. The tests now separate physical-provider measurement, deterministic admission boundaries, operator behavior and terminal ownership; no assertion was weakened merely to make CI pass. No additional blocking complexity, data-compatibility, result-correctness or lifecycle issue was established by the completed review. This approval does not claim exhaustive execution of every platform, SQL or pressure combination.

@mergify

mergify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-07 13:21 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-07 13:33 UTC · at 70be641eda6608bbffa388e4320f811618dcc8a6

This pull request spent 12 minutes 14 seconds in the queue, with no time running CI.

Reason

Pull request #29646 has been merged manually at 4e58756

Hint

You were too fast!

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
ci — 70be641e Deployed Oct 7, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/documentation Improvements or additions to documentation kind/enhancement size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants