ReviewOS

zig-utils/zig-js

Bench: add a polymorphic object-shape JSC workload

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

Parent: #50 Related: #47, #49, #52, #60

Problem

The accepted comparison needed a polymorphic object workload whose hot named access crosses multiple live receiver shapes instead of only monomorphic numeric loops. polymorphic_properties now supplies that row across direct, independent steady/cold, and shared modes.

Acceptance criteria

  • Exercise at least four live receiver shapes and a real named-property read/modify/write in the timed loop.
  • Extend harness validation and document the workload and timed boundaries.
  • Preserve stable cross-engine checksums in every mode/lane count.
  • Calibrate equal job counts so every full-run engine/mode row exceeds the publication timing floor.
  • Capture and link an initial symmetric baseline before optimization.
  • Optimize only general structural engine paths with live shape/property guards and correct fallback.
  • Beat JSC in every fair direct and independent-context row.
  • Keep zig-js shared-realm scaling above 1.0x at every reported lane count.
  • Pass focused semantic/GC/no-GIL tests, the comparison harness, and the final batched full suite/TSan gate.
  • Publish the expanded report/TSV and generated README summary only after all gates pass.

Current evidence: July 15 report, raw samples, and the README scorecard.

9 days ago

Initial honest workload is on main in 13c40bcc (bench: add polymorphic property comparison (#61)). Each job allocates four lane-local objects whose value property occupies slots 0, 1, 2, and 3, then performs 10,000 read/modify/write iterations while cycling all four live shapes.

Focused 3-sample one-job medians (10,000 iterations): zig-js 1.525 ms versus JSC 0.525 ms, so JSC currently has about 2.90x zig-js throughput. Exact checksum is 7115515; eight lanes produce 57220664 in zig-js direct/shared and JSC independent modes. The complete reduced nine-workload matrix passed. At its 10-job quick size, zig-js shared scaling was 2.37x at eight lanes.

The full default is 200 jobs/lane, projecting both engines above the 50 ms publication floor. No favorable full report will be published before a general structural engine optimization closes the new row.

9 days ago

Optimization is now on main in 89e2d399 (four-entry polymorphic inline caches) and 1b085362 (guarded isolated-context polymorphic property-loop quickening).

The quickener is structural: it recognizes an opcode/data-flow shape, not source text or benchmark/function names. It accepts only dense ordinary arrays and plain own-data objects, resolves live shapes/property slots through the general PIC, rejects shared or escaped frames, chunks within the checkpoint budget, preserves exact logical step counts, and falls back before mutation when a guard fails. The differential test covers both four plain receiver shapes and an accessor that forces guarded fallback.

Calibrated production-size probe (350 jobs/lane, three samples; exact checksum 2485681706 for one lane and 19985474120 for eight):

modezig-js medianJSC medianzig-js throughput advantage
direct single63.581 ms176.882 ms2.78x
independent steady, 1 lane63.842 ms177.157 ms2.77x
independent steady, 8 lanes96.736 ms261.609 ms2.70x
independent cold, 1 lane64.490 ms177.997 ms2.76x
independent cold, 8 lanes98.719 ms270.743 ms2.74x

Shared-realm zig-js medians were 523.587 ms at one lane and 730.485 ms at eight lanes, or 5.73x effective scaling. Every production-size median clears the 50 ms floor.

Validation completed in this slice: all 30 focused vm: tests, all 7 comparison-harness tests, and the reduced nine-workload matrix with matching checksums. The final full suite, TSan/no-GIL gate, seven-sample full report, TSV, and generated README publication remain deliberately batched and unchecked.

9 days ago

Final publication evidence is now on main in fdb32d8. The July 14 report contains all 10 workloads and 1,540 raw samples from db131e0. Polymorphic properties beats JSC directly (2.53x zig-js throughput), at eight warmed independent contexts (2.54x), and scales 5.57x in the shared realm. Full units passed 760/760 with zero leaks and the comparison harness passed 7/7; the fresh main TSan run remains pending before closing this issue.

9 days ago

Completed: the four-shape polymorphic property workload is fully published across direct, independent steady/cold, and shared modes with validated checksums, adequate timing floors, JSC wins in comparable rows, positive shared scaling, and the final safety/publication gates recorded in the issue body.

Sign in to comment on this issue.