ReviewOS

zig-utils/zig-js

Perf: trim GC slab tails without scanning discarded free slots

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

Parent: #97 Related: #62, zig-utils/zig-gc#4

Evidence

The exact shared-realm object_churn profile attributed 216 of 994 coordinator evaluation samples to GcCellBacking.trimEmptyTailChunks. The old path filtered the intrusive free list node by node, including every slot in tail chunks that were immediately returned. Bootstrap cells leave a small live size-class prefix, so the optimized path reconstructs the list from issued slots in the bounded retained prefix instead.

Rejected exact-parent experiments are recorded in the issue timeline: deferring nursery trimming changed reuse behavior, while only fast-clearing completely empty buckets missed the measured live-prefix case.

Acceptance criteria

  • Tail trimming work is bounded by retained issued slots rather than discarded free slots.
  • Fully empty buckets clear their all-free list in O(1).
  • Partially live buckets retain exactly their valid free nodes and existing reusable-tail behavior.
  • Preserve capacity, issued/free/live counters, ownership indexes, and allocator delegation.
  • Materially improve the exact shared row without regressing direct throughput.
  • Pass focused allocator/GC/no-GIL tests and the batched unit/TSan gates.
  • Update the benchmark report, raw evidence, README, and benchmark guide.

Implementation: c98a36c Publication: e4b7240 Report: https://github.com/zig-utils/zig-js/blob/main/docs/.data/benchmark-comparison-2026-07-14.md Raw evidence: https://github.com/zig-utils/zig-js/blob/main/docs/.data/benchmark-comparison-2026-07-14.tsv

9 days ago

Retained implementation evidence on exact parent 3cc2a58c (baseline runner SHA-256 576826a06d9699821712452dc42e5ad2dd9c1682e7d6a3aaa4665f91d95474fb):

  • short exact-parent direct object_churn (100 jobs): 21 samples/binary, 213.873 ms -> 206.555 ms median (3.4% faster), all checksums 1030552128;
  • short exact-parent shared (8 lanes x 10 jobs): 21 samples/binary, 624.623 ms -> 557.282 ms median (12.1% faster), all checksums 825067776;
  • publication-load shared (8 lanes x 100 jobs): 6 samples/binary, 13.016 s -> 11.425 s median (12.2% faster), all checksums 8309369344.

Validation:

  • focused GC cell backing units: 20/20 pass;
  • complete units: 762/762 pass, 0 leaked;
  • focused GC cell backing TSan: 20/20 pass.

The implementation preserves trimming and the eight-chunk reuse tail, but reconstructs free nodes only from issued slots in the retained prefix. A completely discarded size class clears in O(1). Full publication and README refresh will follow in a separate docs commit.

9 days ago

Completed and published on main. Exact-parent eight-lane shared object_churn improved 12.2%; the full publication improved 10.3% to 11,089.300 ms. Direct exact-parent throughput improved 3.4%. Focused allocator units, all 762 units, focused TSan, and the full 1,540-sample comparison passed with exact checksums.

Sign in to comment on this issue.