Skip to content

fix(jsc): track ArrayBuffer ownership and inspect worker memory - #5

Merged
steipete merged 2 commits into
openclaw/mainfrom
claude/w143-arraybuffer-accounting
Oct 4, 2026
Merged

steipete merged 2 commits into
openclaw/mainfrom
claude/w143-arraybuffer-accounting

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown

ArrayBuffer payloads now retain their allocation-origin charge across worker transfers while external memory follows the current holder. Previously, unmaterialized typed-array vectors were missing, GC-holder estimates moved the wrong charge between VMs, and worker statistics waited for the worker event loop to become idle.

The engine keeps separate origin, holder, native-object, and GC-epoch accounting. Fast/Oversize vectors are registered in C++, DFG and FTL, reconciled before sweep, and retired once during materialization. A packed weak link preserves view size, and Eden collections scan only the young prefix. Resizable, shared, native-adopted and WebAssembly storage have explicit ownership rules. JavaScript heap reporting and worker limits share the same backing-store classification.

Worker inspections run on the owning VM thread through traps, an idle drain and atomic-wait wakeup. Teardown disposes pending callbacks. The matching Bun adapter is included in the existing qualification pipeline; engine and Bun must be rebuilt together. This extends the read-only engine check. Artifact publication remains a coordinator action.

Builds on oven-sh/WebKit#303 and oven-sh/bun#34406; thanks @robobun.

Integrated onto source-position main e9d324af5. Exact-head CI run 37242889997 is green at e95a3ef91cf0fda2d4e65ddc250513c0c669565c. The accounting adapter is 010, after the common stack-position adapter 009.

Validation on one direct AWS c7a.24xlarge Linux host, using the unchanged lane recipe:

  • JSC accounting and sampling: LLInt, baseline JIT, DFG, FTL and concurrent GC; namespace and source-position regressions also pass.
  • Node 24.21.0 and paired Bun: 24/24 API/ownership modes each, covering transfer, origin exit, detach, resize, native, shared, WebAssembly and serialization behavior.
  • Focused process (19), worker (7), native-buffer (1), worker-limit (14) and serializer (60) cases pass; combined source-position suites pass 96/96.
  • Unchanged OpenClaw worker-cpu/task-pool/transfer consumers: 38/38. Busy/waiting worker reads complete in approximately 1 ms.
  • Expanded paired fork selection: 45 files plus 2 dependency checks, 47/47 all-pass on both arms, identical outcomes and zero regressions.
  • Rust checks: 12/12 targets; subsequent runtime edits are C++/JS.
  • Codex P2 reviews: scoped-clean for engine and Bun.
  • Supplementary TSan accounting/lifecycle run passes with documented exact-frame suppressions for pre-existing GC races; 1,280 inspections and 1,280 queued cancellations across 20 VM lifetimes. This is scoped qualification, not an unsuppressed race-free claim. The only GC synchronization changes retained are atomic extra/external visited totals and the exercised parallel-helper activity assertion lock.

One initial API run exposed startup allocation timing in the new busy/wait fixture, also reproducible on the prior candidate. Settling startup before allocating the fresh payload preserves all assertions, the 64 KiB bound, and the consumer. Node and Bun then passed 20 busy plus 20 wait repetitions each before the complete rerun.

ABBA, eight samples per arm, against paired current-main engine plus the same common Bun adapters:

Workload Before (ms) After (ms) Change
buffer 146.4802 149.3238 +1.94%
fast 31.3784 31.4235 +0.14%
materialize 144.8020 149.6641 +3.36%
oversize 145.4974 146.3678 +0.60%
small 4.6612 5.0975 +9.36%
stats 2097.6425 2111.8061 +0.68%
eden-retained 34.7131 34.8259 +0.33%

Tiny-array tracking costs approximately 2.2 ns per allocation in this workload. These costs are explicit; no consumer assertion or benchmark threshold was relaxed.

Keep allocation-origin attribution with backing stores across transfers and
VM teardown, while holder external and GC heap totals remain independent.
Instrument Fast/Oversize allocation in C++, DFG and FTL, and service numeric
worker inspections on the owning thread during loops and atomic waits.

Include the matching Bun qualification adapter and execution-tier tests.
Retain only the accounting-related visited-total atomics and the helper
activity assertion lock exercised by the accounting collector path.

Builds on oven-sh#303 and oven-sh/bun#34406; thanks @robobun.
Preserve both independently reviewed changes and their regression checks.
Apply stack-position adapter 009 before accounting adapter 010, retain both
changelog entries, and synchronize the two reviewed Bun header whitespace
fixes. Accounting runtime and JSC test patch sections are unchanged.

Combined-base direct AWS qualification and exact-head CI gate landing.
@steipete
steipete merged commit 6fceea9 into openclaw/main Oct 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant