ReviewOS

zig-utils/zig-gc

Perf: add an exact-managed owner/child write barrier

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

Profile source: zig-utils/zig-js#62 after cfed7bc

zig-js object_churn now spends 237 top-of-stack samples in Heap.headerForPayload from the dense replacement barrier. The generic writeBarrierFrom contract accepts arbitrary embedder pointers, so it correctly performs tolerant ownership classification for both child and owner. Some runtime paths, however, have exact live cells created by the same heap and need neither membership lookup nor fallback list scans.

Scope:

  • add writeBarrierFromManaged(owner, child) for non-null exact live managed payloads
  • derive headers directly and assert header magic in safety builds
  • preserve nursery old-to-young owner remembering
  • preserve incremental/concurrent marking handoff
  • leave writeBarrier/writeBarrierFrom tolerant semantics unchanged
  • share the post-classification marking helper to avoid logic drift

Acceptance:

  • nursery test promotes an owner, stores a young exact child through the new barrier, and proves survival
  • incremental barrier test proves a managed child becomes marked/retained
  • existing wild/non-heap pointer tolerance tests remain on the generic API
  • full zig-gc tests pass
  • commit references this issue and is pushed as Chris without coauthors
  • zig-js adoption is tracked separately and must show a pinned benchmark win before landing
9 days ago

Implemented in b9b5a8c. The new exact-managed owner/child barrier derives the child header directly, preserves nursery old-to-young remembering, and reuses the incremental/concurrent marking handoff without changing the tolerant public barrier. Added dedicated nursery and incremental reachability coverage; zig build test passes.

Sign in to comment on this issue.