Repository navigation
fix: let source builds and Git updates finish on 8 GiB machines - #201901
fuller-stack-dev merged 10 commits into
Conversation
… heap is uncapped The parallel native declaration pass (openclaw#198661) holds Go memory outside --max-old-space-size. A cold build of main is OOM-killed in that pass in an 8 GiB container even with nothing else running; the single-threaded pass completes there. Parallel emit now needs the build owner's uncapped default heap, which it grants only when memory is ample.
Compare the capped single-threaded and uncapped parallel passes in one fixture, keep the compiles running on Windows, and document which hosts stay single-threaded.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThe PR makes native declaration emission single-threaded unless stable type ordering and the build process’s ample-memory heap budget both permit parallel emission. Example: A cold source build runs in an 8 GiB container with the normal 7424 MiB build heap.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — verified: source commit Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a concrete source-build failure with a focused change, and source review found no introduced correctness or security defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSource builds and Git-update candidate builds invoke tsdown, whose declaration plugin passes source roots and compiler options to the native emitter and receives declarations, source maps, and input inventories. flowchart TD
A[Source build or Git update] --> B[Build memory owner]
B --> C[Tsdown process with selected heap]
C --> D[Native declaration emitter]
D --> E[Single or parallel compiler pass]
E --> F[Declarations and input inventory]
Technical reviewBest possible solution: Keep declaration emission in its existing owner and admit parallel mode only when stable ordering and the existing ample-memory build budget both allow it. Do we have a high-confidence way to reproduce the issue? The source exposes the reported path: stable ordering enables native parallel compilation even when the build wrapper caps Node’s heap; the author reports two cold-build OOMs in 8 GiB, but this read-only review did not independently reproduce the memory failure. Is this the best way to solve the issue? The change is a small, coherent repair that consumes the existing build-memory decision, preserves the fast path on ample-memory hosts, and extends the existing real-compiler fixture without adding another scheduler or memory-discovery owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 44267df6c5ea. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +52, Other +20. Total +72 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 19, 2026, 10:25 AM ET / 15:25 UTC. |
…ot the total heap V8's heap_size_limit adds the young generation, so a planner-capped 12287 MB old space still read as uncapped. Read the --max-old-space-size the build owner wrote instead, and keep the test wrapper's paths out of shell source.
build-all hands every build child its frozen budget in OPENCLAW_TSDOWN_MAX_OLD_SPACE_MB. Reading Node heap flags could still admit the parallel pass when an inherited underscored alias survived the planner's rewrite.
…y child tsdown-build now exports OPENCLAW_TSDOWN_MAX_OLD_SPACE_MB itself, so direct tsdown-build runs carry the budget that build-all used to add, and the declaration emitter shares the owner's uncapped-heap threshold instead of copying it.
|
Merged via squash.
|
|
Headroom follow-up for this change: how much margin 8 GiB really has. These cells use the same Docker update matrix as the PR evidence. In each, installed 2026.11.5 does an in-place Git update to
What this says:
The guard itself is out of scope for this PR. It admits builds that are then killed between about 5 and 6.5 GiB, and it refuses or admits near 8 GiB depending on transient memory. That goes to a follow-up. Not attached: the cells' raw logs. The artifact store rejects uploads from the machine that ran them. Peak figures are exact MiB of cgroup |
…claw#201901) * fix(build): run the declaration pass single-threaded unless the build heap is uncapped The parallel native declaration pass (openclaw#198661) holds Go memory outside --max-old-space-size. A cold build of main is OOM-killed in that pass in an 8 GiB container even with nothing else running; the single-threaded pass completes there. Parallel emit now needs the build owner's uncapped default heap, which it grants only when memory is ample. * test(build): prove both declaration modes emit identical output Compare the capped single-threaded and uncapped parallel passes in one fixture, keep the compiles running on Windows, and document which hosts stay single-threaded. * fix(build): admit parallel declarations from the planned old space, not the total heap V8's heap_size_limit adds the young generation, so a planner-capped 12287 MB old space still read as uncapped. Read the --max-old-space-size the build owner wrote instead, and keep the test wrapper's paths out of shell source. * fix(build): take declaration threading from the planned heap budget build-all hands every build child its frozen budget in OPENCLAW_TSDOWN_MAX_OLD_SPACE_MB. Reading Node heap flags could still admit the parallel pass when an inherited underscored alias survived the planner's rewrite. * refactor(build): let tsdown-build hand its frozen heap budget to every child tsdown-build now exports OPENCLAW_TSDOWN_MAX_OLD_SPACE_MB itself, so direct tsdown-build runs carry the budget that build-all used to add, and the declaration emitter shares the owner's uncapped-heap threshold instead of copying it.
What Problem This Solves
A source build of current
maindoes not fit in 8 GiB of memory. In an 8 GiB container with nothing else running, a coldpnpm buildis OOM-killed in its declaration step, in 3 of 3 runs. That build runs during a Git install, a manualpnpm build, andopenclaw updateon a Git checkout when the installed updater is 2026.11.4 or 2026.11.5. The memory goes to the native TypeScript compiler, which #198661 made parallel. The build's memory guard cannot see that memory, because--max-old-space-sizedoes not bound a Go child process.User Impact
On a host where the build owner caps the build heap (below about 13 GiB of usable memory), the declaration step now runs single-threaded, and a cold build completes in an 8 GiB container. Hosts with more memory keep the parallel pass. Declaration output is the same in both modes.
The margin at 8 GiB is small. With a Gateway and a busy writer in the same 8 GiB container, the update passed, but the container peaked at 7848 MiB (7.66 GiB) of anonymous memory, 344 MiB under its limit, during the build. This PR does not claim that every 8 GiB host can build. When memory is too low, the existing guard refuses before touching anything, and the old build keeps serving; see the negative control below.
Why This Change Was Made
tsdown-buildsizes the build heap. It grants its uncapped default (12288 MB) only when memory is ample, and it uses the same fact to allow two parallel runtime builds.tsdown-buildnow hands its frozen budget to every build child inOPENCLAW_TSDOWN_MAX_OLD_SPACE_MB.build-allused to add it, and that duplicate is gone. A small shared module holds the threshold, so both use one rule. The emitter runs the compiler in parallel only when that budget is 12288 MB or more and stable type ordering is on. It never reads Node heap flags or V8's total heap limit.tsdown) also stays single-threaded, as before perf(build): emit tsdown declarations in one native compiler command-line pass #198661. An explicitOPENCLAW_TSDOWN_MAX_OLD_SPACE_MBof 12288 or more counts as a statement that memory is ample.Which side runs this code. The build runs the scripts of the tree being built, so the candidate's code decides, under any installed updater.
v2026.11.6,release/2026.11.10andmain. Since fix(update): Git updates overbuild and cannot repair interrupted conversion #189463 they setOPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1for update builds, in both the in-place and the release layout.pnpm build.release/2026.11.10reverts perf(build): emit tsdown declarations in one native compiler command-line pass #198661, andrelease/2026.11.6andv2026.11.5predate it.What this PR does not change: the build memory guard (
MEASURED_MIN_TSDOWN_HEAP_MB = 4352, from #123979). Measured on this base, its floor is too low, not too high:A per-process sample at the moment of the kill at 6 GiB:
build-allThe guard also counts pnpm's own memory as competing: at 5 GiB alone it computed a 4310 MB heap and refused. Raising the floor would refuse more hosts, and I have no data for hosts with fewer than 16 CPUs. So this is recorded as a follow-up, not changed here.
Evidence
Recordings (cold
pnpm build, containermemory.max8 GiB, no swap, 16 CPUs, nothing else running). Full raw logs are not attached because the artifact store rejected uploads from this machine.RED, base
eb381dceef2:write-unified-entry-dtsfails after 1m4.6s,oom_kill 1,memory.peak8192 MiB, 155 s.build-8gib-red.mp4
GREEN, final head
75ddce3266b: every phase done,write-unified-entry-dts1m46.3s,oom_kill 0,memory.peak6993 MiB, 273 s.build-8gib-green-75ddce3.mp4
GREEN, earlier head
5697d27a366(same reproduction):oom_kill 0,memory.peak7327 MiB, 254 s.build-8gib-green.mp4
Isolated build floor (cold
pnpm buildof the base, alone, 16 CPUs, no swap):Measured floor alone: between 6 and 7 GiB.
openclaw updatecells (Docker update matrix, managed Gateway serving, writer at 8 MiB/s on a 512 MiB agent database, Git tag on the beta channel):5697d275697d27mainea74900to5697d278040c3c5697d27readyztrueeb381dcNotes on the cells:
release/2026.11.10had 203 s and 179 s outages.preflight-no-good-commitwith the next actionopenclaw triage.Tests
test/scripts/native-declaration-boundary.test.ts: one test now compiles a 16-module fixture in fresh Node processes, setting the planner budget (OPENCLAW_TSDOWN_MAX_OLD_SPACE_MB) per case:--max_old_space_size=12288, and with no budget but--max-old-space-size=12288;test/scripts/tsdown-build.test.ts(adjacent owner guard): the tsdown child's env now carries the budget. It is4352for a capped plan,12288on an unconstrained host and8192for the Windows default. These assertions fail on the base.test/scripts/build-all.test.ts: unchanged; its existing child-env assertions still pass with the duplicate removed.node scripts/run-vitest.mjs test/scripts/tsdown-build.test.ts test/scripts/build-all.test.ts test/scripts/native-declaration-boundary.test.ts: 163 passed, 3 skipped.pnpm tsgo:scripts; the root tooling typecheck;pnpm lint:scripts; oxfmt;git diff --check; the baseline ratchets, all ok. The test-lines ratchet is +68.pnpm tsgo:test:rootfailed on 4 unrelatedrelease-*test files inherited from main at the time; that has not been rechecked on the current head.Audit and review
The touched test file was audited in full. The two-case determinism
it.eachwas replaced by the single test above. Its parallel case ran in-process under the test runtime (Bun), where the heap fact does not exist, so it could no longer select parallel mode.The new test keeps the compiles and equality checks on Windows and adds a cross-mode equality check. No other case changed.
An independent read-only review found nothing blocking. Its should-fix items:
autoreviewdoes not run on this machine.Second independent review (final design): nothing blocking. It asked that
tsdown-buildexport the budget itself and share the threshold; both are done. It also asked to note that Windows stays single-threaded and that the threading check does not run on Windows (the compiles and equality checks do).ClawSweeper round 1 (on
8040c3c): overall C, proof B, patch C. Its four findings, all fixed:$0;release/2026.11.6listed as running declarations: corrected;v2026.11.6skips them.ClawSweeper round 3 (on the final head
75ddce3): overall B, proof B, patch B, "patch is correct". Its one finding asked this description to name the planner budget as the threading input, and it now does.ClawSweeper round 2 (on
27dc770): overall D, proof D, patch C. Its finding was that an inherited--max_old_space_size=12288alias survives the planner's rewrite and admitted the parallel pass. Fixed by reading the planner's budget, with a test case. It also said the full-build proof predated the final logic; the final-head recording above answers that.Head. The update cells ran on
5697d27and8040c3c. The final head differs only in how the emitter learns the admitted budget. At the guard-computed budget in these cells (below 12288 MB) every version chooses the same single-threaded mode. Main merges since then touch no build code; the release-layout runner change (#201917) belongs to the installed updater, not the target build.Not proven
Steps left to a person: none for builds that fit. When memory truly is too low, the update ends with the old build serving and a recorded failure. The run record names
openclaw triageas the agent route. Adding memory cannot be automated.Correction: peak-memory figures in this description are exact MiB from cgroup
memory.stat(anon, whole container). An earlier version divided MiB by 1000 and labeled the result GiB.