ReviewOS

zig-utils/zig-js

Perf: make swept GC cell reuse O(1)

#112
Closed chris opened this 11 days ago ·
11 days ago

Parent: #62\nRelated: #111, zig-utils/zig-gc#21\n\nAllocation-heavy profiling shows GcCellBacking.takeFreedSlotFromChunkLocked in 120/536 direct samples after batched sweep release. The current reusable-slot path repeatedly scans fixed per-chunk bitmaps from word zero.\n\nReplace the bitmap-search allocation path with an intrusive LIFO free-slot chain stored in already-dead slab storage, while retaining exact ownership metadata and bitmaps for diagnostics/validation. Validate exact checksums, GC backing accounting, direct and 1/2/4/8 independent object-churn rows, full correctness, and TSan. Publish material results in the benchmark report and README and reference this issue from every commit.

11 days ago

The first implementation experiment (intrusive links in swept cell storage) is rejected and will not be committed: exact checksums held, but direct object churn regressed from 114.511 ms to 163.834 ms and warmed 8 independent contexts from 366.021 ms to 779.469 ms. This showed that preserving the bitmap allocator’s compact address-order reuse matters. The issue remains open with a narrower implementation: retain external bitmaps and address order, but maintain each bitmap’s first non-empty word so allocation no longer rescans from word zero.

11 days ago

Closing the experiment without a merge. The address-ordered bitmap cursor improved direct medians in the focused screen (about 2–3%) but did not meet the no-regression gate: warmed 8-context paired rounds were noisy and had a +24.322 ms median cursor-minus-baseline delta. Both attempted designs are fully reverted; the working tree is back to the published allocator. Follow-up optimization will target the per-cell nursery finalization/sweep cost instead of reuse ordering.

Sign in to comment on this issue.