Repository navigation
perf: skip stable hookful child call sites - #685
Merged
domgan-oai merged 1 commit intoAug 10, 2026
Merged
domgan-oai merged 1 commit into
domgan-oai merged 1 commit into
Conversation
domgan-oai
marked this pull request as ready for review
August 10, 2026 14:04
95 tasks done
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
Refs #673
Why
The existing same-module memoization proof treated any hookful descendant as unsafe. Consequently, updating one counter in a 100-component chain rerendered additional blocks and traversed up to 91 otherwise unchanged child slots even though the DOM required only one text update.
Module-level setter publication prevents a simple purity shortcut: another mounted root can own the same publication target, so an unchanged-props bailout must detect when that owner changed and rerun the original subtree.
Changes
useStatecalls, simple immutable initializers, ordinary props, synchronous component trees, and uniquely written private setter bindings.Performance
The paired minified production sweep improved from approximately 0.020 ms to 0.004 ms (5×), with both batch orders improving from 0.008 ms to 0.004 ms (2×). Sub-millisecond timing is quantized, so deterministic work counts are the acceptance signal. Mount retains exactly 19 blocks, 18 full slots, and 82 lightweight slots; teardown, JSX output/work, and the fixed 16-file compiler corpus remain unchanged.
Validation
pnpm --config.verify-deps-before-run=false syncpnpm --config.verify-deps-before-run=false format:files:checkon all changed files.pnpm --config.verify-deps-before-run=false --config.enable-pre-post-scripts=false run typecheck— full workspace TypeScript body; unrelated optional pretypecheck disabled.pnpm --config.verify-deps-before-run=false exec vitest run --project octane --project octane-prod --silent=passed-only— 804 files / 11,699 tests passed.Risk / follow-ups
Provenance
agent-authored)Note
Medium Risk
Compiler-only optimization with strict static proofs, but it changes render/skip semantics for hookful trees and relies on publication-witness correctness across roots and hydration—high impact if the proof is wrong, mitigated by extensive tests and unchanged behavior for unproven shapes.
Overview
Adds a production-only TSRX compiler path that memoizes same-module child component calls when a hook-owning parent re-renders with unchanged props, so deep chains no longer walk every descendant slot—only the stateful owner’s block runs and one text node updates.
The proof is intentionally narrow: components whose setup is only invariant
useStateplus optional one-time publication of setters into private modulelets.classifyStableHookfulChildCallsmarks eligible callees, propagates publication witnesses, and wires call sites through the existing auto-memo machinery—often via_$componentSlotLite—with post-render snapshots of setter bindings so multi-root publication stays correct.Benchmark
work.mjsgates foroctane-tsrxnow expect zero child slot dispatch on shallow/middle/deep/batched bumps; docs describe TSRX vs unchanged JSX cascade.auto-memo.test.tsadds broad regression coverage (child state, context, effects, stores, Suspense, refs/keys/memo, hydration, proxy/multi-root setters).Reviewed by Cursor Bugbot for commit cdd13cd. Bugbot is set up for automated code reviews on this repo. Configure here.