Skip to content

perf: skip unchanged conditional keyed rows - #628

Merged
trueadm merged 2 commits into
octanejs:mainfrom
openai-oss-forks:fix/todomvc-conditional-row-memoization
Aug 7, 2026
Merged

trueadm merged 2 commits into
octanejs:mainfrom
openai-oss-forks:fix/todomvc-conditional-row-memoization

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Extend production keyed-list survivor memoization to compiler-proven rows containing only host-element conditionals.
  • Preserve conditional row ownership, hydration, uncontrolled input values, event freshness, keyed identity, and suspended transition rollback.
  • Add a deterministic seven-framework TodoMVC regression guard and an octane patch changeset.

Why

TodoMVC rows contain @if (editing === item.id), which previously disabled the existing DEP-PURE survivor bailout for the whole list. Immutable updates consequently rerendered every unchanged row and rewrote unchanged class attributes.

Controlled 24-iteration production measurements before/after the optimization:

Operation Before After Total class writes
Add 100 todos 2.61 ms 0.73 ms 5,350 → 400
Complete 25 todos 1.70 ms 0.36 ms 2,575 → 100
Delete 25 todos 1.50 ms 0.19 ms 2,250 → 75

The deterministic row-only measurement drops from 2,500 to 25 class writes for 25 immutable updates, matching React. DOM shape is unchanged, generated application code does not grow, and the shared production runtime grows by approximately 22 bytes gzipped.

Changes

  • Conservatively recognize host-only nested @if rows with complete stable dependency witnesses; continue rejecting hooks, components, opaque calls, refs, portals, spreads, and other control-flow boundaries.
  • Reserve a keyed-list flag for rows that require their active scope, keep full renderBlock execution when dependencies change, and invalidate dependency snapshots while a transition is journaled.
  • Cover immutable row updates, callback replacement, reordering, uncontrolled drafts, server hydration, fail-closed opaque calls, and suspended transition rollback.
  • Count real browser-observed row-class mutations separately from timing samples and enforce an Octane/React ratio guard.

Validation

  • pnpm format:check — repository-wide formatting was not run; scoped formatting passed.
  • pnpm typecheck — repository-wide typechecking was not run; all four touched Octane source/test files passed tsrx-tsc.
  • pnpm test — the full monorepo is blocked by pre-existing broken cross-worktree dependency symlinks and Node 26's experimental localStorage; both Octane projects were tested directly.
  • pnpm_config_verify_deps_before_run=warn pnpm sync
  • pnpm_config_verify_deps_before_run=warn pnpm format:files:check benchmarks/baselines/ratios.json benchmarks/todomvc/README.md benchmarks/todomvc/run.mjs packages/octane/src/compiler/compile.js packages/octane/src/runtime.ts packages/octane/tests/_fixtures/for.tsrx packages/octane/tests/for.test.ts .changeset/conditional-keyed-row-memoization.md
  • pnpm_config_verify_deps_before_run=warn pnpm typecheck:files packages/octane/src/runtime.ts packages/octane/src/compiler/compile.js packages/octane/tests/for.test.ts packages/octane/tests/_fixtures/for.tsrx
  • NODE_OPTIONS=--no-experimental-webstorage ./node_modules/.bin/vitest run packages/octane/tests/for.test.ts packages/octane/tests/compiler/compiler-ast-immutability.test.ts packages/octane/tests/compiler/compiler-map-coverage.test.ts --project octane --project octane-prod --maxWorkers=4 --reporter=dot — 109 tests passed.
  • NODE_OPTIONS=--no-experimental-webstorage ./node_modules/.bin/vitest run --project octane --project octane-prod --testNamePattern '^(?!.*transforms installed raw Octane packages but preserves manual-slot sources).*$' --maxWorkers=8 --reporter=dot — 770 files and 10,861 tests passed; one pre-existing broken-installed-workspace test is excluded in each project.
  • pnpm_config_verify_deps_before_run=warn node benchmarks/bench.mjs --quick --ratios todomvc — all seven production targets passed, including four applicable ratio guards and exactly 25 Octane row-class writes.
  • pnpm_config_verify_deps_before_run=warn pnpm changeset:check

Risk / follow-ups

  • Production-only optimization; unsafe row shapes fail closed, and transition attempts intentionally disable the bailout.
  • Upstream's new certified fast-host mounting remains excluded for conditional rows; existing fast keyed-selection coverage passes with the reused flag bit.
  • Editing still invalidates all rows. A future scope-aware keyed-selection specialization could target only the previously and newly edited items.

