ReviewOS

zig-utils/zig-gc

GC: expose zero-overhead collection phase boundaries

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

Downstream: zig-utils/zig-js#426

Embedders can currently observe only afterSweep; a nursery collector regression cannot distinguish preparation/whitening, root+graph tracing, sweep/finalization, and the post-sweep hook without patching the generic heap or embedding a clock in zig-gc. The generic collector should expose semantic phase boundaries while leaving timing and storage entirely to an opt-in binding.

Acceptance

  • Define stable full/minor collection phase boundary values for prepare/trace/sweep/post-sweep transitions.
  • Invoke an optional binding hook at the exact boundaries without changing collector ordering, locks, barriers, or failure behavior.
  • Compile the hook away for bindings that do not declare it; zig-gc must not own a clock or counter.
  • Cover full and nursery ordering, empty/no-op nursery collection, force-full fallback, and after-sweep ordering in focused tests.
  • Pass the full normal and suppression-free TSan suites.
  • Document the opt-in binding contract concisely and update the zig-js dependency consumer.
9 days ago

Generic phase boundaries landed in d0f3035.

  • normal suite: 45/45, zero leaks
  • suppression-free TSan suite: 45/45, zero reports
  • focused ordering covers empty minor no-op, native minor, forced-full fallback, and afterSweep placement
  • bindings without collectionPhaseBoundary compile the call away; zig-gc owns no clock or counter

The final acceptance item remains open until zig-js#426 consumes the hook and its downstream gates pass.

9 days ago

Consumed by zig-utils/zig-js@8b271b3 for exact cooperative-GC phase attribution. The downstream normal and focused TSan counter gates pass, the opt-in contract is documented, and ordinary bindings compile the hook away.

Sign in to comment on this issue.