Skip to content

fix: cold source builds exceed memory budget during declaration emit - #157992

Open
Olli0103 wants to merge 4 commits into
openclaw:mainfrom
Olli0103:fix/native-dts-memory-157783
Open

Olli0103 wants to merge 4 commits into
openclaw:mainfrom
Olli0103:fix/native-dts-memory-157783

Conversation

@Olli0103

@Olli0103 Olli0103 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cold source builds can exhaust memory during native TypeScript 7 declaration emission. Node's heap setting does not bound the Go compiler child. A per-child Go target must also account for declaration groups admitted concurrently.

User Impact

Source builders get an availability-sensitive soft Go memory target for declarations. Explicit caller GOMEMLIMIT remains authoritative. There is no runtime or configuration migration.

Implementation

Rebased onto c3b2b7d3fc1a053d2f6907e55e1629c16fc53706; current candidate is 078fe921e196b2255dfc228d4834fce5f5e58a97.

  • Keep main's async TS7 API, filesystem boundary, publication and compiler cleanup unchanged. The API has no environment option, so the tsdown worker receives the environment inherited by its native API child.
  • Resolve 60% of effective available capacity once, including host availability and cgroup constraints. The staged writer divides that Go-managed share between its selected one or two workers; direct CLI builds account for explicit --concurrency.
  • Preserve caller overrides. Runtime-only and declaration-disabled builds receive no automatic Go limit. Watch mode receives no automatic limit because tsdown ignores its concurrency setting there.
  • Include the policy module in declaration cache inputs.

GOMEMLIMIT is soft and excludes non-Go memory; the remaining 40% is a sizing allowance, not a guaranteed RSS reserve. This is a declaration-memory fix, not a claim that a full cold build fits 10 GiB. Runtime-bundling concurrency remains separate in #157739, as obviyus's review identified.

Evidence

  • Memory regressions: 5/5 passed, 2.31 s real wall time including runner startup.
  • Build-wrapper regressions: 88/88 passed, 4.61 s real wall time including runner startup.
  • Related compiler boundary, subprocess, declaration-resolution and native-TypeScript suites: 41 passed, 6 platform-specific skips. The async emitter itself is unchanged.
  • Canonical changed-file checks passed: script and root-test typechecks, formatting, scoped lint, declaration/dependency guards and dead-export scans. Final script and root-script typechecks and scoped lint also passed after the last concurrency adjustment. git diff --check passed.
  • Fresh independent source review of the complete candidate diff against the pinned base found no remaining P2-or-higher issues. The canonical autoreview helper was attempted but returned reviewer_unavailable after authentication failed; it did not produce a passing review.

Current-head real behavior proof

Candidate 078fe921e196b2255dfc228d4834fce5f5e58a97, Linux x64, Node 24.21.0, pnpm 12.5.1, TypeScript 7.1.0-dev.20260920.1. Each cell used a disposable no-swap cgroup. The detector matched the exact installed compiler path and SHA-256, not a basename assumption. This package's executable is named tsc; the actual declaration children used --api --async.

Full proof run 37273712838, harness 1775a5b280cc88848d70593de3a2d977aededf95:

Cell Result Command wall time Cgroup peak Observed async compiler target
Full cold pnpm build, 13 GiB Passed 825.829 s 9.624 GiB 24 serial children, 7669–7842 MiB
Full cold pnpm build, caller GOMEMLIMIT=6GiB, 13 GiB Passed 835.984 s 9.112 GiB All 24 children preserved 6GiB
Two nonempty canonical extension partitions, 13.75 GiB Passed 173.423 s 10.936 GiB Two overlapping async children, both 3993MiB

The parallel cell used the same staged declaration writer and explicitly reduced Node heaps to 5120 MiB, admitting two nonempty canonical extension partitions. It observed both compiler children from 5.416 s until approximately 159 s. It is not proof of default-heap parallel admission on a larger host.

All three cells recorded zero OOM/OOM-kill deltas, zero container swap use, no timeouts and no lingering sampled workers. Compiler RSS is distinct from the soft Go target; the parallel aggregate sampled compiler RSS peaked at approximately 9.324 GiB.

