ReviewOS

zig-utils/zig-js

Objects: elide single-owner named descriptor snapshot mutexes

#1006
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Problem

After #1005, the frozen representative_json invocation still records 817,937 property-lock acquisitions, including 798,645 named_snapshot acquisitions. These are present ordinary named-property reads in a single-owner Context. namedOwnPropertySnapshot still unconditionally takes property_lock after its lock-free Shape probe even though #1005 established an enable-only publication gate for this exact mutable-slot snapshot boundary.

Change boundary

Reuse Object.property_snapshot_locks_enabled and lockPropertySnapshot for the present-data branch of namedOwnPropertySnapshot. The default single-owner path may skip the mutex; after enableParallelSync() publishes concurrent GC or parallel JS, retain the exact current lock, accessor recheck, Shape revalidation, attribute read, and slot read. Do not change writers, absent-property publication, accessor reader gates, Proxy/exotic behavior, or shared-realm synchronization.

This is a single-owner continuation of #1005 under parent #473. It does not alter #532's shared-object synchronization or claim its remaining multi-lane acceptance gate.

Completion

  • Pin lock-counter tests for disabled and enabled publication modes.
  • Keep concurrent descriptor publication and mutation witnesses on the enabled path, including TSan/no-GIL coverage.
  • Preserve JSON semantics, OOM/deep/cycle behavior, Test262 JSON, and required VM/tree agreement.
  • Run seven alternating exact-parent pairs on both frozen JSON rows, array/object controls, and a generic named-property control with exact checksums.
  • Land only with measured instruction/CPU non-regression and update #473.
9 days ago

Landed on main in 1eee9212. The enable-before-sharing gate now covers ordinary named descriptor snapshots while concurrent realms retain the exact locked accessor, Shape, attribute, and slot revalidation path. Frozen representative_json attribution falls from 817,937 property-lock acquisitions to 19,292, removing all 798,645 named-snapshot mutexes with the exact checksum and unchanged Shape/allocation/GC counts. Seven alternating pairs keep base JSON at 0.9947x instructions / 1.0019x CPU and the variant at 0.9990x / 0.9990x; the proxy/accessor control improves to 0.9921x / 0.9842x. JSON Test262 is 165/165 with 165/165 required VM agreement; 6,178 related property cases, 30 real-GC JSON tests, the no-GIL TSan witness, and 121 value-layer TSan tests are green. Current direct comparison is still 4.2965x / 4.4930x JSC, so parent #473 remains open.

Sign in to comment on this issue.