ReviewOS

zig-utils/zig-gc

Perf: prepare old owners once for fresh-cell store batches

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

Consumer: zig-utils/zig-js#62

Evidence

A symbolized ReleaseFast object_churn profile after zig-js entered the 512-byte Object slab attributes 135 exclusive samples to Heap.writeBarrierFromManaged. The guarded object-allocation loop stores only freshly allocated managed children into one prevalidated array, but currently repeats the full child-young, parent-young, remembered-owner CAS, and marking checks for every replacement.

Invariant

For a checkpoint-bounded batch of fresh allocations:

  • every child is allocated by the same heap immediately before its first store;
  • a child allocated during incremental/full marking is born marked and queued/deferred for tracing;
  • no collection can promote the owner inside the batch;
  • an old owner therefore needs to enter the nursery remembered-owner set once before the batch, while a young owner needs no remembered entry;
  • the consumer must re-prepare after every GC checkpoint.

Scope

  • expose a strict exact-managed-owner API that prepares an owner for a batch of stores of newly allocated cells;
  • remember an old owner once when nursery collection is enabled;
  • avoid a redundant incremental child barrier because future children are born grey whenever marking is active;
  • keep the tolerant and ordinary per-child barriers unchanged;
  • document caller obligations and add a focused old-owner/young-child survival test.

Acceptance criteria

  • Old-owner to fresh-young-child edges survive minor collection after one preparation call.
  • Young owners and nursery-disabled heaps remain correct.
  • Existing exact/tolerant barrier tests remain green.
  • zig-gc full tests pass.
  • The consuming zig-js optimization shows repeatable exact-parent improvement.
  • Retained commits reference this issue.
9 days ago

The zig-js consumer experiment was correct but performance-neutral, so this API was fully reverted and no commit was pushed.

Validation before rejection:

  • full zig-gc tests passed;
  • zig-js forced-minor quick-object and restricted-receiver tests passed with zero leaks;
  • exact checksum held across all performance samples.

Exact-parent zig-js A/B: +0.11% paired median, 3/7 wins. That does not justify expanding the strict barrier API. See zig-utils/zig-js#89 for the complete evidence.

Sign in to comment on this issue.