Complete output comparison covered 24,654 entries across 19 roots, including 647 declaration files. File inventories and hashes matched except the two timestamp-bearing build-stamp files. Only dist/.buildstamp's builtAt and dist/.runtime-postbuildstamp's syncedAt were normalized; all raw hashes and both named differences are retained in comparison.json. There were no unexplained differences. This is not a claim of raw byte-for-byte identity of timestamps.

Focused run 37271810502 separately passed the base declaration group in a 10 GiB no-swap cgroup, 80.538 s, 7.558 GiB cgroup peak, observed async child GOMEMLIMIT=6142MiB, zero OOM/OOM-kill events.

Runtime-only smoke recovery 37278655660, same candidate and harness b184981251648f2e807758f708f46a6be1a58846, passed built CLI version, built status-runtime tests, isolated loopback Gateway /readyz with ready=true and /healthz with ok=true, then graceful shutdown. The earlier smoke asserted the wrong readiness JSON field and is retained as a failed harness attempt. The recovery did not repeat declarations or the memory proof.

Full-suite limitations

The full proof workflow is failed, not an all-green validation claim. Its contained pnpm check and pnpm test both reached their 2700 s deadline and were terminated. Both recorded zero OOM/OOM-kill deltas. check also failed the SQLite-worker guard because rg was absent, and the max-lines guard reported a stale baseline entry. Its 104-package lock validation did not complete. test recorded assertion failures before termination, including root-user refusal and a GitHub fetch failure in the network-disabled container. These logs do not establish that every failure is environmental or base-side; no passing full suite or exact-base reproduction is claimed.

Full check/test clearance requires a suitably provisioned non-root, network-capable validation route and classification of remaining assertion failures. No full build or memory stress was run on the production Mac mini.

Historical Evidence and Remaining Limits

Run 36148840191 passed a single cold declaration group on old head 726dea10b3e54389935e0c27744d2cfc35763dd5 inside a 10 GiB no-swap cgroup. That predates main's async emitter and is not current-head or full-build proof. Earlier contributor measurements and run 36108835114 are historical for the same reason.

The standard runner is not a 24 GiB host. A separately labeled lowered-Node-heap parallel cell can demonstrate shared worker environments, but cannot establish default-heap parallel admission on a larger host. Current-head full pnpm build has passed. Full pnpm check and pnpm test have not passed on the disposable proof host; their failed logs and deadlines are described above. No unconditional 6 GiB or 10 GiB full-build claim is made.

Closes #157783

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@Olli0103
Olli0103 marked this pull request as ready for review September 25, 2026 07:08
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S labels Sep 25, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: ready, awaiting a maintainer decision.

What this changes

This PR assigns native declaration compilers a shared Go memory target while preserving explicit caller limits.

Example: Two declaration workers share 24 GiB of effective available memory without a caller GOMEMLIMIT.

  • Before: Neither worker receives an automatic Go memory target.
  • After: Each worker receives GOMEMLIMIT=7372MiB.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong behavior evidence supports the introduced repair, but its remaining product value needs an owner decision after the later main fix.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Current-head Linux cold builds exercised automatic and explicit Go limits through pnpm build, with recorded async compiler environments, zero OOM events, output comparison, and overlapping-worker coverage; full check/test failures remain disclosed and unattributed rather than claimed as passing.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Cold source builds can lose the native declaration compiler to OOM despite bounded Node heaps.
Reason: The original repair has demonstrated value, but a later owner-authored implementation now addresses the central problem and changes the value of maintaining this alternative.

Merge readiness

⏳ Ready, awaiting maintainer decision

Keep open for maintainer disposition: a later merged fix addresses declaration-compiler memory on main, but this maintainer-engaged PR proposes a different policy and has confirmed conflicts.

Priority: P2
Reviewed head: 078fe921e196b2255dfc228d4834fce5f5e58a97
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should this PR be retired in favor of the shared compiler policy now on main, or does its availability-sensitive sizing address a distinct remaining requirement?
  • Recommendation: Confirm supersession: Retire this PR after confirming the shared policy covers the intended constrained-host requirement, preserving the contributor's measurements and discussion.
  • Why: The later repair addresses the central OOM problem through an existing owner, while this PR uses a different sizing policy and predates declaration consolidation.

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A failing-base replay of the added regression tests was not shown; supplied current-head build traces cover the changed production path.
Agent review details

