ReviewOS

zig-utils/zig-js

Perf: hoist plain-object prototype lookup from allocation batches

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

Parent: #62

Evidence

Current main at f4602d86 still trails system JSC in the fair direct object_churn row. A fresh five-sample same-session check measured medians of about 197.000 ms for zig-js and 117.836 ms for JSC, with checksum 1030552128 in every sample (about a 1.67x remaining elapsed gap).

A fresh symbolized ReleaseFast profile shows the guarded fixed-shape allocation loop repeatedly entering Interpreter.newObject; a visible portion of that path is objectProto, which walks to the realm root and locks its binding table even though %Object.prototype% is an immutable intrinsic identity already cached by the realm. The quick batch validates one root shape and can resolve that intrinsic once before allocating its checkpoint-bounded run.

Scope

  • expose a narrow intrinsic-prototype resolver for VM allocation tiers;
  • resolve %Object.prototype% once per guarded allocation batch rather than once per fresh object;
  • allocate/default-initialize every object through the normal GC seam and assign the same intrinsic prototype;
  • preserve realm identity, bootstrap/null-prototype behavior, OOM recovery/state publication, tracing, checkpoints, and all existing quick-loop guards/fallbacks.

Acceptance criteria

  • focused tests prove quick and generic execution retain identical values and exact VM step counts across realms;
  • OOM and fallback behavior remain covered;
  • exact-parent alternating object_churn A/B shows a repeatable win with checksum 1030552128;
  • retain only if the signal justifies the added API seam;
  • batched full validation and commits reference this issue.
11 days ago

Implemented and pushed in db131e0.

Exact-parent alternating A/B on object_churn (100 jobs, 3 samples/process):

  • Batch 1: candidate won 6/7 pair medians; aggregate median 198.414 ms vs 201.122 ms (-1.35%).
  • Reversed-order confirmation: candidate won 5/7 pair medians; aggregate median 202.508 ms vs 214.441 ms (-5.56%; noisier batch).
  • All 84 samples produced checksum 1030552128.
  • The quickened path now has a regression assertion for intrinsic Object.prototype identity after replacing the global Object binding.
  • Validation: 760/760 unit tests, zero leaks; 7/7 comparison-harness tests.

The change resolves the realm intrinsic once per checkpoint-bounded allocation batch and preserves allocation failure publication and exact step accounting.

Sign in to comment on this issue.