ReviewOS

zig-utils/zig-js

GC: make the multi-age nursery moving

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

Parent: #134 Extends: #145 Depends on: #144 Related: #446 Blocks: #147, #246

The production age-three nursery currently reclaims and promotes without relocating surviving young cells. The README removal gate requires a moving nursery whose copying/promotion path reuses the exact relocation contract and remains safe during mid-script no-GIL minor collection.

Acceptance

  • Copy surviving young cells between age spaces and promote terminal-age survivors with stable IDs and failure-atomic forwarding metadata.
  • Rewrite precise roots, old-to-young remembered edges, young-to-young edges, weak/finalization state, handles, interpreter/baseline/optimizer stack maps, and embedding roots during every moving minor cycle.
  • Preserve persistent-card correctness and eliminate stale from-space pointers before mutators resume; verify the full relocation inventory after each stress cycle.
  • Coordinate bounded parallel mid-script minor rendezvous across shared-realm mutators without a context GIL, including allocation failure and collector abort recovery.
  • Keep conservative stacks and opaque native frames explicitly pinned or fail closed; never infer interior/base pointers from untyped words.
  • Add age-by-age promotion, weak/ephemeron/finalizer, JIT deopt/OSR, native handle, fault-injection, leak, no-GIL, TSan, and long-running mutation tests.
  • Publish exact-parent pause, throughput, bytes-copied, promotion, retained-backing, and timeout evidence; update the release matrix and README only from committed artifacts.
9 days ago

Implementation landed on main in 56dfc7d6 (feat(gc): move multi-age nursery survivors) with the reusable collector layer in zig-utils/zig-gc@958563a (feat(heap): move multi-age nursery survivors).

Completed mechanics:

  • Every live young survivor moves after minor weak/sweep processing, including terminal-age promotion, while preserving process-stable cell IDs.
  • Destination and forwarding planning are failure-atomic; OOM leaves roots/edges/addresses unchanged and increments movement-failure telemetry.
  • Exact Context, interpreter/VM, baseline/optimizer stack-map, protected Zig, C-API, private strong/weak, remembered, young-to-young, weak/ephemeron/finalization, and Wasm/embedding dispatch all reuse the verified relocation inventory.
  • Promotion creates a persistent old-owner card so a parent that ages ahead of its child remains a valid frontier across later moving minors.
  • Shared no-GIL movement uses the existing bounded 100 ms exact-generation rendezvous. Opaque peers time out without consuming work; a deterministic retry test proves the same request later completes.
  • JIT-enabled shared allocation pressure now publishes a distinct moving-checkpoint wake word. Exact native checkpoints move; opaque paths get a four-tranche bounded opportunity before conservative non-moving fallback.

Verification on the pushed source:

  • zig build test-parallel: 1,458/1,458 passed, 0 leaked, 10 shards.
  • Moving-nursery filter: 8/8 Debug, 8/8 ReleaseSafe, 8/8 TSan, 0 leaked and no TSan reports.
  • Cooperative filter: 7/7; compaction filter: 11/11.
  • zig-gc: 56/56 tests.
  • Test262 expectations changed: 0.

The final two checklist items intentionally remain open until the exact-parent generation benchmark publishes pause/throughput/bytes-copied/promotion/retained-backing/timeout evidence from a clean commit. Related automatic-stop evidence remains tracked in #446.

9 days ago

Closure evidence landed in e1a51b0b and release-inventory follow-up 8f7ea6e0.

The committed July 29 matrix contains 112 exact moving/non-moving age-one/age-three rows, zero movement failures, nonzero copy telemetry for survivor workloads, a three-mutator no-GIL parent, bounded retries, raw TSV, and a generated report. Moving age-three measured 0.63–1.01x its exact non-moving parents; 480.42 MiB was copied across the recorded moving age-three rows. Full units were 1,458/1,458, focused moving-nursery coverage passed in Debug/ReleaseSafe/TSan, and the release inventory now marks generational_gc green (11/12 overall).

Related #446 owns the remaining automatic-compaction coverage audit; it no longer blocks the moving multi-age nursery itself.

Sign in to comment on this issue.