How this fits together

The source-build wrapper prepares tsdown worker environments; native TypeScript children inherit those environments and return declarations to the existing staging and publication owner.

flowchart LR
  A[Source build command] --> B[Build plan]
  C[Effective memory capacity] --> B
  B --> D[Worker environments]
  D --> E[Native TypeScript compilers]
  E --> F[Staged declaration publication]
Loading

Technical review

Best possible solution:

Have the build owner confirm supersession by the shared policy on main before requesting any conflict repair or alternative memory policy.

Do we have a high-confidence way to reproduce the issue?

The historical failure has concrete compiler and cgroup traces, but this read-only review did not reproduce an OOM on current main after its later repair.

Is this the best way to solve the issue?

The proposed worker-environment approach is supported by real build evidence, but current main's shared compiler resource owner is the preferable place for any remaining repair.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 27a0be4a75d9.

Provenance checked

  • Build heap admission and memory snapshot keeps the original intent (0e8faac: Respect enforceable cgroup budgets and stop unsafe builds before output cleanup.)
  • Shared declaration staging and publication keeps the original intent (0c82ca6: One writer owns compiler-input receipts, private staging, validation, and publication.)
  • Overlapping staged compilers keeps the original intent (6cc8bb1: Overlap independently staged compilers only when measured capacity supports their combined budgets.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Verified introduced change: The pinned introduced diff adds availability-sensitive Go budgeting, divides the target by selected concurrency, preserves caller overrides, and excludes watch and declaration-disabled invocations. (scripts/lib/native-declaration-memory.mts:10, 078fe921e196)
  • Later merged repair: fix(build): prevent native declaration compiler OOMs #179140 merged a declaration-OOM repair using the existing compiler resource policy and one captured build budget; its recorded full build completed with maximum single-process RSS of 6.95 GiB. (scripts/tsdown-build.mts:736, 8816945e4a1c)
  • Current-main implementation: The fetched main wrapper calls applyLocalTsgoPolicy before constructing worker environments; the shared owner supplies constrained-host GOMEMLIMIT, GOGC, and GOMAXPROCS defaults while preserving explicit tuning. (scripts/tsdown-build.mts:737, 27a0be4a75d9)
  • Different current declaration graph: improve(build): cut measured full-build time by 51–59% #165271 consolidated full declarations into one program and removed staged compiler overlap; its discussion explicitly treated this PR's memory proposal as complementary. (scripts/lib/tsdown-config-groups.mts:4, 27a0be4a75d9)
  • Maintainer engagement and confirmed conflict: Collaborator obviyus supplied a full-build reproduction and requested preservation of the async emitter; live REST metadata still reports the reviewed head as mergeable=false and mergeable_state=dirty. (078fe921e196)
  • No formal fixing connection established: The inspected timeline contains no reference from the later OOM repair, and that repair's body does not identify this PR as superseded; implementation overlap alone does not satisfy the PR implemented-on-main close rule.

Likely related people:

  • Peter Steinberger: Raw commit 0c82ca6 adds scripts/lib/tsdown-declaration-writer.mts:26 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0c82ca658c03; files: scripts/lib/tsdown-declaration-writer.mts)
  • Jesse Merhi: Raw commit 0e8faac adds scripts/tsdown-build.mts:1098 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0e8faacd716f; files: scripts/tsdown-build.mts)
  • Vincent Koc: Raw commit e8dde30 adds scripts/tsdown-build.mjs:279 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e8dde305e2a0; files: scripts/tsdown-build.mjs)

PR surface

