ReviewOS

zig-utils/zig-js

Perf: release swept GC cell slabs in same-size batches

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

Problem

The direct object-churn profile still spends material time in per-cell sweep/backing release. zig-gc currently calls the backing allocator once for every dead object; GcCellBacking then repeats size-class dispatch, ownership lookup, and free-bitmap accounting.

Plan

  • Implement the optional batched sweep-release hook proposed in zig-utils/zig-gc#20.
  • Add a GcCellBacking same-size release path that acquires a bucket once and preserves exact live/free counters and duplicate-free assertions.
  • Retain generic allocator fallback for non-cell/delegated storage.
  • Add focused backing and GC reclamation tests.
  • Run exact interleaved baseline/candidate object-churn A/B before retaining.

Parent: #97 and #44. Backward compatibility is not required, but collector correctness and exact checksums are.

9 days ago

Implemented on main in aaa2c3ab; clean benchmark publication and README/report refresh are in d24f23c3. Dependency: zig-utils/zig-gc@597b7d7.

Exact interleaved direct A/B (21 pairs): baseline 117.088 ms, candidate 117.578 ms (+0.4%, candidate faster 12/21; neutral), checksum 1030552128 throughout.

Five-sample shared screen (baseline → candidate):

  • 1 lane: 221.560 → 191.131 ms (-13.7%)
  • 2 lanes: 413.365 → 348.444 ms (-15.7%)
  • 4 lanes: 1075.238 → 747.000 ms (-30.5%)
  • 8 lanes: 5328.988 → 5321.444 ms (-0.1%, neutral/noisy)

Clean seven-sample publication at aaa2c3ab:

  • direct object churn: 117.481 ms vs JSC 116.026 ms (1.3% gap)
  • shared object churn 1/2/4/8: 192.868 / 350.919 / 730.610 / 5192.344 ms
  • versus prior publication: -10.9% / -15.7% / -12.2% / -10.5% shared wall time

Validation: exact checksums, focused TSan shared/backing tests, all 766 zig-js tests (0 leaks), dependency full + full TSan, and benchmark publication guards.

9 days ago

CI routing note: run 29384313843 exposed an unrelated, machine-speed-dependent TSan mid-GC witness timeout after the runtime/benchmark jobs had passed. The harness root cause is tracked and fixed in #110 / e0bcf59; the superseding main gate includes both the batched sweep implementation and the oracle fix. #109 remains open until that combined run is fully green.

9 days ago

Completed by aaa2c3a with benchmark/docs publication in d24f23c and the CI-oracle follow-up in e0bcf59. The final superseding main gate is fully green: https://github.com/zig-utils/zig-js/actions/runs/29385360583 — 32 successful jobs plus 1 expected skipped nightly matrix entry, 0 failures. The exact TSan mid-GC job, all four TSan no-GIL corpus shards, unit/TSan matrices, benchmark harness, docs, Test262, and fuzz profiles passed. Broader shared-object scaling work remains tracked by #97.

Sign in to comment on this issue.