Provenance

  • An agent produced this diff (agent-authored)

Note

Medium Risk
Touches production keyed-list reconciliation, compiler purity flags, and transition journaling; incorrect bailout could cause stale DOM or wrong conditional branches, though the change is gated conservatively and heavily tested.

Overview
Extends production keyed-list survivor memoization so TodoMVC-style rows with nested @if (host elements only) can bail out when parent deps are unchanged, instead of re-rendering every row and rewriting unchanged class attributes.

The compiler adds hasOnlyHostConditionalItemBodies and a narrow conditionalHostDepEligible path: DEP-PURE rows may include proven host-only conditionals when dependency witnesses are complete; unsafe shapes (hooks, components, opaque calls, other control flow) stay on the normal path. Flag bit 5 now means the row needs its active Block scope (replacing the prior keyed-selection marker on ordinary forBlock); rows that need scope are excluded from keyedForBlock selection specialization.

The runtime still promotes survivors when deps match, but for scope-required rows it avoids the lite direct-body path, clears cached deps during journaled transitions so rollback cannot leave stale bailout state, and only skips work when dependencies are stable.

Benchmarks add row_class_writes_complete25 (MutationObserver on li class during complete25) plus a 2× Octane/React ratio guard targeting ~25 writes vs list-wide churn. TodoMVC docs note production preview builds for cross-framework columns.

Tests cover nested conditional lists (immutable updates, reorder/remove, hydration, Activity + components, transition suspend/rollback) and confirm member-call bodies still re-run inside nested @if.

Reviewed by Cursor Bugbot for commit 8430c63. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Aug 7, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit eaec0f3. Configure here.

Comment thread packages/octane/src/compiler/compile.js Resolved
@trueadm
trueadm marked this pull request as ready for review August 7, 2026 20:44
@trueadm
trueadm merged commit 27758f5 into octanejs:main Aug 7, 2026
36 of 46 checks passed
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 7, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 7, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 7, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 7, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 7, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 7, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization
leonidaz pushed a commit that referenced this pull request Aug 10, 2026
* docs(packaging): plan CommonJS package conditions

* feat(packaging): add CommonJS graph builder

* fix(packaging): parse CommonJS graphs with esbuild

* feat(octane): publish CommonJS runtime entries

* feat(bindings): publish CommonJS runtime graphs

* test(packaging): exercise packed CommonJS consumers

* chore(release): record CommonJS package conditions

* test(packaging): run CommonJS tarball canary

* test(packaging): compare ESM and CommonJS parity

* fix(review): guard CommonJS output deletion

* fix(review): reject lossy CommonJS transforms

* feat(packaging): compile TSRX CommonJS graphs

* perf(packaging): reuse TSRX compilation work

* feat(packages): support callable CommonJS defaults

* fix(packages): recognize TSRX CommonJS roots

