Repository navigation
perf(octane): signal-instance identity + dormant-owner fast paths - #1216
Merged
Merged
Conversation
1 task done
jonkwheeler
marked this pull request as ready for review
September 21, 2026 13:54
This was referenced Sep 21, 2026
Contributor
Author
6 of 7 tasks
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.
Part of #1202. Split from #1188.
Summary
SCOPE_SIGNAL_INSTANCE_KEYSWeakMaponto five fields onScope/Block/LiteBlockImpl(signalInstanceParent,signalInstanceSite,signalInstanceValue,signalInstanceHasKey,signalInstanceResolved);stampSignalInstanceKey/stampSignalInstancewrite them, andresolveSignalInstanceKeyresolves the recipe lazily with last-writer-wins semantics.componentSlotLitenow resolves the scope's signal owner inline and only allocates therunWithSignalOwnerclosure when the owner actually changes — the common same-owner mount calls the component body directly.renderBlockInnerskips bookkeeping whose own predicate would early-return anyway on dormant blocks:recordCapturedRenderis skipped unless the capture is a non-root-transaction capture, andfinishEffectRenderonly runs onceeffectSlotsis populated.drainEffectEventUpdatesreplaces the hidden-subtree drop with parked publication: an Effect Event update queued under a hidden Suspense boundary defers to the boundary's reveal action (version-guarded), while a rolled-back render's payload still never publishes.Why
WeakMapentry on every mount; the field form costs five stores and keeps the recipe lifetime-stable with the scope itself. Scalar-only components still never pay ancestor walks, visited sets, key coercion, or JSON strings — resolution stays lazy.componentSlotLiteis the lite-component mount path; wrapping every signal-document mount in a closure just to switch owners taxed the most common case (owner unchanged) with an allocation per mount.Changes
packages/octane/src/runtime.ts:Scopeinterface +ScopeImpl/BlockImpl/LiteBlockImplgain thesignalInstance*fields (LiteBlockImplcarries them null for the polymorphicscope.blockwalk);SCOPE_SIGNAL_INSTANCE_KEYSdeleted;stampSignalInstanceKeyadded;resolveSignalInstanceKey,stampSignalInstance,componentSlotLite,renderBlockInner,drainEffectEventUpdatesrewritten as above;componentSlotImpl(×2),renderOffscreen,childSlot(×2) stamp viastampSignalInstanceKey.packages/octane/tests/render-block-dormant.test.ts(new): pins the dormant-path contract from the consumer side — a state-only component re-renders correctly, and a block that arms mid-lifecycle (firstuseEffect, firstuse()suspension, first context read, first transition) takes the full path from that render on..changeset/proud-scopes-drift.md:'octane': patch.Validation
pnpm format:files:checkon touched paths — clean.pnpm typecheck:fileson touched paths — clean.vitest run packages/octane/tests/render-block-dormant.test.ts— 10 tests pass across theoctaneandoctane-prodprojects.vitest run packages/octane/tests/signals-dom-bindings.test.ts packages/octane/tests/components.test.ts— 125 tests pass across all signal/component project shards.pnpm syncleaves the tree clean (no generated output).pnpm format:check,pnpm typecheck,pnpm test— deferred to CI per repo convention.main@8a4a2e087(20 iters; <1 = faster) — nav_teardown 0.9→0.7 ms (0.78x), nav_mount 2.2→2.0 (0.83x), nav_deep 2.7→2.4 (0.88x), nav_deep_6x 17.3→14.6 (0.89x); nav_nested ~flat. DOM census identical (2052/1025/1); reuse ratio 0.104 vs main 0.087 (both far above the ~0.03 ideal, unchanged in kind)run-minimal.mjscaptured all listed scenario sizes before stopping at the pre-existingbinding-aria-esbuildfailure (known unrelated esbuild issue flagged on perf(runtime): beat React 19 + Compiler across the timing benchmark portfolio #1188).Risk / follow-ups
Scope/Blockshape so the structural walk stays polymorphic-safe.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Changes core render, signal identity, and Suspense Effect Event commit paths; semantics are intended to be equivalent but the hidden-boundary parking and dormant guards are subtle.
Overview
Octane runtime performance and correctness tweaks around signal identity, lite mounts, dormant renders, and Effect Events under hidden Suspense.
Signal-instance identity no longer uses a per-scope
WeakMap; recipe and resolved keys live on fivesignalInstance*fields onScope,Block, andLiteBlockImpl, withstampSignalInstanceKey/ lazyresolveSignalInstanceKeypreserving last-writer-wins semantics.Lite component mounts (
componentSlotLite) inline signal-owner resolution and only wrap the body inrunWithSignalOwnerwhen the owner differs from the current one, avoiding a per-mount closure on the common path.Dormant block renders skip work that would no-op anyway:
recordCapturedRenderis omitted for root-transaction captures, andfinishEffectRenderruns only aftereffectSlotsis non-null so the firstuseEffecton a render still arms the full path.Effect Event draining no longer drops updates for subtrees hidden by Suspense; they are parked on the boundary via
deferHiddenRevealActionand applied at reveal (with version guards), while rolled-back renders still cannot publish stale impls. New tests inrender-block-dormant.test.tslock dormant vs mid-lifecycle arming behavior for state, effects,use(), context, and transitions.Reviewed by Cursor Bugbot for commit d898df6. Bugbot is set up for automated code reviews on this repo. Configure here.