You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0f14430
Browse filesBrowse the repository at this point in the historyBrowse files
authored
perf(signals): narrow store writes clone by spread; overlay only for wide owned backings (#3367)
Part one of #3360. Per write+commit on a one-key store: rc.7 629 ns ->
340 ns steady state; a fresh store's first write+commit 3x cheaper (the
reporter's 100k-store shape ~265 -> ~90 ms).
- cloneRaw spreads plain-data containers (Object.prototype, every own key an
enumerable data property) instead of the descriptor walk: same result,
~1/50th the cost. The one-time accessor scan grades the container (sc
0/1/2) and records its own-key count (kc, bumped by set-trap writes of new
keys so a record that grows from {} still graduates).
- The #3044 prototype overlay is taken only for WIDE (>32 keys) containers
over an OWNED backing. Narrow ones clone cheaper than they overlay
(Object.create turns the backing into a V8 prototype and every flatten
writes into that prototype); an unowned backing had to be privatize-cloned
at commit anyway, so the overlay there paid create + clone + per-key copy.
- Grade-2 containers flatten and take overlay first-writes by bare
assignment; a non-plain defineProperty through the draft downgrades the
grade so descriptor-bearing keys keep the descriptor paths.
The remaining per-write cost is the weak-collection registration of each
pending backing (~190 ns); that is part two.
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
Store writes on narrow containers are ~1.85× cheaper (629 → 340 ns per write+commit steady state; a fresh store's first write+commit 3× cheaper). Plain-data containers now clone by spread instead of a descriptor walk, and the #3044 prototype overlay is taken only for wide (>32 own keys) containers over an already-owned backing — for narrow or unowned ones the overlay cost more than the clone it was meant to avoid (`Object.create` turns the backing into a V8 prototype, and the first commit had to privatize-clone anyway). Part one of #3360; the remaining per-write cost is the weak-collection registration of each pending backing.
0 commit comments