ReviewOS

zig-utils/zig-js

Perf: use the exact-managed barrier in object churn replacement

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

Problem

The fixed object-allocation loop replaces a present dense array element with a freshly allocated managed object on every iteration. Its generic replaceDenseElement barrier classifies both exact GC payload pointers through zig-gc’s tolerant live-payload index, which remains visible in the object_churn profile.

Scope

  • Add a narrow exact-managed value barrier in gc.zig backed by zig-gc#10.
  • Add an explicitly prevalidated, exclusive dense replacement primitive that omits its own generic barrier.
  • Use that pair only in the isolated object-allocation quick loop when the active allocator is the GC heap; preserve the existing arena/generic path.
  • Keep the per-iteration restriction check and all loop bailout semantics unchanged.
  • Add focused coverage proving the quick loop still runs correctly in both arena and GC modes, including nursery collection.
  • Compare pinned alternating runs against cfed7bc5; land only if the exact-checksum benchmark shows a repeatable win.
  • Run the batched full suite only after a measured win.

Acceptance

  • Exact managed owner/child barrier preserves nursery and incremental invariants.
  • object_churn checksum remains 1030552128.
  • Candidate beats the pinned baseline across paired samples.
  • Commit references this issue and is pushed to main as Chris without coauthors.
9 days ago

Landed on main in fb6f8d8, backed by zig-gc exact-managed barrier b9b5a8c (zig-gc#10). Seven alternating process pairs with three samples each beat cfed7bc in 7/7 pairs: overall median 254.840333 ms -> 232.842708 ms (8.6319% lower, 1.0945x throughput), with checksum 1030552128 in all 42 samples. Validation: focused GC/nursery quick-loop coverage, 757/757 unit tests with zero leaks, and 7/7 benchmark-harness tests.

Sign in to comment on this issue.