Repository navigation
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
7009f5d to
50a8e32
Compare
50a8e32 to
0a64733
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
|
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
Resident SQL and current-provider refreshEach 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.
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 controlsUsed the existing
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 recoveryThree 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.
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. 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:
This proves recovery after bounded disk-admission pressure. It does not recreate the historical 129 physical-headroom 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 limitsPublic 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: 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
left a comment
There was a problem hiding this comment.
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.
Current-head TPC-DS 1T full-suite evidence on host 129 — 2026-10-0799/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
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, Compiled on 129 with Go 1.27.0, GCC 11.2.1, CGO enabled, Previously problematic or expensive queries all completed:
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:
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)
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
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:
TestGroupAdaptiveSpillProjectsRecoveryGrowthspilled before its asserted boundary;TestAccountedGroupQueuedSpillDoesNotRetainFDsreturnedrequested=24, used=0, limit=0instead 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.
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.
|
SCA fix and rebase pushed: current head The failed SCA job stopped in Makefile Validation after rebase, Linux/amd64, Go 1.27.0, CGO=1 and verified native artifacts:
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
left a comment
There was a problem hiding this comment.
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.
Merge Queue Status
This pull request spent 12 minutes 14 seconds in the queue, with no time running CI. ReasonPull request #29646 has been merged manually at 4e58756 HintYou were too fast! Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
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.The improvement is not just relaxing a cap: the recorded executions also remove substantial redundant/serial work.
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).281ca809d6vs15fa399ed9: 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 physicalcap=0state. Raw fixtures/artifacts stay outside the PR.71b9f8b6: FAILED. Q1-Q3 passed; Q4 rejected atjoin-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.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.General changes
processLimitationSize=0with 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-checkpass; 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 at0a647334ea, including SCA, UT, coverage and pessimistic/proxy multi-CN BVT.Current source:
15fa399ed9, rebased onto declared base281ca809d6, 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 older0a647334earevision. 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.