Skip to content

test: preserve descriptor helper evaluation and list state - #1967

Merged
trueadm merged 12 commits into
octanejs:mainfrom
openai-oss-forks:codex/memo-context-performance
Oct 10, 2026
Merged

trueadm merged 12 commits into
octanejs:mainfrom
openai-oss-forks:codex/memo-context-performance

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add public regression coverage for imported descriptor-list helpers, including same-object field mutation, live import reads, per-row default props, keyed state and suspended updates.

Why

The proposed production-only descriptor reuse could skip authored reads: mutating an existing item and publishing a new array left stale text and event data. Getter-driven import changes and transient per-row defaults also diverged from development and ordinary descriptor rendering. The optimization has been withdrawn in a forward commit.

The final runtime, compiler, benchmark fixtures and work gates match the required main revision 64c33de2f09a40eef4b4e9a6f0a4ead6fb955efe. This PR now changes only two test files. Previous allocation-elision and timing claims do not apply to the final diff.

Changes

  • Exercise the same mutation, getter/import and default-prop scenarios through production TSRX, actual Vite development transforms, production JSX and a forwarding helper. Verify current text/events, surviving row/input identity, typed drafts and cleanup.
  • Preserve public list controls for held updates, custom comparators, key changes/reordering, context, Activity and server-rendered DOM adoption.
  • Remove the projection companion, compiler/adapter admission, generic runtime delta machinery and unrelated context/teardown optimizations. Warm classification and memo-context correctness are being handled separately.

Validation

  • The previous production TSRX optimization fails all three new semantic scenarios; JSX and ordinary-helper controls pass. The actual development render control passes with only Vite's unused browser HMR transport stubbed; this is not HMR lifecycle testing.
  • Current head e1b505653, against main 64c33de2f: 20/20 owning tests pass and full pnpm sync passes with no generated changes. The two-test diff is unchanged from its previously qualified version.
  • Full-configuration scoped formatting passes. The local scoped typecheck encountered an existing HappyDOM declaration incompatibility with the workspace Node 24 types, with no diagnostics in these tests; no suppression or dependency change was added. The current-head CI typecheck passes.
  • All 31 current-head checks pass, including full CI and the benchmark report. All 64 work counters, 60 application bundle measurements and 111 public-import bundle measurements are unchanged. Maintainer review is still required.

Risk / follow-ups

No framework or benchmark behavior changes in this final diff. The prior memo-wall survivor-gate change is also withdrawn. No new speedup, bundle-size improvement or Ripple parity is claimed. The broader performance investigation remains open.

Provenance

  • An agent produced this diff (agent-authored)

Codex task · implementation host com-79386.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Low Risk
Only new Vitest integration files; no production code paths change.

Overview
Adds test-only regression coverage for Octane lists built from imported buildRows-style helpers—no runtime, compiler, or benchmark changes in this diff.

descriptor-list-behavior.test.ts introduces Vite + happy-dom integration fixtures (client IIFE and SSR bundle) that exercise keyed row lists through real octane/compiler/vite builds. Scenarios include memo hold buffering, sibling suspension/startTransition, reordering, context refresh, Activity hide/show lifecycle, descriptorChildren inspection, undefined keys, live key mutation during transitions, unkeyed→keyed recovery, and hydrateRoot adoption after renderToString.

vite-descriptor-helpers.test.ts locks mutated-item render parity when a new outer array is published: in-place field mutation, getter-driven import/callback changes, and transient defaultProps. The same expectations run under production TSRX, production JSX, forwarded helpers, and a RunnableDevEnvironment path that uses Vite’s actual dev transforms (with browser HMR client stubbed for render-only control).

Reviewed by Cursor Bugbot for commit e1b5056. 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 Oct 10, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review October 10, 2026 04:59
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🟡 js-framework: 1 timed operation(s) slower beyond ±3%

Compares 64c33de2f, the merge commit's first parent with 5a9bcd922 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