* perf: speed up server-rendered HTML escaping (#629)

* perf: skip unchanged conditional keyed rows (#628)

* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization

* fix(ci): prevent usehooks hydration timeout

* fix(ci): refresh React parity evidence hashes

* perf: reuse bounded keyed-reorder scratch storage (#630)

* perf: add minimal-import bundle reachability budgets (#631)

* perf: add minimal-import bundle reachability budgets

* fix: register reachability benchmark with MCP server

* fix: preserve side-effect-only bootstrap entrypoints (#633)

* perf: cache stable renderable regions and prune sync warming (#634)

* perf: cache stable renderable regions and prune sync warming

* fix: preserve uppercase-prefixed custom hook state

* fix(benchmarks): remove js-framework DOM node metrics (#636)

* fix(bindings): classify production bundle side effects (#637)

* feat: enable React Compiler across framework benchmarks (#639)

* perf: reduce core runtime and compiled application bundles (#638)

* Version Packages (#601)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(commonjs): fail closed on authored .tsrx modules

Refuse compiling .tsrx into CommonJS packaging output so published packages keep source for consumers to compile.

Co-authored-by: Cursor <[email protected]>

* fix(commonjs): restore published require export conditions

Re-apply the CommonJS require maps for octane and the binding packages after the main merge dropped them.

Co-authored-by: Cursor <[email protected]>

* fix(commonjs): order require before default and wire binding prepack

Put import/require ahead of default in octane publishConfig.exports so Node does not always pick the ESM graph, and run build:cjs from prepack for the binding packages that advertise dist/cjs.

Co-authored-by: Cursor <[email protected]>

* fix(compiler): discover source packages without a CommonJS build

require.resolve failed on prepack-only dist/cjs entries in CI, so Vite
source discovery skipped Base UI and nested bindings. Fall back to the
installed package manifest when the require target is missing.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: domgan-oai <[email protected]>
Co-authored-by: Dominic Gannaway <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Cursor <[email protected]>
trueadm added a commit that referenced this pull request Aug 28, 2026
* feat(bindings): port react-transition-group

* fix(bindings): address transition parity feedback (#487)

* fix(bindings): make group updates synchronous (#487)

* fix(bindings): register transition group integrations (#487)

* fix(bindings): refresh transition parity evidence (#487)

* fix(bindings): guard null transition refs (#487)

* fix(bindings): format transition parity inventory (#487)

* fix(react-transition-group): preserve transition state

* fix(ci): format TransitionGroup source

* fix(ci): refresh transition parity lock hash

* docs: refresh package inventory

* docs: refresh binding parity gaps

* docs: refresh binding status

* fix(react-transition-group): refresh stable child flags

* chore(evals): refresh transition group corpus

* fix(ci): refresh transition parity evidence

* fix(ci): format transition parity inventories

* feat(react-select): add foundation and default components

* feat(react-select): port managed option hooks

* feat(react-select): port Select and composed entrypoints

* feat(react-select): add nonce and public type parity

* feat(react-select): match menu placement and keyboard navigation

* feat(react-select): match accessibility and scroll behavior

* feat(react-select): match touch interaction behavior

* feat(react-select): match multi-value navigation

* feat(react-select): match input and form events

* feat(react-select): match pointer selection behavior

* feat(react-select): match mount focus behavior

* feat(react-select): complete exact binding

* fix(react-select): register migration rewrites (#541)

* fix(react-select): enforce public type parity

* chore(ci): refresh react-parity evidence after main merge

Regenerate lockfile hashes and inventory for react-select.

Co-authored-by: Cursor <[email protected]>

* chore(ci): refresh react-parity evidence after main merge

Regenerate lockfile hashes and inventory for react-select.

Co-authored-by: Cursor <[email protected]>

* chore(ci): refresh react-parity evidence after main merge

Regenerate lockfile hashes and inventory for react-select.

* perf: speed up server-rendered HTML escaping (#629)

* perf: skip unchanged conditional keyed rows (#628)

* perf: skip unchanged conditional keyed rows

* fix: exclude Activity boundaries from keyed row memoization

* fix(ci): prevent usehooks hydration timeout

* fix(react-select): resolve Bugbot keyed-list and selection regressions

Always call setValue on single-select reselection, merge Fade innerProps,
and add stable keys for menu, form, and animated value-container children.

Co-authored-by: Cursor <[email protected]>

* fix(react-select): pass animated value children without Fragment wrappers

Octane Children.toArray does not flatten Fragment descriptors, so MultiValueContainer could not clone transition props onto MultiValue and Placeholder children.

Co-authored-by: Cursor <[email protected]>

* fix(react-select): pass inspectable animated value children

Restore the needsInspectableValueChildren path so TransitionGroup receives an enumerable children array instead of a compiler opaque block, without Fragment wrappers that Children.toArray cannot flatten.

Co-authored-by: Cursor <[email protected]>

* test(react-transition-group): scaffold upstream parity lanes

Run the pinned React suite unchanged and separate adapted parity evidence from ordinary Octane conformance coverage.

Co-authored-by: Cursor <[email protected]>

* test(react-select): add pristine upstream Jest lane

Run the vendored react-select suites unchanged as a required parity oracle,
drop whole-project parity ownership so repo-authored tests stay ordinary, and
refresh neighboring vitest.config.js evidence hashes after the main merge.

Co-authored-by: Cursor <[email protected]>

* test(react-transition-group): complete adapted upstream suite

Port every applicable upstream runtime case one-for-one so the adapted lane now provides exhaustive parity evidence with no pending dispositions.

Co-authored-by: Cursor <[email protected]>

* test(react-select): start adapted upstream suite

Port the smaller upstream suites into a verified Octane lane and account for every remaining pristine identity with fail-closed controls.

Co-authored-by: Cursor <[email protected]>

* test(react-select): adapt core Select behavior

Port 102 upstream Select cases covering props, filtering, inputs, callbacks, accessibility, and interactions, reducing the unadapted inventory to 115 identities.

Co-authored-by: Cursor <[email protected]>

* test(react-transition-group): address parity review feedback

Strengthen adapted lifecycle scenarios and keep parity evidence mapped to the files that execute each upstream case.

Co-authored-by: Cursor <[email protected]>

* test(react-select): expand Select upstream coverage

Adapt 66 more Select cases across keyboard navigation, callbacks, forms, accessibility, custom components, and value handling, leaving 49 pristine identities pending.

Co-authored-by: Cursor <[email protected]>

* test(react-select): complete adapted upstream suite

Port the remaining one-for-one adapted cases to 248 of 255 pristine
identities, keep seven Select blockers fail-closed with rationales, and
refresh the parity inventories and hashes for the review feedback.

Co-authored-by: Cursor <[email protected]>

* test(react-select): stabilize StateManaged snapshot ids

Move the defaults snapshot before other mounts so instance ids stay at
react-select-1 regardless of suite filtering or test order.

Co-authored-by: Cursor <[email protected]>

* fix(react-select): match upstream focus and clear behavior

Co-authored-by: Cursor <[email protected]>

* fix(react-select): mark parity provenance verified

Unverified provenance left required React parity lanes validate-only; flip to verified so CI executes them.

Co-authored-by: Cursor <[email protected]>

* fix(react-transition-group): add type lanes for verified parity

Absent upstream type suites still require repo-authored pristine-types and adapted-types evidence before verification can be verified; add consumer-shaped typetests and refresh lockfile hashes.

Co-authored-by: Cursor <[email protected]>

* fix(react-transition-group): restore adapted upstream oracles

Address leonidaz parity review: node-env SSR adapted project, silent
cleanup console spy, mid-appear null child, childFactory reentry,
appear checkpoint, and full SwitchTransition callback traces.

Co-authored-by: Cursor <[email protected]>

* fix(react-select): address parity inventory review

Split the transition-group SSR adaptation into its own required lane, inventory
the three canonical react-select skips as not-applicable, classify Select.test.ts
under fail-closed discovery, and reconcile UPSTREAM.md with the verified counts.

Co-authored-by: Cursor <[email protected]>

* fix(react-select): close leonidaz parity control gaps

Add assertion-group type parity verifiers and typetest ledger coverage for
react-select and react-transition-group, record exact oracle versions, and
drop Vitest wrappers around the direct jest-full pristine lanes.

Co-authored-by: Cursor <[email protected]>

* fix(select): close type-parity controls and drop react prefix

Verify mapped typetest fixtures belong to the pristine/adapted compiler
programs, record the exact @types/react type-oracle pins, and rename the
Octane package to @octanejs/select per maintainer naming guidance.

Co-authored-by: Cursor <[email protected]>

* chore: refresh parity hashes after select rename and main merge

Co-authored-by: Cursor <[email protected]>

* fix(select): route differential tests to react-parity and pin type oracle

Move the six react-octane-differential SSR suites into a dedicated
select-differential Vitest project under testExecution.group react-parity,
and replace catalog:default @types/react pins with literal 19.2.17/19.2.3.

Co-authored-by: Cursor <[email protected]>

* fix(select): reconcile multi-value focus and key inspectable children

Match upstream focusedValue remapping on value updates and give the
animated ValueContainer path stable keys without breaking MultiValue
child inspection.

Co-authored-by: Cursor <[email protected]>

* fix(select): flatten keyed fragments in animated ValueContainer

Unwrap inspectable ValueContainer's keyed Fragment slots before
TransitionGroup and MultiValueContainer inspect child types.

Co-authored-by: Cursor <[email protected]>

* fix(select): preserve animated child identities (#541)

- retain fragment and inner child keys when flattening inspectable children
- cover animated single-select value and input rendering

Note: pre-existing typecheck failures in packages/select/src/animated/transitions.tsrx were not addressed by this PR.

* chore: format refreshed parity evidence

* fix(select): validate without Node ambient types

* fix(select): register browser suite in heavy CI

* chore: refresh eval corpus hashes

* fix(select): reconcile async state transactionally

* chore: refresh merged parity evidence

* fix(select): address parity review findings

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: domgan-oai <[email protected]>
Co-authored-by: Dominic Gannaway <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants