Repository navigation
perf(octane): memoize through plain-callee projections; skip the de-opt key serializer - #262
Conversation
…y serializer
Two independent findings from a benchmark audit of the suites where Octane
trailed the fine-grained frameworks.
**autoMemo gave up on any call in a template.** `containsRenderCall` vetoed
every CallExpression in render-value position, gating the component's
`autoMemoSafe` flag (which propagates transitively to every ancestor), the
per-item survivor short-circuit, and the whole-list region cache. One
`{formatDate(d)}` therefore removed region memoization from a component and
everything that rendered it. The veto exists for `header.column.getIsSorted()`
— mutable state read through an object whose identity no dep witnesses — and
that hazard is carried by the RECEIVER, so only the member-callee shape needs
to fail closed. Hook-shaped callees (`use`, `use*`) stay disqualified: they own
suspension, hook cells, context subscriptions, and effect lifecycles, which the
blanket veto was incidentally covering.
Same-module `function` helpers that are never reassigned are now accepted as
memo-region witnesses, on the immutable-identity grounds already given to
same-module components and `const X = memo(C)` walls.
**De-opt child keys serialized on every render.** `scopedDeoptKey` built every
child's reconciliation key with `JSON.stringify`, including at the unwrapped top
level that every `{items.map(...)}` and every binding's output produces — 1,000
serialized strings per parent update on a 1,000-row list, even when all rows
bailed. Nested wrapper paths keep the serialized encoding; both aliasing
properties it provides are preserved by the 'k'/'i' prefixes.
Paired benchmark runs, same machine, baseline = this branch's base:
chat-stream type160 2.22ms -> 0.78ms (-65%)
chat-stream appendHistory 1.56ms -> 0.72ms (-54%)
chat-stream streamCoarse 0.78ms -> 0.46ms (-41%)
chat-stream streamFine 1.58ms -> 0.96ms (-39%)
chat-stream switchConv 4.08ms -> 3.56ms (-13%)
type160 moves Octane from the slowest of the fast frameworks to ahead of Solid,
Ripple, and Vue Vapor. js-framework, effectful-list, and memo-wall show no
regression; memo-wall's value-position wall improves from 1.48x to 1.39x React
(a Chromium profile of that op drops the flatten step 13.4% -> 6.0% of samples,
total samples -13.8%).
Full suite: 1310 files / 12835 tests. Three prod-only failures found during
development were real and are fixed in this diff: an ineligible same-module
component must not be rescued as a plain helper, and hook calls must not be
treated as value projections.
Co-Authored-By: Claude Opus 5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Local callees bypass member veto
- Added collectSurfaceDeclaredNames helper to collect locally-declared names from the walked scope and exclude them from plainCalleeIsMemoizable's plain-callee pass-through, so local identifiers wrapping member calls (e.g., const read = () => item.read(); read()) now correctly fail closed.
- ✅ Fixed: Callsites ignore module helpers
- Added the missing ctx.moduleFunctionBindings?.has(name) check to the autoMemoCallsitesSafe free-identifier loop so same-module function helpers no longer force the flag false and block child callsite memoization.
Or push these changes by commenting:
@cursor push e65452707f
Preview (e65452707f)
diff --git a/packages/octane/src/compiler/compile.js b/packages/octane/src/compiler/compile.js
--- a/packages/octane/src/compiler/compile.js
+++ b/packages/octane/src/compiler/compile.js
@@ -2633,6 +2633,7 @@ function containsAutoMemoContextRead(root, ctx) {
* other than memo staleness (SSR item identity) must leave it off.
*/
function containsRenderCall(stmts, allowPlainCallee = false) {
+ const localNames = allowPlainCallee ? collectSurfaceDeclaredNames(stmts) : null;
let found = false;
const seen = new WeakSet();
function walk(n) {
@@ -2633,6 +2633,7 @@ function containsAutoMemoContextRead(root, ctx) {
* other than memo staleness (SSR item identity) must leave it off.
*/
function containsRenderCall(stmts, allowPlainCallee = false) {
+ const localNames = allowPlainCallee ? collectSurfaceDeclaredNames(stmts) : null;
let found = false;
const seen = new WeakSet();
function walk(n) {
@@ -2659,7 +2660,7 @@ function containsRenderCall(stmts, allowPlainCallee = false) {
t === 'NewExpression' ||
t === 'TaggedTemplateExpression'
) {
- if (allowPlainCallee && plainCalleeIsMemoizable(n)) {
+ if (allowPlainCallee && plainCalleeIsMemoizable(n, localNames)) {
// The callee itself is a witnessed binding; its ARGUMENTS still carry
// the render-value contract, so `fmt(row.get())` stays disqualified.
walk(n.arguments);
@@ -2659,7 +2660,7 @@ function containsRenderCall(stmts, allowPlainCallee = false) {
t === 'NewExpression' ||
t === 'TaggedTemplateExpression'
) {
- if (allowPlainCallee && plainCalleeIsMemoizable(n)) {
+ if (allowPlainCallee && plainCalleeIsMemoizable(n, localNames)) {
// The callee itself is a witnessed binding; its ARGUMENTS still carry
// the render-value contract, so `fmt(row.get())` stays disqualified.
walk(n.arguments);
@@ -2715,11 +2716,48 @@ function isHookCalleeName(name) {
* and React Compiler key on, and it is what the blanket call veto was
* incidentally covering here.
*/
-function plainCalleeIsMemoizable(node) {
+function plainCalleeIsMemoizable(node, localNames) {
if (node.type !== 'CallExpression' && node.type !== 'OptionalCallExpression') return false;
const callee = node.callee;
if (callee?.type !== 'Identifier') return false;
- return !isHookCalleeName(callee.name);
+ if (isHookCalleeName(callee.name)) return false;
+ if (localNames?.has(callee.name)) return false;
+ return true;
+}
+
+/**
+ * Collect names declared at the surface level of `stmts`, matching the walk
+ * boundary of `containsRenderCall` (function bodies are NOT entered).
+ * Locally-declared callees can wrap opaque member calls through closures
+ * (`const read = () => item.read(); read()`) and must not be treated as the
+ * free module-level or imported identifiers `plainCalleeIsMemoizable` admits.
+ */
+function collectSurfaceDeclaredNames(stmts) {
+ const names = new Set();
+ const seen = new WeakSet();
+ function walk(n) {
+ if (!n || typeof n !== 'object') return;
+ if (Array.isArray(n)) {
+ for (const x of n) walk(x);
+ return;
+ }
+ const t = n.type;
+ if (!t) return;
+ if (seen.has(n)) return;
+ seen.add(n);
+ if (t === 'ArrowFunctionExpression' || t === 'FunctionExpression') return;
+ if (t === 'FunctionDeclaration') {
+ if (n.id?.type === 'Identifier') names.add(n.id.name);
+ return;
+ }
+ if (t === 'VariableDeclarator') collectPatternNames(n.id, names);
+ for (const key in n) {
+ if (AST_WALK_SKIP_KEYS.has(key)) continue;
+ walk(n[key]);
+ }
+ }
+ for (const s of stmts) walk(s);
+ return names;
}
/**
@@ -2715,11 +2716,48 @@ function isHookCalleeName(name) {
* and React Compiler key on, and it is what the blanket call veto was
* incidentally covering here.
*/
-function plainCalleeIsMemoizable(node) {
+function plainCalleeIsMemoizable(node, localNames) {
if (node.type !== 'CallExpression' && node.type !== 'OptionalCallExpression') return false;
const callee = node.callee;
if (callee?.type !== 'Identifier') return false;
- return !isHookCalleeName(callee.name);
+ if (isHookCalleeName(callee.name)) return false;
+ if (localNames?.has(callee.name)) return false;
+ return true;
+}
+
+/**
+ * Collect names declared at the surface level of `stmts`, matching the walk
+ * boundary of `containsRenderCall` (function bodies are NOT entered).
+ * Locally-declared callees can wrap opaque member calls through closures
+ * (`const read = () => item.read(); read()`) and must not be treated as the
+ * free module-level or imported identifiers `plainCalleeIsMemoizable` admits.
+ */
+function collectSurfaceDeclaredNames(stmts) {
+ const names = new Set();
+ const seen = new WeakSet();
+ function walk(n) {
+ if (!n || typeof n !== 'object') return;
+ if (Array.isArray(n)) {
+ for (const x of n) walk(x);
+ return;
+ }
+ const t = n.type;
+ if (!t) return;
+ if (seen.has(n)) return;
+ seen.add(n);
+ if (t === 'ArrowFunctionExpression' || t === 'FunctionExpression') return;
+ if (t === 'FunctionDeclaration') {
+ if (n.id?.type === 'Identifier') names.add(n.id.name);
+ return;
+ }
+ if (t === 'VariableDeclarator') collectPatternNames(n.id, names);
+ for (const key in n) {
+ if (AST_WALK_SKIP_KEYS.has(key)) continue;
+ walk(n[key]);
+ }
+ }
+ for (const s of stmts) walk(s);
+ return names;
}
/**
@@ -5291,7 +5329,8 @@ function compileInternal(source, filename, options, analyzedAst, mode, bundlerMe
ctx.importNamespaceNames.has(name) ||
(!ctx.importedNames.has(name) &&
!ctx.defaultMemoBindings.has(name) &&
- !ctx.componentInfo.has(name))
+ !ctx.componentInfo.has(name) &&
+ !ctx.moduleFunctionBindings?.has(name))
) {
autoMemoCallsitesSafe = false;
break;
@@ -5291,7 +5329,8 @@ function compileInternal(source, filename, options, analyzedAst, mode, bundlerMe
ctx.importNamespaceNames.has(name) ||
(!ctx.importedNames.has(name) &&
!ctx.defaultMemoBindings.has(name) &&
- !ctx.componentInfo.has(name))
+ !ctx.componentInfo.has(name) &&
+ !ctx.moduleFunctionBindings?.has(name))
) {
autoMemoCallsitesSafe = false;
break;You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 72b5bbb. Configure here.
…cover the boundary Addresses both Cursor Bugbot findings on #262 and adds the behavioral coverage the first commit was missing. **Bugbot #1 (high) — local callees bypassed the member veto.** `plainCalleeIsMemoizable` admitted any non-hook `Identifier` callee, but the contract it documented only covers module-scope immutable bindings. A local `const read = () => item.read()` — or a module helper `function sortIcon(h) { return h.getIsSorted(); }` — wraps the exact receiver hazard the change kept failing closed, and the inline hook-memo tier can hand a local a stable identity. A call is now admitted only when the callee is: - an imported binding (opaque module boundary, the one place this analysis trusts rather than proves — React Compiler assumes the same), or - a same-module `function` declaration that is never reassigned AND whose own body is a value projection, checked transitively with cycles failing closed. Component-local callees, unbound globals, and namespace members now fail closed. **Bugbot #2 (medium) — call sites ignored module helpers.** `autoMemoCallsitesSafe` still treated free same-module `function` helpers as opaque while every other classifier accepted them, so a parent that formatted through a helper blocked child call-site memoization. **Coverage.** Two new behavioral suites, 30 tests: `automemo-render-calls.test.ts` renders lists whose array identity and item objects never change while state moves behind an accessor — a wrongly memoized region freezes the output. It covers the member callee, a module helper wrapping one, the same two frames away, component-local arrow / stable-local / function declaration callees, a reassigned module function, and a live accessor in an ARGUMENT to an otherwise-admitted projection; the converse (module, transitive and imported projections stay reactive); hook callees; a context consumer under a memoizable region; and the newly unblocked call-site path. `deopt-child-key-aliasing.test.ts` covers the key encoding through a template HOLE — raw `createElement` host children reconcile through a different keying function, so the first attempt at these tests exercised the wrong path and could not fail. Asserts explicit keys never alias positional indices (both in one list), adversarial keys that resemble serialized wrapper paths, equal keys under different wrappers, keyed-fragment reorder, unkeyed wrappers staying positional, and mixed keyed/unkeyed lists. Both suites were validated against deliberately broken implementations: the pre-fix callee rule fails 5 of the 7 staleness cases, and dropping the key/index prefix, sharing a prefix, ignoring explicit keys, or dropping the wrapper path each fail 1-3 of the key cases. The restored implementation passes. chat-stream codegen is byte-identical to the build the benchmark numbers were measured on, so the reported figures still stand. Full suite: 1332 files / 12958 tests. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Both Bugbot findings addressed in c542bb5, along with the behavioral coverage the first commit was missing. #1 (high) — local callees bypass member vetoCorrect, and worse than the example: a module helper A call is now admitted only when the callee is a module-scope immutable identity:
Component-local callees, unbound globals, and namespace members now fail closed. #2 (medium) — callsites ignore module helpersFixed: CoverageTwo new behavioral suites, 30 tests.
Both suites were validated against broken implementations rather than assumed to work:
The two staleness cases that don't fail against the pre-fix rule (direct member call, local function declaration) were already vetoed by other gates; they're kept as guards. chat-stream codegen is byte-identical to the build the benchmark numbers were measured on, so the reported figures stand unchanged. Full suite: 1332 files / 12958 tests. |
… render-read scan Addresses the CI failure and the Bugbot finding on #297, and corrects measurement claims that did not survive checking. **CI: examples/pulseboard, virtualized list frozen mid-scroll.** The pass cached `const virtualItems = virtualizer.getVirtualItems()` on `[virtualizer]`, whose identity is stable while its window moves with scroll — the receiver hazard #262 vetoes for regions, in another costume. Calculations are now admitted on exactly that rule (plainCalleeIsMemoizable via containsRenderCall), so a member call fails closed whether or not the author named its result. One contract, both paths; the asymmetry section added to differences-from-react.md is removed because there is no longer an asymmetry to document. The cost is real and stated: `const visible = todos.filter(...)` is no longer cached. `todos` genuinely is an immutable snapshot, but this analysis cannot yet tell that from a live object, so it fails closed on both. Recovering it needs receiver provenance and is follow-up, not a bolt-on. **Bugbot (medium): render-read scan over-nominated names.** `seedRenderReads` treated every unbound Identifier in the JSX walk as a render consumer, including non-computed MemberExpression PROPERTIES (`row.length` nominated a local named `length`) and names read inside nested function bodies (handler-only locals). Both contradicted the documented "values the render tree never reads pay nothing". The walk now stops seeding inside function values — which run at invoke time, not while the template renders — and reads only the object side of a non-computed member expression. use()-argument seeding is unaffected: it still descends into function values, and a non-computed property is an Identifier by construction so it cannot hide a use() call. **Corrected measurements.** The previous body credited this change with chat-stream and todomvc wins. Both compile BYTE-IDENTICALLY with and without the pass — verified by diffing their output — so those numbers were run-to-run variance, not results. With the narrowed rule the attributable win is memo-wall alone: parent_rerender_equal_B 0.226ms -> 0.091ms (-60%) one_change_B 0.235ms -> 0.156ms (-34%) ctx_through_wall_B 0.569ms -> 0.413ms (-27%) todomvc, chat-stream and js-framework are now all byte-identical controls; their movement (up to +-100% on sub-millisecond ops) is this machine's noise floor. Size cost drops with the narrower rule: +0.07% gzip, was +0.25%. **Tests.** The identity fixture now uses an imported projection (the admitted shape). New `LiveReceiverCalculation` covers the pulseboard regression: a state-held object with stable identity whose method answer changes must re-read on every render. Re-admitting member calls fails it. examples/pulseboard e2e: 7/7 pass locally (CI had 1 failing). Full suite: 1376 files / 13717 tests. Co-Authored-By: Claude Opus 5 <[email protected]>
* wip(octane): auto-calculation memoization via the Tier A inline cache Lowers a derived `const X = <expr containing a render-time call>` to `useMemo(() => <expr>, [deps])` so its identity is stable while its inputs are. An idiomatic `const visible = todos.filter(...)` otherwise allocates a fresh array every render, and every consumer keyed on its identity — an autoMemo region's dependency tuple, a memo() child's prop — misses unconditionally. The region cache is only as good as the stability of what it keys on. Runs after Pass A' (use()-fed chains keep their Symbol-slot treatment) and before Pass A/B, so the minted numeric-slot useMemo is lowered by the authored inline tier (`_k$N`) rather than the Symbol/warm `puTake` path. Client only — a server render evaluates each body once, so a cache is pure overhead. Also broadens the hook naming convention used by creation eligibility from `^use[A-Z]` to `(^|_)use(?:$|[A-Z])`. A prefixed custom hook (`unstable_useRouterState`, mirroring React Router) previously read as an ordinary creation, so the pass wrapped a HOOK CALL in a cache and froze its subscription — caught by the remix-router guards/parity suites. Paired benchmarks vs this branch's base (js-framework is a control: its codegen is byte-identical with and without the pass, and it still moved +-8%, which calibrates the noise floor for the run): chat-stream switchConv 3.92ms -> 1.80ms (-54%) chat-stream streamCoarse 0.56ms -> 0.30ms (-46%) chat-stream streamFine 0.94ms -> 0.66ms (-30%) chat-stream type160 1.22ms -> 1.02ms (-16%) memo-wall parent_B 0.226ms -> 0.109ms (-52%) memo-wall ctx_wall_B 0.569ms -> 0.453ms (-20%) todomvc toggleAllOff 0.24ms -> 0.12ms (-50%) todomvc toggleAllOn 0.24ms -> 0.14ms (-42%) todomvc filterCycle 0.80ms -> 0.46ms (-42%) No op regresses by the repo's own compare rule (>1.15x score AND >1.10x min, plus >0.1ms absolute for sub-1ms ops). Full suite: 1338 files / 13072 tests. NOT READY: still needs the staleness contract documented, dedicated behavioral tests (including the frozen-hook regression), a bundle-size check for the added cells, and a decision on the region/calculation contract asymmetry. Co-Authored-By: Claude Opus 5 <[email protected]> * fix(octane): scope the hook convention to unstable_, and finish auto-calculation Follows the auto-calculation WIP with the pieces it was missing. **unstable_ is enumerated, not pattern-matched.** The WIP broadened hook detection to `(?:^|_)use(?:$|[A-Z])` to catch `unstable_useRouterState`, which is looser than the convention warrants — an ordinary helper could be mistaken for a hook by spelling alone. It is now `^(?:unstable_)?use(?:$|[A-Z])`: React's own staging prefix, which bindings mirror, and nothing else. The region rule's separate `^use[A-Z]` check is folded onto the same constant so both paths agree on what a hook is. Getting this wrong in the permissive direction is not a staleness bug — a cache wrapped around a hook call freezes its state cell and any subscription it owns, which is how the WIP froze @octanejs/remix-router's pending navigation at "(idle)". **Tests.** `auto-calculation.test.ts` covers identity stability across an unrelated re-render, rebuild on a real input change, correctness of a cached reduction and imported projection, both hook-declaration shapes staying live, `let` keeping its reassignment, and a handler-only calculation. Behavioral throughout, and run under both vitest projects so the runtime hook form and the inline flat-cache lowering must agree. Validated against broken implementations: dropping the `unstable_` prefix fails 1 test (the exact bug), removing hook detection entirely fails 2, and disabling the pass fails the 2 identity tests in both projects. The restored implementation passes. **Docs.** A new "Derived values are cached at their declaration" section in docs/differences-from-react.md states the pure-render contract, what is never cached, and — deliberately — that a hoisted `const s = header.getIsSorted()` is cached while the same call inline in a template is not, with the reasoning and the `let` escape hatch. **Size.** +0.25% gzip on the codegen-size corpus (25181 → 25243 bytes). Known, pre-existing: the `codegen-size` gzip ratio guard already breaches on this branch's base (1.07x vs a 1.04x ceiling, measured with the pass disabled and again on the base commit). This change moves it to 1.08x. The guard's recorded numbers no longer match the corpus, so it needs re-recording independently of this work. Full suite: 1369 files / 13680 tests. tsgo and format:check clean. Co-Authored-By: Claude Opus 5 <[email protected]> * fix(octane): admit calculations on the region callee rule; narrow the render-read scan Addresses the CI failure and the Bugbot finding on #297, and corrects measurement claims that did not survive checking. **CI: examples/pulseboard, virtualized list frozen mid-scroll.** The pass cached `const virtualItems = virtualizer.getVirtualItems()` on `[virtualizer]`, whose identity is stable while its window moves with scroll — the receiver hazard #262 vetoes for regions, in another costume. Calculations are now admitted on exactly that rule (plainCalleeIsMemoizable via containsRenderCall), so a member call fails closed whether or not the author named its result. One contract, both paths; the asymmetry section added to differences-from-react.md is removed because there is no longer an asymmetry to document. The cost is real and stated: `const visible = todos.filter(...)` is no longer cached. `todos` genuinely is an immutable snapshot, but this analysis cannot yet tell that from a live object, so it fails closed on both. Recovering it needs receiver provenance and is follow-up, not a bolt-on. **Bugbot (medium): render-read scan over-nominated names.** `seedRenderReads` treated every unbound Identifier in the JSX walk as a render consumer, including non-computed MemberExpression PROPERTIES (`row.length` nominated a local named `length`) and names read inside nested function bodies (handler-only locals). Both contradicted the documented "values the render tree never reads pay nothing". The walk now stops seeding inside function values — which run at invoke time, not while the template renders — and reads only the object side of a non-computed member expression. use()-argument seeding is unaffected: it still descends into function values, and a non-computed property is an Identifier by construction so it cannot hide a use() call. **Corrected measurements.** The previous body credited this change with chat-stream and todomvc wins. Both compile BYTE-IDENTICALLY with and without the pass — verified by diffing their output — so those numbers were run-to-run variance, not results. With the narrowed rule the attributable win is memo-wall alone: parent_rerender_equal_B 0.226ms -> 0.091ms (-60%) one_change_B 0.235ms -> 0.156ms (-34%) ctx_through_wall_B 0.569ms -> 0.413ms (-27%) todomvc, chat-stream and js-framework are now all byte-identical controls; their movement (up to +-100% on sub-millisecond ops) is this machine's noise floor. Size cost drops with the narrower rule: +0.07% gzip, was +0.25%. **Tests.** The identity fixture now uses an imported projection (the admitted shape). New `LiveReceiverCalculation` covers the pulseboard regression: a state-held object with stable identity whose method answer changes must re-read on every render. Re-admitting member calls fails it. examples/pulseboard e2e: 7/7 pass locally (CI had 1 failing). Full suite: 1376 files / 13717 tests. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>


Two independent findings from a benchmark audit of the suites where Octane trailed the fine-grained frameworks (Solid / Ripple / Vue Vapor). Both are conservative-analysis gaps rather than missing machinery.
1. autoMemo gave up on a component because its template contained a call
containsRenderCallvetoed everyCallExpressionin render-value position. It gates three tiers — the component'sautoMemoSafeflag (which propagates transitively to every ancestor that renders it), the per-item survivor short-circuit, and the whole-list region cache. So a single{formatDate(d)}removed region memoization from that component and everything above it.The veto exists for one real hazard:
header.column.getIsSorted()returns a new answer whileheaderstays the memoized object, so nothing in the dependency tuple witnesses the change. That hazard is carried by the receiver, so only the member-callee shape needs to fail closed. A bare identifier callee resolves to a module-local or imported binding the region already tracks — exactly as exposed to mutable module state as the bare identifier read the same region is already permitted to memoize through (the documented DEP-PURE contract intests/_fixtures/for.tsrx).Kept disqualified:
{header.getIsSorted()}. The TanStack Table pattern; bindings that expose live accessor methods keep working unchanged.useanduse*. These own suspension, hook cells, context subscriptions, and effect lifecycles, not value projections. The blanket veto was incidentally covering them.new Foo()and tagged templates — construction isn't a value projection.The SSR item-identity call site (
itemNeedsIdentity) is left strict: it needs "no call executes here" for a different reason than memo staleness, so it takes the unchanged default.Also in this change: same-module
functionhelpers that are never reassigned are accepted as memo-region witnesses, on the immutable-identity grounds already given to same-module components andconst X = memo(C)walls. Reassigned names are excluded (their identity is as mutable as a modulelet).2. De-opt child keys ran
JSON.stringifyper child per renderscopedDeoptKeybuilt every child's reconciliation key withJSON.stringify([path, kind, key]), including at the unwrapped top level that every{items.map(...)}and every@octanejs/*binding's rendered output produces. A 1,000-row list allocated 1,000 serialized strings on every parent update, including updates where all 1,000 rows went on to bail.The path-free level now returns
'k' + key/'i' + index. A JSON encoding always begins with[, so no prefixed key can collide with a nested wrapper path, and the differing prefixes keep an explicitkey="0"distinct from an implicit index 0 — the same two aliasing properties the serialized form provides. Nested wrapper paths keep the serializer.Measurements
Paired runs on one machine, baseline = this branch's merge-base, same command / warmup / iteration policy:
type160appendHistorystreamCoarsestreamFineswitchConvtype160(160 keystrokes through the controlled composer) moves Octane from the slowest of the fast frameworks to ahead of Solid (0.96), Ripple (0.80) and Vue Vapor (0.80).No regressions in
js-framework,effectful-list, ormemo-wall. The memo-wall value-position wall — thecreateElement(Row, props)→ children-hole shape every binding produces — improves from 1.48x to 1.39x React. A Chromium CPU profile of that op drops the flatten step from 13.4% to 6.0% of samples and total samples by 13.8%; the timed op moves far less than that profile implies, and the changeset states both numbers rather than the flattering one.Reviewer notes
Three real prod-only failures surfaced during development and are fixed in this diff — worth knowing because they show the veto was load-bearing in ways its comment didn't state:
componentInfo.use(promise)memoizable, so a re-suspended boundary stopped destroying and recreating its layout effects. Hooks are now explicitly excluded.octane-prod.docs/differences-from-react.mdgains an "Automatic memoization and calls in templates" section documenting the observable boundary for binding authors, including the escape hatch (read a method-backed value into a local and let state own it).Not included: there are no
chat-streamtiming ratio guards today (only the node census), so nothing locks in this win. The benchmarks README is explicit that guards are hand-copied after review rather than auto-ratcheted, so I did not add them unilaterally — happy to run--record --ratios chat-streamand propose thresholds in a follow-up.Verification
main: 1328 files / 12914 tests pass (includes the newoctane-prodcoverage)pnpm format:checkclean,tsgo --noEmit -p packages/octane/tsconfig.jsonclean, changeset check cleanPlainCalleeListasserts the durable contract: an unrelated parent re-render keeps rendered text, and a real item change still reaches the DOM through a helper call. The existingCallBodyListmember-callee test is unchanged and still passes.🤖 Generated with Claude Code
Note
Medium Risk
Changes compiler memo eligibility and reconciliation key encoding; incorrect classification could freeze stale UI or collapse child identity, though analysis fails closed and tests target both hazards.
Overview
Production autoMemo no longer disqualifies a whole region because the template contains any render-time call.
containsRenderCallnow takes an optional memo context and treats plain identifier callees as memoizable when they are imported bindings or never-reassigned same-modulefunctionhelpers whose bodies pass a purity walk (plainCalleeIsMemoizable/moduleHelperIsPureProjection). Member calls, hooks (use/use*), local/reassigned callees,new, and tagged templates still block memoization; call arguments are still walked so live accessors inside args (e.g.projectCount(row.read())) keep regions uncached. Immutable modulefunctiondeclarations are also collected and treated like components/memowalls for dependency witnessing (without rescuing ineligible components).On the runtime side,
scopedDeoptKeyat the unwrapped top level (path.length === 0) returns'k' + key/'i' + indexinstead ofJSON.stringify, cutting per-child allocation on hot list/hole paths while nested wrapper paths keep the serialized encoding.Docs add “Automatic memoization and calls in templates”; new prod behavioral tests cover projection vs live-accessor contracts and de-opt key aliasing.
Reviewed by Cursor Bugbot for commit c542bb5. Bugbot is set up for automated code reviews on this repo. Configure here.