Repository navigation
perf: avoid nested universal hook slot arrays - #1026
Merged
domgan-oai merged 3 commits intoSep 10, 2026
Merged
domgan-oai merged 3 commits into
domgan-oai merged 3 commits into
Conversation
domgan-oai
marked this pull request as ready for review
September 10, 2026 09:38
Closed
68 of 84 tasks
14 of 21 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.
Summary
Symbol.forbehavior.Why
Issue #981 identified temporary arrays in the universal hook-slot path. The direct-hook fast path is unchanged; nested hooks previously evaluated one array literal per lookup.
Validation
pnpm format:check(scopedpnpm format:files:checkpassed for all changed files)pnpm typecheckpnpm test(not run as one local command; the full sharded suite passed in current-head CI)294f6b0cf.node benchmarks/bench.mjs --quick universal-hook-slot --ratios(its zero-array assertion passed; no ratio guards selected for this new suite).621147d01: at 128 nested owners, 1,024 → 0 resolver array events on mount, changed-prop update, state update, and keyed reorder; total runtime array events fell by exactly 1,024 in each phase. Direct hooks, setup, and teardown were unchanged, with matching output and hook-call counts.Risk / follow-ups
Symbol.foron every lookup. That remaining part of Track V8 performance audit findings across runtime, SSR, universal core, and compiler output #981 stays open.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches the production universal hook-slot resolver on every nested hook call; behavior is guarded by new tests and a zero-array benchmark gate.
Overview
resolveHookSlotno longer builds[...UNIVERSAL_SLOT_STACK, own]on nested lookups; it walks the captured stack depth with an indexed loop and the same string/Symbol.forencoding, leaving the direct (empty-stack) fast path unchanged.A new
universal-hook-slotNode benchmark (wired intobench.mjs, docs, and the MCP suite list) production-bundles the runtime, instrumentsresolveHookSlot, and fails unless resolver array-creation events are zero across mount, prop/state updates, reorder, and unmount for direct vs doubly nestedwithSlotworkloads.universal-manual-hook-context.test.tsadds a regression for nested sibling hook state/refs through reorder, reentrant slot coercion, a failed render, retry, and teardown.Reviewed by Cursor Bugbot for commit 294f6b0. Bugbot is set up for automated code reviews on this repo. Configure here.