target operation base ms head ms head/base 95% CI
octane-jsx select_lots 1.369 1.481 +5.5% +4.4% … +6.9% 🟡 slower
All 20 timed operations (19 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 2.283 2.300 ±0.0% −0.0% … ±0.0% ⚪ within noise
octane-tsrx replace 5.225 5.167 −2.7% −6.9% … +3.6% ⚪ within noise
octane-tsrx add 2.183 2.267 +0.0% ±0.0% … +4.5% ⚪ within noise
octane-tsrx update 0.121 0.119 −0.5% −3.9% … +1.1% ⚪ within noise
octane-tsrx select 0.005 0.005 −0.8% −1.1% … −0.0% ⚪ within noise
octane-tsrx swap 0.014 0.015 +1.1% +0.5% … +1.9% ⚪ within noise
octane-tsrx remove 0.013 0.012 ±0.0% −1.0% … +1.0% ⚪ within noise
octane-tsrx runlots 22.083 22.058 +0.5% −2.5% … +1.8% ⚪ within noise
octane-tsrx select_lots 0.005 0.005 +1.1% +0.5% … +1.4% ⚪ within noise
octane-tsrx clear 39.592 39.983 −0.2% −1.0% … +2.1% ⚪ within noise
octane-jsx run 3.108 3.083 −0.0% −2.8% … +1.6% ⚪ within noise
octane-jsx replace 5.725 5.733 −0.8% −3.0% … +3.1% ⚪ within noise
octane-jsx add 2.917 2.900 ±0.0% −3.3% … +3.2% ⚪ within noise
octane-jsx update 0.236 0.233 −0.7% −1.6% … +0.0% ⚪ within noise
octane-jsx select 0.114 0.115 +0.6% +0.6% … +1.9% ⚪ within noise
octane-jsx swap 0.152 0.153 +0.6% −0.6% … +1.1% ⚪ within noise
octane-jsx remove 0.153 0.153 −0.0% −0.9% … +0.9% ⚪ within noise
octane-jsx runlots 26.158 25.750 +1.2% −3.1% … +2.9% ⚪ within noise
octane-jsx select_lots 1.369 1.481 +5.5% +4.4% … +6.9% 🟡 slower
octane-jsx clear 41.908 41.400 −0.5% −1.5% … +0.6% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 60 measured values.

Public-import reachability bundles (bytes)

No changes across 111 measured values.

@trueadm

trueadm commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Needs changes. I found no wrong render in the delta or context-tracking paths, but the cost and scope don't match how much code can actually use this.

  1. Admission matches only the bench helper, while every array app pays for the runtime.
    • The proof requires all of the following:
      • a module with nothing but imports and one function, so even an exported TS type declines (L86)
      • a body of exactly new Array(xs.length) plus a two-statement numeric for (L95)
      • createElement from 'octane', with key first (L184)
    • In the repo I could only find benchmarks/memo-wall/*/wall-b.* matching. The README line saying bindings produce this shape was removed.
    • The delta and publication path (runtime.ts L39040–L39194) ships to every app whose childSlot takes arrays. The bot flags hydrate-frame +527 B gzip and Base UI/Radix +488–514 B gzip, in both the Vite and esbuild variants.
    • Either widen admission to shapes real code produces, or put the delta behind a compiler-only export so other apps tree-shake it.
  2. Dev/prod divergence on mutated items.
    • A warm call reuses the old descriptor for a same-identity, same-key item at the same index, without re-reading its fields (L442).
    • After items[1].label = 'x'; setItems(items.slice()), prod TSRX keeps the stale label. Dev, the JSX twin and an unprojected call all update.
    • This matches @for's survivor skip, but it isn't documented for imported helpers (differences-from-react.md#L260) and no test pins it. A dev/prod difference in rendered output is the part I'd most like resolved.
  3. Build cost (question). projectionExports (vite.js#L1085) doesn't consult _preflightScope. So every production-client .[cm]?[jt]s module containing the text createElement now gets a full parse, including node_modules and document.createElement users. Has this been measured on a large app?
  4. Please split. The memo-promotion change at the three arming sites looks like it fixes a latent main bug: retained descendants of a newly armed block skip context stamping. If so, it deserves its own PR, regression test and changeset line. The warm-plan provider/context classification (compile.js L6656–6684 plus about 176 test lines) and the unmountScope split are separate changes too. The bounded walk itself shows no measured gain (ctx_through_wall is within noise).
  5. Evidence. The CI bench report doesn't run memo-wall, and the PR's memo-wall tables compare against earlier PR heads (665c4a6, 8b9aab8). Please add a direct main 4cc2a1ed70 → head table. Also, work.mjs changes one_change_A updateSurvivor from ROWS to 1 even though wall A isn't touched. Is that correcting a stale gate?
  6. Nit: the static default-memo proof (bundler.js L553–581 plus the extra module load in vite.js) re-proves what compilerCanCacheDescriptorProjection already checks at runtime. Keeping one layer would be enough.

Merge note: the compile.js conflicts with #1966 and #1972 are entries added at the top of INTERNAL_CLIENT_RUNTIME_HELPERS; keep all of them.

Verified:

  • The delta token is published only after a complete canonical pass, and it is cleared and journaled on clear, teardown and fast-map paths.
  • It is disabled for hydration, rollback, replay, signal owners and foreign renderers.
  • Context refresh on a cache miss goes through the context-aware region.
  • Vite projection state is per environment and limited to one-shot production client builds, with no serve, HMR or SSR exposure.
  • Rewrites are copy-on-write.
  • No Block, Scope or ForSlot fields were added, and perf-review-scan is clean.

@domgan-oai domgan-oai changed the title perf: cache descriptor projections and bound context tracking test: preserve descriptor helper evaluation and list state Oct 10, 2026
@github-actions github-actions Bot added test PR: tests only and removed perf PR: performance work labels Oct 10, 2026
@trueadm

trueadm commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Good to go with nits. The rework addresses the earlier review. The production-TSRX field-mutation case (L218–L225) is the real guard: the withdrawn projection accepted this exact helper shape, so it would render the stale row:B and fail here.

  1. This pins a React divergence that isn't documented. The transient-defaults scenario (L193, L233) expects function-component defaultProps to apply through memo. React 19 ignores defaultProps on function components, and differences-from-react.md has no entry for it. Main already behaves this way (conformance/lazy-components.test.ts:257), so this isn't a regression. Still, I'd drop the scenario, since the getter case already proves evaluation order, and document the divergence separately.
  2. The list file doesn't guard stale reuse, and partly duplicates existing tests. Its only in-place write (L543) changes the key, so it bypasses the reuse path. Several cases overlap descriptor-children-cursor.test.ts#L104, #L150 and deopt-child-key-aliasing.test.ts. I'd keep only the cases with no equivalent elsewhere: the comparator hold, the Activity reorder, descriptorChildren, and the held live-key change.
  3. Question: L486 uses setTimeout(0) + flushSync, where every other suspended case uses await act(...). Is that intended?
  4. Nits:
    • The Rows/buildRows destructure at L135 is always undefined now.
    • The PR body's Validation section still says CI is pending for 9b3be097a.

Verified:

  • Both files match the octane and octane-prod include globs.
  • Each run gets a fresh Window, so tests don't depend on order.
  • The survivor-identity, focus, comparator-hold and root-suspension expectations match React.
  • 30/30 checks green on 978cade2b3.

@trueadm
trueadm merged commit 6e5b2a2 into octanejs:main Oct 10, 2026
32 checks passed
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 test PR: tests only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants