ReviewOS

zig-utils/zig-gc

Perf: size the default nursery for mutator safepoints

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

Problem

The 64 KiB minimum / 256 KiB default nursery makes allocation-heavy embedders collect far too frequently once they add safe mid-script minor-collection checkpoints. In zig-js object churn, that policy regressed the workload to roughly 2.53 s per 100 jobs because collector fixed costs dominated.

Proposed change

  • Raise both the minimum and default nursery threshold to 4 MiB.
  • Preserve the existing survival-based adaptive policy and young-batch growth cap.
  • Keep the policy general in zig-gc; the embedder decides where safe collection checkpoints exist.

Evidence

A 4 MiB nursery was the best tested point for the downstream zig-js object-churn workload. Larger 8 MiB and 16 MiB batches were slower, while the old sub-megabyte defaults caused excessive minor collections.

Downstream: zig-utils/zig-js#63

Acceptance criteria

  • Nursery threshold tests cover the new floor and adaptive cap.
  • zig-gc unit tests pass.
  • Downstream zig-js uses the policy at single-mutator safepoints.
  • Exact downstream checksum remains stable.
9 days ago

Implemented in a0b9101 and pushed to main. The nursery floor/default is now 4 MiB, the adaptive growth-cap tests cover the new policy, zig-gc tests pass, and downstream zig-js preserves checksum 1030552128 while collecting at single-mutator safepoints.

Sign in to comment on this issue.