Repository navigation
perf(octane): keep compiler fast paths through standard conversion calls - #2268
Merged
Merged
Conversation
A keyed @for row that converted its text with `String(row.id)` lost every list fast path: containsRenderCall treated the unbound global as an opaque call, and the whole-list and item-memo free-name loops rejected the `String` name. Rows re-rendered on every parent render, the whole-list cache and keyed-selection update were off, the direct host mount was declined, and SSR kept a per-row identity wrapper. containsRenderCall now admits a lexically unbound SETUP_PURE_GLOBAL_CALLEES call for every caller, using hook-deps' _octaneUnboundCallee stamp so any binding named String stays opaque. Those globals run no user code beyond the coercion template literals and `+` already perform. The @for whole-list and item-memo loops admit unshadowed IMMUTABLE_AMBIENT_GLOBALS, matching the dep-pure path's isUnwitnessedAmbientRead. Component and call-site memo proofs are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 28, 2026 20:44
Contributor
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
90 other measured values are unchanged. Public-import reachability bundles (bytes)
139 other measured values are unchanged. |
…globals The @for whole-list proof now admits unshadowed standard global names, so a row that reads `undefined` or `Math.PI` gets the list cache too. pagecraft's document list (`aria-current={... : undefined}`) is the bench report's +135 B gzip. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | bffdbe5 | Commit Preview URL Branch Preview URL |
Oct 28 2026, 10:26 PM |
trueadm
added a commit
that referenced
this pull request
Oct 28, 2026
A child hole whose type proves it a string becomes `{x as string}`; a
number or bigint becomes `{String(x)}` (a template literal where a local
shadows `String`). Types come from one program over the project under
its tsconfig, so imported types resolve, falling back to the module's
own program, which now loads the ES5 library so array and string members
have types. As with the compiler's typed-text proof, the rule runs only
on TypeScript modules in a project with `strictNullChecks`: otherwise a
`string` may hold null, which React renders as nothing.
The js-framework run measured the casts at about 20% off creates. The
corpus casts 219 holes with no new compile errors and Strong unchanged.
The plan now records the keyed-selection finding: the inlined row's slow
selection was its `String()` call, a compiler gap fixed in #2268, not
the useReducer state; the un-inlined row's cost is memo's comparator, so
dropping a provably safe comparator replaces row inlining as the
candidate rule.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…calls `String(value)` was already a call-free projection inside @for rows. Component bodies, call sites, and calculations still rejected the `String` name, so a child that converted its text lost its compiler memo region, lite edge, and stable-hookful-child skip. isConversionGlobal (a SETUP_PURE_GLOBAL_CALLEES name no module binding shadows) now joins the immutable names in the six remaining memo free-name proofs: calculations, stable hookful children, mapped providers, component call sites, component bodies, and call-site dependencies. Three more gates admit isConversionGlobalCall, the lexically unbound call: - warm potential, since a conversion starts no async work, so the hookful child skip is reachable; - the lite-edge hookless check, since it cannot hide a hook; - the call-site dependency collector, so the global itself is never compared. Each admitted source now compiles exactly like its bare-value twin. Shadowing by a local, module const, or module function keeps the region off. Co-Authored-By: Claude Opus 5.5 <[email protected]>
10 of 13 tasks
… String() The retry ancestry bound only had work to measure because `String(value$.get())` kept Leaf, and so every Layer above it, out of the compiler memo proofs. With conversion globals now memoizable, the retry reused cached subtrees and the observer saw no retry paths. The same failure appears on the previous compiler if Leaf reads `value$.get()` without String(). Leaf now reads a module `let`, which no memo proof can witness, so the retry re-renders the whole signal-owner tree. The measured scope-path entries are unchanged: 21,384 at depth 16 and 269,640 at depth 64. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Oct 28, 2026
…n CLI (#2264) * feat(codemod): add @octanejs/codemod, a React to Octane/TSRX migration CLI Add `octane-codemod`, which rewrites React + TSX/JSX modules as Octane + TSRX: React imports and React libraries move to `octane` and their bindings, components become `@{ … }` templates with `@if`/`@for`/`@try` where that keeps React's behavior, and template modules are renamed to `.tsrx` with every import of them updated. Every migrated module is compiled before it is written; `--strong` applies the compiler's fixes and keeps each module Strong where the compiler accepts it. Names resolve through a single-file TypeScript binding, contexts by provenance across modules, literals and comments survive rewrites, and a second run changes nothing. `@octanejs/cli` exports its binding catalog and fix application for the codemod to reuse. The Hacker News example gains a codemod lane: `codemod.mjs` respells `jsx/` with React imports and migrates it, and the shared Playwright journeys run against the result as a third project. docs/octane-codemod-plan.md holds the implementation plan and the third-party corpus results. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(codemod): reuse the CLI's project helpers and simplify the runner Concise pass over the codemod before review: - Find the project root and walk its sources with `findRoot` and `scanSourceFiles` from `@octanejs/cli` instead of a second walker; dot directories such as `.storybook/` are now skipped like other tooling. - Share the compiler finding shape (`finding`, `thrown`) between the runner and the Strong pass. - Report a module the compiler rejects in every mode as its compile error, not as a Strong blocker, with a regression test. - Collapse duplicated helpers in the transform (binding names, line prefixes, whitespace-only children) and flatten `mapReactImport`. - Count CLI errors from one findings list; `--no-verify` uses `parseArgs` `allowNegative`. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(changeset): note the CLI root exports the codemod uses Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(codemod): address review findings on imports, providers, and Strong fallback - Map `import('react')` and other dynamic imports of React modules to their Octane module, as static imports already were. - Rewrite `.Provider` on the context's tag name, so self-closing providers migrate too; this replaces the element-level provider rewrite. - Remove the `"use strong"` the codemod added wherever it sits in the prologue (after `"use client"` too) when a module falls back to compatibility mode. - `test:e2e:dev` in the Hacker News example generates the codemod app first. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(codemod): insert Strong directives on their own line and skip out/ - The prologue insertion point only ever falls at a line start (after a shebang, blank lines, whole-line comments, and directives), so the Strong fallback always finds the directive line it added, including when a comment shares the first line with code. - Project scans skip `out/` build output again, now in the CLI's shared walker, so `octane analyze` skips it too. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(codemod): list @octanejs/codemod as Node tooling source-publication debt `@octanejs/codemod` is a Node CLI like `@octanejs/cli`: it validates its shipped source with Node's types and publishes `.js` without sibling declarations. List it beside the CLI under both rules, tracked by #2266, which covers shipping declarations and scoping the Node-types rule for every Node tooling package. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(codemod): record a clean corpus now that #2265 fixed TS2300 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(codemod): migrate default-imported contexts and import() types - Only a default import of React or Octane stands for the whole module; any other module's default import is its `default` export, so a context imported with `import Theme from './theme'` is recognized through the project's context index and its `.Provider` migrates. - `import('react').X` in a type position maps its module, and a React type name Octane spells differently, the same way static imports do; renamed relative modules are followed there too. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(codemod): rewrite inside a remapped import() type A remapped specifier copied the rest of its node verbatim, so in `import('./box').Box<import('react').ReactNode>` the nested React import was never migrated. The rest of the node is now emitted, which visits its type arguments. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(codemod): record the js-framework-benchmark results Migrated react-hooks is correct and beats React on every op, but trails the hand-written octane-tsrx target 1.2-169x and ships React-sized bytes. Record the numbers, the Strong blockers, react-classes, and the three rule candidates they point to: text-hole casts, render(App), and row inlining held on the keyed-selection question. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(codemod): spell typed text holes as text bindings A child hole whose type proves it a string becomes `{x as string}`; a number or bigint becomes `{String(x)}` (a template literal where a local shadows `String`). Types come from one program over the project under its tsconfig, so imported types resolve, falling back to the module's own program, which now loads the ES5 library so array and string members have types. As with the compiler's typed-text proof, the rule runs only on TypeScript modules in a project with `strictNullChecks`: otherwise a `string` may hold null, which React renders as nothing. The js-framework run measured the casts at about 20% off creates. The corpus casts 219 holes with no new compile errors and Strong unchanged. The plan now records the keyed-selection finding: the inlined row's slow selection was its `String()` call, a compiler gap fixed in #2268, not the useReducer state; the un-inlined row's cost is memo's comparator, so dropping a provably safe comparator replaces row inlining as the candidate rule. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(codemod): make every JSX module TSRX and fix the weather/chat defects Every module with JSX (`.jsx`, `.tsx`, or a `.js` file with JSX) now becomes `.tsrx`, entries and helpers without a component included, so no `.tsx` module is left outside Strong mode. A module that was JavaScript gains `// @ts-nocheck`, so it stays as unchecked as it was. On the corpus this takes `.tsrx` modules from 414 to 488 and Strong from 316 to 378, with no compile errors. Validating on the weather and chat benchmark apps found three defects: - a `.jsx` entry kept JSX that Octane's Vite plugin does not compile, so the build failed (fixed by the TSRX change); root-absolute `index.html` script paths now resolve from the page's directory; - a key on every arm of a conditional row stayed on the arms, leaving an unkeyed `@for` of runtime descriptors (+12.8 kB, ~2x streaming); a shared key now moves to the header, and differing keys keep `.map()`; - finding lines named the new file with the old file's lines, and Strong blockers kept the directive's lines; notes now name the original file, and blockers are shifted to the written one. The Hacker News server loads a TSRX `entry-server` when the lane has one. The plan records both apps' results and the compiler follow-ups. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
`const value = String(props.value)` became a cached calculation once conversion globals joined the calculation proof: isPropCreationExpr counted the conversion as value creation. A re-render with unchanged props then skipped the conversion (signals-primitive-local-values expects one per render), and a primitive gains nothing from a memo cell. The bare twin `const value = props.value` has no call and was never cached. A conversion-global call no longer counts as creation; its arguments still do, and `new String(x)` still does. Calculations with a real creating call keep the conversion admission. Server prop-flow likewise emits a plain `String(...)` instead of a per-pass memo (recharts Bar). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…TS reprint
B.tsx renders `{String(depth)}`, which the lite-edge hookless check now
admits, so A calls B through componentSlotLite instead of componentSlotVoid.
Lite exports are void exports vouched for by the same reprint-tolerant
fingerprint (vite.js), so either proven edge shows the proof survived.
The fail-closed case now rejects both edges. Matching only componentSlotVoid
would have passed vacuously once B went lite. Without its rewrite plugin, that
case now fails.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | bffdbe5 | Commit Preview URL Branch Preview URL |
Oct 28 2026, 10:27 PM |
5 of 8 tasks
domgan-oai
pushed a commit
that referenced
this pull request
Oct 29, 2026
The test runs the codemod over the whole Hacker News app twice, compiling every module each time. It takes about 1.3 s locally but passed Vitest's default 5 s under CI load on #2268's test shard 2. Co-authored-by: Claude Opus 5.5 <[email protected]>
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
{String(row.id)}, now keeps every compiler fast path the bare value gets. That covers:@forrows: dep-pure survivor skip, whole-list memo region, keyed-selection update, direct host-row mount, and the SSR row path without a per-item identity wrapper;Stringwith a local, parameter, import, or module binding keeps all of these off.Why
@octanejs/codemod(feat(codemod): add @octanejs/codemod, a React to Octane/TSRX migration CLI #2264) on the js-framework React hooks app.Rowinlined into the@for, the migrated app selected 28× slower than the hand-written fixture, and 313× slower for 10,000 rows.useReducer-destructured state and theuseCallback(flushSync(dispatch))handler. Neither matters: the same app with a bare{item.id}already matched the hand-written fixture.{String(item.id)}:containsRenderCalltreated the unboundStringas an opaque call;Stringname;function Rowwith{String(item.id)}got list flags 138 rather than 142, and a child converting its text lost its call-site region.String(value)is the spelling.rulesync/rules/tsrx-authoring.mdrecommends for an intended text conversion, and the codemod emits it for number-typed text holes.Changes
isConversionGlobalCall(node): a call whose callee carries the existing_octaneUnboundCalleelexical stamp fromhook-deps.jsand names aSETUP_PURE_GLOBAL_CALLEESglobal (String,Number,Boolean,parseInt, …). Four gates admit it:containsRenderCall, for every caller. Arguments are still walked, soString(row.read())fails closed.isConversionGlobal(name, ctx): a conversion-global name that no top-level module binding shadows. It joins the immutable names in the six component-side free-name proofs:autoCalculationOf);autoMemoSafe);isImmutableAmbientGlobal(name, ctx): the@forwhole-list and item-memo loops admit unshadowedIMMUTABLE_AMBIENT_GLOBALS.isUnwitnessedAmbientReadalready allows in the same function.componentInfobranch, so a component is never treated as a global.undefinedorMath.PItherefore also gets the whole-list cache.isPropCreationExpr: a conversion-global call no longer counts as value creation. Its arguments still do, and so doesnew String(x).const value = String(props.value)therefore stays an ordinary local, exactly likeconst value = props.value. A primitive gains nothing from a memo cell.Bar'sname.summarize(String(n)), still admits the conversion and is cached.+already perform, and every proof already admits those.plainCalleeIsMemoizableandmoduleHelperIsPureProjectionare unchanged. A module helper whose body callsString()still is not a pure projection.docs/differences-from-react.md: the call-admission paragraph now lists conversion globals. The changeset is updated to match.Validation
pnpm format:check(not run repo-wide;pnpm format:files:checkon every changed file passes)pnpm typecheck(not run repo-wide;pnpm typecheck:fileson the changed tests and fixtures reports only pre-existing errors, none on lines this diff adds)pnpm test(not run locally; left to CI)targeted tests, all passing on the final head:
octane-prod: 1,315 tests in 28 files. These are the owning suites (auto-memo,auto-calculation,automemo-render-calls,for) plus every test file whose fixture's compiled output changes (commit functions, event signal owner, hole kinds, nested, provider output, signals local chains and primitive locals, try/catch and its hydration cases, transition flush, typescript text holes, SSR invalid nesting, conformance attribute, matrix, lazy, and multichild suites).octane:compiler/for-item-purityandauto-calculation, 72 tests.animated; shadcninputsandssr/server-tier2;vite-plugin-octaneplugin; xstateupstream-useActor. 102 tests.pre-fix failures, checked against
mainand against this PR's previous head:@for: the three positive cases in the newfor-item-puritydescribe fail onmain(PURE, the whole-list cache, and selection dependency index 1 in flags bits 8+).auto-memotwin cases fail on the previous head. These are a component body, a call-site prop, a hookful child that publishes its setter, and a mapped row under a provider. Each asserts that theString()source compiles byte-identically to its bare-value twin once component ids are normalized.auto-calculationidentity case (summarize(String(items.length))) fails before the component commits.signals-primitive-local-values("evaluates conversion once…") caught an intermediate head that cachedconst value = String(props.value). It passes again inoctane-signals,octane-signals-strong, andoctane-signals-prod.@forshadowing cases turn red when the lexical stamp is removed.String) turn red when the stamp or the module-shadow check is removed.Behavioral coverage:
String()-converted fixtures.automemo-render-callsgains a live shadow case and a projection case.auto-memogains live re-read cases for each shadowing form, with the source passed through props so only theStringguard decides.auto-calculationchecks that an object built withString()keeps its identity across an unrelated render and rebuilds when its input changes.Compile corpus: 5,734 outputs (client and server) across
packages/,examples/, theoctane-tsrxbenchmark fixture, andwebsite/srcwere compiled onmainand on this branch. There are no new compile errors.@forlists, plus pagecraft's document list.Bar's server prop-flow.Scatter;select;BaseAreaSeries,BaseAreaStack, andBaseLineSeries;EcosystemDirectoryand playgroundPlayground;undefined. That is deliberately out of scope.js-framework harness (
benchmarks/js-framework/run.mjs, 8 iterations, all builds from this worktree). Ratios are to the hand-writtenoctane-tsrx:String(item.id),main{item.id},main(control)PR benchmark report on the first head: all 64 js-framework work counters are unchanged, and every timed operation is within noise.
undefined(aria-current={… ? 'page' : undefined}). It now gets the memo-region wrapper any qualifying list gets.perf-review:node scripts/perf-review-scan.mjs→ 0 candidates.Setlookup per call or free name.bagNarity changes.concise-code: src +67 −16 (runtime +0 −0), all incompile.js.isImmutableAmbientGlobalserves the@forloops.isConversionGlobalserves the six component-side free-name proofs.isConversionGlobalCallserves four call gates. The only new file is the changeset.plainCalleeIsMemoizable, about the same size. It turned module helpers that wrapString()into pure projections everywhere, an untested side effect.IMMUTABLE_AMBIENT_GLOBALSname in the component proofs, the same size. It changes 26 more outputs for names likeundefined, a broader policy than the codemod needs.Risk / follow-ups
memo(Row, customCompare)row compiles to flags 8: no single root, no dep-pure, no list cache. That is the remaining 18× select. Dropping the comparator, ormemoentirely, recovers dep-pure and the list cache, and a plainfunction Rowgets flags 142.benchmarks/scoped-signals/retry-owner-ancestry.test.mjsnow hasLeafread a modulelet.String(value$.get())kept every leaf, and so every layer above it, out of the memo proofs.Leafreadsvalue$.get()withoutString().vite-void-import-cycles.test.ts:B.tsxrenders{String(depth)}, soAnow calls it through the lite edge.globalThis.Stringwould be memoized past the reassignment. The setup-checkpoint proof andIMMUTABLE_AMBIENT_GLOBALSalready make the same assumption.Symbol(desc)is in the admitted set. A cached calculation or skipped row keeps its earlier symbol, the same identity retention React Compiler gives an allocation with unchanged inputs.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Compile-time-only, but it widens when regions skip re-render; shadowing and opaque arguments are the intended guardrails, with a residual assumption that runtime
globalThis.Stringis not reassigned.Overview
Unshadowed calls to standard conversion globals (
String,Number,parseInt, etc.) no longer force memo and@foroptimizations off. The compiler treats them like bare coercions:containsRenderCallskips them when arguments stay pure, and newisConversionGlobal/isConversionGlobalCallhelpers let auto-memo, cached calculations, lite edges, and@forwhole-list / item proofs accept the callee the same way they accept imported projections.@forrows using{String(row.id)}keep dep-pure survivor skips, list memo regions, keyed-selection updates, and fast host paths; unshadowed reads of immutable ambient globals (e.g.undefined,Math.PI) also qualify for the whole-list cache. ShadowingStringlocally or in the module still fails closed, andString(row.read())stays live because arguments are walked.Docs and the changeset describe the React-migration spelling
{String(item.id)}and the js-framework benchmark fix (select was ~28× slower onmain). Tests cover compile parity with bare values, shadowing, calculation identity withsummarize(String(n)), and hydration/list behavior for converted fixtures. The scoped-signals retry benchmark adds a moduleletonLeafso memoizable conversions do not collapse the measured retry tree.Reviewed by Cursor Bugbot for commit bffdbe5. Bugbot is set up for automated code reviews on this repo. Configure here.