ReviewOS

zig-utils/zig-js

Perf: retain checkpoint-safe object allocation pools

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

Parent: #97

The shared fixed-shape object kernel preserves exact 1,024-step checkpoints, so its current local allocation batch is limited to 17 objects. A fresh eight-lane profile still records allocObjectBatch/scheduler handoff among the dominant stacks after one-lock batch publication. Earlier checkpoint widening was correctly rejected because replaying checkpoints changed locality and regressed one lane.

Design

  • Keep a small fixed-capacity pool of default-initialized ordinary GC objects on each Interpreter.
  • Trace the unused pool entries as interpreter roots, so the existing checkpoint/collection schedule remains exact and no pointer can be swept while reserved.
  • Refill only in the already-proven shared fixed-shape allocation path; private/direct paths remain byte-identical.
  • Consume and remove each entry from the pool before it becomes observable through the frame/array; preserve prototype/shape/property initialization, barriers, fallback, and exact checksums.
  • Bound unused retained storage and clear it naturally with interpreter lifetime.

Acceptance

  • Focused tests prove refills exceed the old 17-cell boundary and unused cells survive a checkpoint collection.
  • No direct/private behavior change; exact shared checksums and OOM fallback remain valid.
  • Order-balanced shared 1/2/4/8 A/B has no 1/2-lane regression and materially improves 4/8 lanes.
  • Pass focused GC/no-GIL/TSan, then batch full gates before publication.
11 days ago

Closed as not planned after an exact alternating five-pair A/B against the frozen parent binary.

lanesparent medianpool mediandelta
1147.289 ms185.526 ms+25.96%
2399.017 ms349.304 ms-12.46%
41245.816 ms1031.692 ms-17.19%
82334.845 ms2269.089 ms-2.82%

The implementation was correct under the focused fixed-shape allocation test, but it fails the benchmark acceptance contract: single-thread regresses severely and the 8-lane change is not material. Retaining unused initialized objects across checkpoints also makes them roots, increasing tracing/promotion/sweep work; that cost explains why reducing publication-lock traffic did not translate into an across-the-board win.

The prototype has been fully reverted. No README score was changed because this was not an accepted full matrix.

Sign in to comment on this issue.