Tests +114, Other +99. Total +213 across 5 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 115 1 +114
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 109 10 +99
Total 5 224 11 +213

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Declaration compiler memory exhaustion affects constrained source-build hosts, with an existing repair now present on main.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (7 earlier review cycles)
  • reviewed 2026-09-25T07:16:36.671Z sha 8d9f021 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-25T07:30:10.523Z sha 2c9ca5b :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-25T07:52:37.436Z sha 2c9ca5b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T14:52:51.514Z sha 726dea10b3e54389935e0c27744d2cfc35763dd5 :: needs changes before merge. :: none
  • reviewed 2026-09-25T15:15:16.681Z sha 726dea10b3e54389935e0c27744d2cfc35763dd5 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-05T05:47:39.437Z sha 078fe92 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-05T09:18:48.763Z sha 078fe92 :: needs maintainer review before merge. :: none

Reviewed October 27, 2026, 9:16 PM ET / October 28, 2026, 01:16 UTC (Revision 8).

@Olli0103

Copy link
Copy Markdown
Contributor Author

@emes If your Ubuntu KVM guest that normally runs with 10 GiB is available, could you run the current PR head 2c9ca5be8953 there and share a redacted cold declaration-group trace? ClawSweeper's remaining request is a real constrained-host result, not another policy/unit test.

The issue's focused command is:

OPENCLAW_BUILD_CACHE=0 node --import ./scripts/tsx.mjs scripts/tsdown-build.mts --config tsdown.config.ts --filter openclaw-dts-base

The useful evidence is: actual process/cgroup limit (for example memory.max), the native tsc -p child's effective GOMEMLIMIT (read only that key from /proc/<pid>/environ, not the full environment), peak child RSS, peak cgroup usage (memory.peak, if available), wall time, and exit status. Please redact host paths and identifiers. A disposable 10-GiB cgroup on another adequately provisioned Linux host would also work. The PR body is explicit that its successful Mac run was on 16 GiB and does not establish this 10-GiB outcome; the contributor host is not suitable for another memory-stress run.

No need to rerun the entire cold pnpm build for this specific declaration-child boundary.

@Olli0103

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The remaining constrained-host proof is now in the PR body and in the green, secretless 10 GiB cgroup run (uploaded pr-157783-native-memory-proof receipt). Exact PR head 2c9ca5be89531e084ff512ab1b8c7d8732d0529b: cold declaration group exit 0, actual compiler GOMEMLIMIT=6113MiB, sampled compiler RSS peak 8.34 GiB, sampled cgroup peak 9.63 GiB, zero OOM/OOM-kill events. Please reassess the current-head proof boundary.

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@emes

emes commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Ran the PR head 2c9ca5be8953 on the Ubuntu KVM guest (Ubuntu 26.04.1, kernel 7.0.0-34, Node 24.21.0, pnpm 12.4.1, 6 vCPU). The guest currently has 12 GiB (MemTotal 11.6 GiB, ~7 GiB MemAvailable at launch with other services resident), so I ran the group inside a disposable 10 GiB cgroup with swap disabled, matching your Docker settings: systemd-run --user --scope -p MemoryMax=10G -p MemorySwapMax=0. Fresh worktree of the exact commit, pnpm install --frozen-lockfile, no caller GOMEMLIMIT (verified env | grep -c '^GOMEMLIMIT=' → 0). Command exactly as in the issue:

OPENCLAW_BUILD_CACHE=0 node --import ./scripts/tsx.mjs scripts/tsdown-build.mts --config tsdown.config.ts --filter openclaw-dts-base
Field Value
cgroup memory.max / memory.swap.max 10737418240 (10 GiB) / 0
native tsc -p child effective GOMEMLIMIT (from /proc/<pid>/environ, that key only) 4005MiB
peak child RSS (1 s /proc/<pid>/status samples, 164 samples) 8079232 KiB (7.70 GiB)
cgroup memory.peak (final) 8855859200 (8.25 GiB)
memory.events after oom 0, oom_kill 0 (unchanged from before)
tsdown invocation / wall 233.1 s / 234.4 s
exit status 0

Sampled peaks, not exact kernel high-water marks. Redacted 1 s trace excerpt attached below.

