ReviewOS

zig-utils/zig-js

Perf: batch private fixed-shape loop allocations

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

Parent: #62 Related: #97, #49, #44

Evidence

The clean 86d0c5b3 publication has the only direct JSC loss in object_churn (120.334 ms vs 118.117 ms) and a larger warmed eight-context gap (465.616 ms vs 200.717 ms). Sampling the exact workload shows the specialized fixed-shape loop dominating worker execution. Its no-GIL branch allocates up to 17 objects per checkpoint-bounded batch through allocObjectBatch, but the private single-mutator branch still calls allocObject for each iteration even though it has the same no-call, fixed-shape, dense-array guards and exact checkpoint boundary.

Scope

  • Reuse the existing checkpoint-bounded object batch in private contexts, not just the synchronized shared branch.
  • Preserve exact bytecode step counts, safepoint visits, literal shapes/prototypes, indexed replacement, displaced reads, barriers, OOM prefix behavior, and fallback guards.
  • Add focused coverage proving private GC-backed quick loops consume the batch path while arena mode and guarded fallback remain correct.
  • Measure frozen-binary, order-balanced A/B for direct and warmed eight-context object_churn; check shared mode for neutrality.

Acceptance

  • Beat JSC in the fair direct object_churn row and materially improve warmed independent contexts without regressing shared mode.
  • Preserve exact checksums and pass focused VM/GC/OOM tests plus the final batched normal/TSan gates.
  • Publish clean full-matrix evidence and refresh README/docs only after all gates pass.
11 days ago

Rejected by frozen-binary, order-balanced A/B and fully reverted (no commit).

The candidate reused the existing 17-cell checkpoint-bounded batch in private GC contexts and added focused proof that 496+ cells took the batch path; the semantic test passed 2/2 with no leaks. Exact checksums remained 1030552128.

However, direct object_churn regressed consistently:

  • baseline then candidate: baseline median 127.360 ms, candidate median 137.472 ms (+7.9%);
  • candidate then baseline: candidate median 145.882 ms, baseline median 130.303 ms (+12.0%).

The private heap has no contended allocation metadata lock to amortize, so the extra batch machinery is net overhead; the shared branch's rationale does not transfer. The source and test changes are removed and the worktree is back to only the user-owned .claude/ directory.

Sign in to comment on this issue.