ReviewOS

home-lang/home

Native runtime: expose real spawn counters through the JSC bridge

#496
Closed chris opened this 9 days ago ·
9 days ago

Follow-up to #66 and #493. The unchanged packages/runtime/test/bun-corpus/js/bun/spawn/spawnSync.test.ts reports 4 pass / 1 fail / 1 platform skip / 11 assertions in Home. The failure is should use spawnSync optimizations when possible; spawnSync-counters-fixture.ts does not observe an increase in getCounters().spawnSync_blocking. Installed Bun 1.3.14 passes 5 tests / 11 assertions, with the Linux-only memfd test skipped on this Mac.

Home's packages/runtime/src/jsc/Counters.zig has the real saturating counter fields/mark operation, but its header explicitly says toJS/createCountersObject were omitted. JS2Zig___src_jsc_Counters_zig__createCountersObject remains in native_stubs.zig. Port the actual current-VM counter snapshot bridge and verify that the intended native fast path really runs. Do not return fabricated increments or reinterpret this observability failure as proof that the optimization is already verified. On Linux, also verify real memfd behavior and counter updates with unchanged fixtures.

Source pin: 4982b91e3702094330f3be3883354c52b8c01323. Native POSIX error propagation in #493 is a separate change. Preserve existing test deadlines and platform skips; skips are not passes.

9 days ago

Cross-reference update: #493 is implemented and verified in 6d797186c, with #66 updated. The counter snapshot bridge remains parked; actual fast-path/counter behavior still needs verification. The other adjacent gaps are #495 (extra stdio), #496 (real counter snapshots), and #497 (package scripts). These remain separate from the passing full Node timer file (20 tests / 31 assertions).

9 days ago

Implemented the real native bridge on codex/runtime-port in a21f735fc; not merged into main.

createCountersObject reads the invoking VM's existing Counters and creates a distinct JS snapshot. The weak global-object-returning stub is removed; no counter increment is fabricated. Native tests verify the actual blocking fast-path increment, unchanged blocking count on failed setup, buffered-spawn behavior, field types, non-aliasing and mutation isolation. Linux may allocate memfds before an OS spawn failure, so its allocation counter is not incorrectly treated as a success-only counter.

The complete unchanged spawnSync suite passes 5 tests / 11 assertions with 1 Linux-only skip on Darwin. The prior published binary fails the new native snapshot assertions. All 21 native files / 31 selected regression commands and both 17/17 builds pass. Linux's actual memfd fixture and other platform validation remain unverified; the skipped case is not a pass. Keeping this open for integration and Linux verification under #66. The same checkpoint implements #495; remaining boundaries include #497 and #499.

9 days ago

The pending-integration condition is now resolved on main. The real current-VM counter snapshot bridge and the native spawn fast-path increment are present in a21f735fc.

Reverified on current main with the unchanged pinned spawnSync.test.ts: 5 pass / 1 Darwin platform skip / 0 fail / 11 assertions. In particular, should use spawnSync optimizations when possible observes the real spawnSync_blocking increment. The Linux memfd case remains a platform skip here and is not counted as a pass.

Closing the implemented integration item; broader platform parity remains under #66.

Sign in to comment on this issue.