Two observations from this run:

  1. The resolver chose 4005 MiB, not ~6 GiB, because readProcessMemoryCapacity takes the minimum of the cgroup limit and host MemAvailable at spawn time. On a VM (or any host where the cgroup cap is above what is currently free) the Go limit therefore floats with whatever else is resident, and here landed well below the compiler's ~7 GiB live graph. Since GOMEMLIMIT is soft, the child still completed at 7.70 GiB RSS, but the group took 234 s versus 97 s unlimited and 154 s with an explicit GOMEMLIMIT=6GiB on the same guest (main de3010bcfad, same emitter, measured for [Bug]: native TypeScript 7 declaration emit peaks at ~13.5GB per tsgo child during pnpm build #157783). So the outcome on a 10 GiB-class host is safe but the cost is CPU time in GC rather than a lower footprint: the RSS floor is ~7.7–7.9 GiB at 4, 5 or 6 GiB limits. Deriving the default from the cgroup/physical cap rather than instantaneous MemAvailable, or flooring it near 6 GiB when the budget allows, would avoid the slowdown without changing the memory outcome.

  2. The 60 % rule assumes one compiler at a time. resolveStagedDeclarationConcurrency runs two declaration children concurrently when the (Node-heap-based) capacity check allows; on this guest at 24 GiB I observed two tsc -p children at 7.4 GiB each. With this PR each would get ~14.7 GiB, so the "remaining 40 % covers the parent and other processes" comment does not hold for that path. Not a regression versus today's unlimited children, but worth a note or a divisor by the staged concurrency.

For completeness: a full cold pnpm build on this guest inside a 9 GiB cgroup (+3 GiB swap allowance) with an explicit GOMEMLIMIT=6GiB plus #157739 completed in 26m13s with no OOM and 0 swap used (largest of twelve tsc -p children 7.86 GiB). That was on main, not this head.

Redacted trace excerpt (every 20th sample plus the peak sample)
14:00:45 cg_current=5148672 cg_peak=5894144
14:01:06 cg_current=2818637824 cg_peak=2819194880 tsc_pid=48995 tsc_rss_kib=1983584 tsc_gomemlimit=4005MiB
14:01:29 cg_current=4873658368 cg_peak=4874670080 tsc_pid=48995 tsc_rss_kib=4061152 tsc_gomemlimit=4005MiB
14:01:52 cg_current=6095335424 cg_peak=6096068608 tsc_pid=48995 tsc_rss_kib=5308852 tsc_gomemlimit=4005MiB
14:02:16 cg_current=7138926592 cg_peak=7140433920 tsc_pid=48995 tsc_rss_kib=6356300 tsc_gomemlimit=4005MiB
14:02:39 cg_current=8453242880 cg_peak=8453246976 tsc_pid=48995 tsc_rss_kib=7660672 tsc_gomemlimit=4005MiB
14:03:02 cg_current=8188854272 cg_peak=8468967424 tsc_pid=48995 tsc_rss_kib=7539404 tsc_gomemlimit=4005MiB
14:03:26 cg_current=8135688192 cg_peak=8468967424 tsc_pid=48995 tsc_rss_kib=7477740 tsc_gomemlimit=4005MiB
14:03:49 cg_current=8440274944 cg_peak=8781631488 tsc_pid=48995 tsc_rss_kib=7726280 tsc_gomemlimit=4005MiB
14:04:11 cg_current=747233280 cg_peak=8855859200
14:04:32 cg_current=1365286912 cg_peak=8855859200
PEAK: 14:04:01 cg_current=8852451328 cg_peak=8853696512 tsc_pid=48995 tsc_rss_kib=8079232 tsc_gomemlimit=4005MiB

@Olli0103

Olli0103 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor Author

@emes Thanks for the exact-head run and the trace. The 10 GiB declaration group completing without OOM is useful confirmation. Your 4005 MiB observation also exposes a real tradeoff: the current default can fall below the compiler's live graph when host MemAvailable is lower than the cgroup cap. The 234 s versus 154 s comparison is suggestive, though the runs are on different commits, so I won't claim an A/B speedup or blindly raise the limit to 6 GiB on a host that is already tight on memory.

The parallel case needs a correction before merge. Each concurrent declaration child currently receives 60% of the same budget, so the PR's claimed 40% reserve does not hold when staged concurrency is two. I'll account for the actual staged concurrency in the per-child budget, add a focused regression for that path, and revise the memory claim and proof limits. I'll check the capacity-versus-available choice against your measurements while doing that. The single-group 10 GiB result does not prove the parallel or full cold-build path.

@Olli0103

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now includes measured standalone wall times for both test files changed by this PR on the reviewed head 726dea10: 4/4 memory tests in 3.44 s and 202/202 build tests in 4.61 s, measured sequentially with /usr/bin/time -p. No code or test source changed.

Morpheus, assisting Olli with this PR.

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

I tested the full cold pnpm build entry point on current main 4db463bd62b3ab83eaf818211bb27a8ce73c3743 and a local integration of this PR, using node:24.16.0-bookworm on Linux arm64 with Docker --memory 10g --memory-swap 10g (no swap).

Source Exit Wall time Sampled aggregate process RSS peak Kernel cgroup memory peak New OOM kills
Current main 1 133.5 s 10,860,122,112 bytes 10,737,418,240 bytes 1
Local integrated candidate 1 130.4 s 10,917,888,000 bytes 10,737,418,240 bytes 1

Both builds completed tsdown-ai and tsdown-packages, then the runtime tsdown-unified child received SIGKILL, before the staged declaration phase. The sampled RSS totals can double-count shared pages; the cgroup high-water mark is the kernel measurement. The same container ran the builds sequentially with separate cold source trees; its cumulative OOM-kill count rose from 0 to 1 to 2.

There is also a real merge conflict: main replaced the emitter's managed compiler spawn with the async TS7 API. That API has no per-child env option, so the old env: resolveNativeDeclarationCompilerEnv() insertion cannot be carried over directly. The local candidate retained the API and passed the budget through staged invocation environments, including serial invocations; it was not pushed.

@Olli0103, could you rebase onto the async API and confirm which documented host class reaches the staged declaration phase in a full cold build? On this 10 GiB class, runtime bundling is an earlier blocker. I am handing this off rather than expanding this declaration-memory fix into runtime bundling. The caller-override, complete dist hash comparison, and live smoke gates remain unproven; this is not landing-ready evidence.

@Olli0103

Olli0103 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@obviyus let me have a look

@Olli0103
Olli0103 force-pushed the fix/native-dts-memory-157783 branch from 726dea1 to 078fe92 Compare October 5, 2026 05:34
@openclaw-barnacle openclaw-barnacle Bot added size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Oct 5, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 5, 2026
@Olli0103

Olli0103 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@obviyus The rebase is on 078fe921e196b2255dfc228d4834fce5f5e58a97 and preserves the async TS7 API. The PR body now contains the current-head receipts and their limits.

Run 37273712838 completed both full cold builds in a 13 GiB no-swap cgroup: automatic target in 825.829 s, explicit GOMEMLIMIT=6GiB in 835.984 s. Each observed 24 actual tsc --api --async children; the override was preserved throughout. Zero OOM or OOM-kill events. Complete inventories match after only the two named build-stamp timestamp fields are normalized; the raw differences are retained.

Two nonempty canonical extension partitions through the same staged writer also passed with two overlapping async children, each inheriting 3993MiB. That cell explicitly used 5 GiB Node heaps and is not default-heap parallel proof on a 24 GiB host. A separate focused 10 GiB declaration cell passed; I am not claiming a full build on that host class.

Runtime smoke 37278655660 passed built CLI/status and isolated Gateway readiness/liveness with graceful shutdown. The earlier readiness failure was the proof script expecting ok instead of ready.

The full proof workflow remains red: pnpm check and pnpm test each hit the 45-minute deadline, with additional guard/assertion failures. The container lacked rg, ran as root and blocked network access; those explain specific logged failures, not every failure. I have not certified the full suites or changed unrelated code to make this proof host pass.

Maintainer handoff: please validate full check/test on the supported non-root, network-capable CI route and, if required, default-heap parallel admission on a larger host. The requested async-child, override, output and lowered-heap overlap evidence is now available for re-review. No production Gateway changes or merge were made.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 5, 2026
@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Oct 28, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026

This branch has not been deployed

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

Labels

clawtributors PR from a clawtributor P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: native TypeScript 7 declaration emit peaks at ~13.5GB per tsgo child during pnpm build

4 participants