Repository navigation
perf(octane): record event signal authority on the host instead of weak maps - #1655
Merged
Merged
Conversation
…ak maps #1069 made every module that can receive a signal handle record each native handler's signal authority: the element's owner in one weak map and an "escaped" mark for the scope in another. Keyed rows paid two weak-map insertions per mounted row even with no signals in use. A same-runner paired A/B put prepend100/append100/insertmid100 at 0.48 -> 0.76 ms across #1069. The element's authority now lives in a $$signalOwner property beside its handler slots, journaled and rolled back like before, and the escape mark is a signalTokenEscaped field on Scope/Block with the same retirement truth table. Mounting no longer touches a weak map. bindSignalText also writes a scalar over the Text it already owns directly, skipping bindDirectSignal's policy dispatch; setText still journals the text and the binding bag. That path runs for every compiled text-hole update in such a module (memo-wall context refresh: 0.669 -> 0.622 ms paired). The signal-dom-bindings suite gains a deterministic guard counting weak-map insertions per mounted and inserted handler row (2 on main, 0 now), with dispatch and survivor-identity controls. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 3, 2026 09:37
Contributor
Benchmark report
Compares js-framework: 1k/10k row operations (ms, lower is better)
All 20 timed operations (18 within noise)
Application bundle size (bytes)
8 other measured values are unchanged. Public-import reachability bundles (bytes)
36 other measured values are unchanged. |
This was referenced Oct 3, 2026
The stable-event-authority work observer counted authority writes through WeakMap.prototype.set. Authority now lives in each host's $$signalOwner property, so the observer counts writes through an Element.prototype accessor instead. The expected counts are unchanged (400 mount, 0 retained, 0 changed capture), and dropping the runtime's unchanged-authority skip still fails the retained-write assertion. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
trueadm
added a commit
that referenced
this pull request
Oct 3, 2026
…ed fixes rotateb and ctx_through_wall_B clear with #1655 and #1656; one_change_B's per-row remainder and tooltip_swarm's scoped-descriptor accessor reads each have their own fix task. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 3, 2026
…nd re-judge them (#1646) * ci(bench): triage the weekly ratio-guard breaches so new ones show The weekly Bench job (`bench.mjs --quick --ratios`) was red with 81 ratio breaches, 4 suites that wrote no numbers and 4 harness gate failures, so a new breach was invisible. Every item is now a fix or a rebaseline. - Harness drift, fixed. Each harness had stopped producing numbers when runtime source it anchors on changed: - ssr-final-replay: a second suspended loop since 2026-09-29. - root-transactions/contracts: staged-DOM text and attribute journaling since 2026-09-15. - signal-dom-bindings: a second native style Block allocation site since 2026-09-23. - codegen-size: the server runtime's lazy streamed-signals chunk since 2026-09-16. - recursive-context: counted a pure-call annotation and trailing newlines as output growth. - Rebaselined, with numbers in each note: five cross-framework bundle-size ratios and the workerd script-size ratio. The absolute app and server-render budgets are now the ratchet. Lynx's no-worklet byte caps from 2026-08-17 are reset to measured + 32, with the background program pinned exactly. - Fix pending, with dated waivers that expire 2026-10-24, each with an owner task: - three exact counters the revived harnesses exposed (one extra closure per ssrTry, 128 live text reads per 128 unchanged compiled updates, compiled output at 1.295x its source); - Lynx create ratios and the re-entrant transport gate; - superlinear hydrate boundary preparation; - Octane Three versus R3F size and frame dispatch; - two timing regressions near the timer floor; - ten quick-mode timing guards whose samples are noise-bound; - the scoped descriptor shape change. - bench.mjs supports a guard `waiver` ({ reason, expires }). A waived breach prints and does not fail, and fails again once the date passes. HARNESS_FAILURE_ALLOWLIST now also covers a suite whose harness writes no numbers. The budget breaches (57) clear when the budget reset lands. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): pair and lengthen the timing samples behind waived ratio guards Twelve timing guards breached in weekly quick runs without a verdict. Their samples sat near Chromium's 100 µs clock or under two-sample noise, and each target ran its whole block minutes after the other side of its guard. - benchmarks/lib/paired.mjs: rotating per-round visit order and a ~20 ms sample calibration shared by the harnesses below. - js-framework-reorder, memo-wall, svg-dashboard, spa-navigation: every target's page stays open in one browser and each sample round visits all targets; short ops repeat until a sample takes about 20 ms (clicks, hook invocations, op batches, and summed navigation legs). - activity caught-reveal: a sample reveals several independent hidden roots in one window, with the small case revealing eight times as many roots so both cases do equal work; the cases alternate per round. - ssr-workerd: an untimed priming spawn per target, then paired cold-spawn rounds; quick mode runs six rounds instead of two. - bench.yml: a `suites` dispatch input to run selected suites. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): collect garbage before every timed spa-navigation leg The untimed return leg mounts a whole route, and its collection landed inside the next timed teardown: nav_teardown samples ran at 17-45% rme. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): re-judge the twelve waived timing guards with paired samples Two quick CI runs of the paired, ~20 ms harness and same-runner A/B runs against the commits that set each guard decided every waiver: - Passing, waiver removed: activity reports, ssr-workerd cold_spawn_to_first_byte, svg-dashboard pan_zoom, memo-wall parent_rerender_equal_A and octane-jsx mount, spa-navigation nav_teardown and nav_mount (no Octane change since #674 on one runner). - Rebaselined: svg-dashboard icon_swap 1.2 -> 1.6, because #983's esbuild minification made React 15% faster while Octane stayed flat. - Confirmed Octane regressions, waiver kept and pointed at the fix: js-framework-reorder rotateb (1.41x per click since #639), memo-wall one_change_B (1.5x) and ctx_through_wall_B (1.44x), and svg-dashboard tooltip_swarm (1.31x since #635). - The rotateb note claimed React moves every survivor; it moves one. A new rotatef guard covers the LIS-vs-lastPlacedIndex differentiator (0.043x). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): rebaseline spa-navigation nav_mount to its CI baseline The 1.2 ceiling came from a local 0.94x reading. On CI runners #674 itself measures 1.15x and head 1.09-1.16x, so the ceiling left 3% of quick-mode headroom; 1.35 keeps a margin while still catching per-node mount growth. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): drop the three weekly waivers that now have fix PRs The waived guards now have owner PRs: ssr-final-replay try_closures (#1644), root-transactions equal_reads (#1643) and codegen-size gzip compiled/source (#1645). #1645 rebaselines the same codegen-size entry, so this branch no longer edits it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): leave lynx-render to its owner fix The lynx-render transport gate failure and the create_1k/create_10k ratio breaches both trace to #885's JSON-encoded transport and now have an owner fix. Its branch re-notes those two guards, so this branch drops their waivers and the suite's allowlist entry instead of editing the same entries. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): keep harness failures unwaivable and leave descriptor shapes to their owner Waiving a suite that throws before it writes numbers would hide any crash in that suite, not only the known shape change, and skip all of its guards. The scoped-descriptor-shapes defect has an owner fix in progress. That fix re-pins the harness's expected keys, so narrowing the waiver here would edit the same assertion. HARNESS_FAILURE_ALLOWLIST is empty again, and a thrown suite failure always fails the job. Dated waivers remain only on individual ratio guards. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci(bench): leave the Three guards to their owner fixes three-renderer frame_1k_subscribers and the two three-bundle-size ratios have owner PRs (#1651, #1652) that re-note and ratchet those entries, so this branch drops their waivers instead of editing the same entries. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): point the four kept timing waivers at their attributed fixes rotateb and ctx_through_wall_B clear with #1655 and #1656; one_change_B's per-row remainder and tooltip_swarm's scoped-descriptor accessor reads each have their own fix task. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(benchmarks): point parent_rerender_equal_A's note at its per-commit journal fix Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mounting rows that have event handlers no longer does weak-map bookkeeping. This was the #1069 cost behind the js-framework-reorder 100-row insert regressions and part of the memo-wall context-refresh regression.
.tsrxmodule with prop-bound holes (it emitsenableSignalBindings(1, true)). In such a module, every native handler recorded its signal authority inSIGNAL_EVENT_OWNERS(aWeakMap<Element, owner>) and marked its scope as escaped inSCOPE_SIGNAL_OWNERS. Every mounted row paid two weak-map insertions, even with no signals in use. The authority now lives in a$$signalOwnerproperty beside the host's handler slots ($$click,$$eventOwner). It is journaled and rolled back as before, now with aJOURNAL_EVENT_OWNER (el, previous)entry. The escape mark is a declaredsignalTokenEscapedfield onScopeImpl/BlockImpl, with the same retirement truth table as the oldfalseentry.bindSignalTextwrites a scalar over the Text it already owns withsetTextdirectly, instead of going throughbindDirectSignal → policy.write → writeDirectSignalText.setTextstill journals the text and the binding bag. Every compiled text-hole update in such a module runs this path, including memo-wall's 1,000 context leaves.Why
Same-runner paired A/B (Bench workflow, scratch branch, every build served at once,
run-reorder.mjs/memo-wall/run.mjspaired harness from #1646):Runs 37111170608 and 37112063521. The 100-row inserts return to their pre-#1069 cost. Attribution: precise-call coverage plus
WeakMap.prototype.setcounts. On main, prepend100 makes 300 weak-map insertions; with this PR it makes 0. In a CPU profile of prepend100 on main,setEventHandlerself time was about 30% of JS time.The remaining ctx_through_wall gap comes from #833's per-leaf text journal. That is handled separately in the #833 keyed-journal PR.
Final paired runs (this head and with #1656)
Runs 37114023279 and 37114031982, same runner, 15 paired rounds. Each cell gives the two runs, in ms.
ctx_through_wall_B against React (guard 0.85): main 0.83 / 0.88, this PR 0.73 / 0.82, with #1656 0.73 / 0.81.
Validation
event-signal-owner-retirement.test.ts: when an inner handler deletes the outer component, the outer component's queued bubble handler still runs under that component's (now retired) authority. It neither falls back to the document owner nor mints instance state. It passes on main's runtime and on this branch. It fails when dispatch stops reading the host's recorded owner.JOURNAL_EVENT_OWNERrollback fails 10+event-signal-owner.test.tscases.setTextfails 20 binding tests.nodeValuewrite fails 17differential/suspense-timingroot-hold cases.signal-dom-bindings/event-owners.mjscounts weak-map insertions per mounted row and per inserted row. It reads 2 and 2 on main and 0 and 0 here, againstmaxRatio: 0, with dispatch and survivor-identity controls.node benchmarks/bench.mjs signal-dom-bindings --quick --ratiosreports both guards passing. The suite's existingrun-dom-bindings.mjscurrently fails a source-site assertion on main; ci(bench): triage the weekly ratio-guard breaches so new ones show #1641 fixes it.--project octane):event-signal-owner,event-signal-owner-retirement,stable-event-authority,differential/suspense-timing,hydration/direct-signal-bindings,retired-event-hosts: 579 passed.--project octane-signals: six event-related signals files, 138 passed.pnpm typecheck:fileson the changed source and tests;pnpm format:files;pnpm sync.pnpm test,pnpm typecheck,pnpm format:check: left to CI (many parallel local sessions).Risk / follow-ups
$$expando, beside$$clickand$$eventOwner.false-entry semantics exactly.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes how event handlers bind to signal authority and scope retirement during delegated dispatch and transaction rollback; behavior is heavily tested but touches core runtime event/signal integration.
Overview
Event signal authority no longer uses per-row
WeakMapinsertions in modules that may receive signal handles. Each host now stores its handler’s authority on$$signalOwner, with rollback via updatedJOURNAL_EVENT_OWNERentries; scopes that published authority are marked withsignalTokenEscapedinstead of a weak-mapfalsesentinel. Delegated dispatch and staged publication read/write that host field the same way they previously used the map.Scalar text updates in those modules take a fast path: when the hole already owns a
Textnode and the value isn’t a signal handle,bindSignalTextcallssetTextdirectly (still journaled) instead of routing through the full signal-binding write path.Benchmarks and tests add weak-map write guards for keyed rows with click handlers (
event-owners.mjs), retarget stable-event-authority counting to$$signalOwner, and add a retirement case where a queued bubble handler after inner delete must not revive instance state for the removed component.Reviewed by Cursor Bugbot for commit e1625ed. Bugbot is set up for automated code reviews on this repo. Configure here.