Repository navigation
perf(octane): lower memo hooks to closure-free caches - #788
Merged
domgan-oai merged 2 commits intoAug 19, 2026
Merged
Conversation
trueadm
marked this pull request as ready for review
August 19, 2026 11:07
Merged
2 of 5 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
() => callbackallocation on client, server, and universal paths. Keep the new compiler/runtime ABI private, with fixed-arity flat publishers to avoid adding ordinary miss-side rest arrays.Performance evidence
Fresh paired runs against upstream base
922b2d46ereproduce the original pinned-baseline results:The candidate passes all 12 guards; the base breaches seven. These are source-creation counts, not V8 heap bytes or a browser-latency claim. Bundle cost is +464 gzip bytes (+1.05%) for this corpus. The recorded hookless compiler-throughput control emitted 18 byte-identical outputs; its timing spread includes parity.
Benchmark methodology and source hashes · Design and safety boundaries
Validation
pnpm sync— completed on the rebased tree; no generated changes remained. Used the available cached dependencies withpnpm_config_verify_deps_before_run=warn.pnpm format:check— repo-wide check not run; scoped Prettier check passed for all 33 non-ignored changed files, andgit diff --checkpassed.pnpm typecheck— repo-wide check not run;tsgo --noEmit -p packages/octane/tsconfig.jsonandtsgo --noEmit -p packages/octane/typetests/tsconfig.jsonpassed. The added hooks/transition fixtures introduce zero diagnostics relative to their baseline.pnpm test— normal locked-toolchain run remains unavailable because dependency installation returned registry 403.node benchmarks/bench.mjs --ratios hook-memowith the same documented fallback loader for both sides — 12/12 pass; baseline negative control fails seven. Observer tests: 2/2 pass.Fallback toolchain: Node 26.4.0,
@tsrx/core0.1.56, esrap 2.3.0, esbuild 0.28.1. The ten remaining test failures are four known Volar/core-version mismatches, three installed-binding discovery failures, and three native compiler-registration failures. The imperative-DOM differential fixture, production-profile bundle, and React-hosted web3 suites cannot load because the fallback setup lacks their generated fixture/native parser/workspace dependencies. These are not claimed green.Risk / follow-ups
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
High Risk
Touches core compiler output, client hook runtime, and transition memo journaling; incorrect lowering could change identities, TDZ, or held-transition behavior despite broad tests and benchmarks.
Overview
Production client compilation now lowers more
useMemo/useCallbacksites to closure-free inline caches instead of per-render factory arrows and dependency arrays. Eligible cache hits skip evaluating the factory and skip creating dependency-array literals;useCallbackonly materializes its function on a miss. Coverage expands beyond flat declarations to nested expressions, returned JSX, custom hooks, plain.ts/.jshook modules, and explicit third-slot calls, with unsafe shapes still on the runtime hook path.The compiler adds a path-aware post-slot pass (
inline-hook-memo.js,plain-hook-memo.js) for helpers and explicit slots, plus flat per-body_k$Ncaches for render-local sites. Runtime gains private helpers (hookMemoPublish*,memoTake*/memoPublish*,hookMemoCreate,hookMemoEqual) and stores callback values directly—no extra() => fnwrapper. Held-transition rollback/promotion journals inline memo cell ranges alongside hook-map entries.A new
hook-memobenchmark (fixtures, post-tree-shake allocation observer, 12 ratio guards) and MCPoctane_benchmarklisting document the allocation and gzip tradeoffs (~+1% bundle gzip in the recorded corpus).Reviewed by Cursor Bugbot for commit dee05bb. Bugbot is set up for automated code reviews on this repo. Configure here.