Skip to content

perf: retain unchanged Lynx rows across transport commits - #696

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:fix/lynx-transported-row-retention
Aug 10, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:fix/lynx-transported-row-retention

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

Extend Octane's existing retained-component subtree adoption to transported universal roots, so changing one or two rows in a Lynx table does not execute every unchanged row component again.

This follows the specific, independently measured fix in Huxpro/octane#11, rather than proposing new compiler machinery, a new transport protocol, or speculative receiver optimization. The performance question is deliberately framed around the actual Lynx-for-Web engine and browser-hosted Element PAPI, not only an inexpensive in-process fake.

Draft status: implementation and same-host before/after Chromium measurements are complete. All affected full framework/build-plugin projects passed 12,531 tests, all eight affected TypeScript configurations passed, and every deterministic Lynx table guard passed.

Why

octanejs/octane#693 made large production-compiled mounts and first native updates competitive with ReactLynx on a shared cheap fake Element PAPI. Its 21-sample in-process 10,000-row results were 44.755 ms versus 47.255 ms for mounting and 7.845 ms versus 8.673 ms for the first update. That benchmark is useful for runtime and host-driver costs, but does not represent real browser DOM work, layout, publication, engine event delivery, or a true priced thread boundary; its Octane ContextProxy also passes objects by reference.

The actual benchmarks/lynx-table/web/run-web.mjs workload tells a different story. It runs production bundles inside a real <lynx-view> backed by Lynx-for-Web and Chromium, drives the same visible table operations through the engine, and compares against vendored ReactLynx and Vue Lynx reference bundles in the same browser session.

Before and after collected on 2026-08-10 on the same 18-core Apple M5 Max, using the same pinned reference bundles; medians of three Chromium samples per operation. Reference columns are from the after run, not the earlier session. Absolute times and reference timings drift with browser/host load; deterministic changed-row counts provide the stronger regression evidence.

Rows Operation Octane before Octane after Change ReactLynx, after Vue Lynx VDOM, after
1,000 Create 74 ±2 ms 77 ±1 ms +4%; noise 37 ±1 ms 45 ±3 ms
1,000 Update every tenth row 17 ±4 ms 10 ±4 ms −41% 9 ±3 ms 7 ±4 ms
1,000 Select one row 14 ±1 ms 7 ±4 ms −50% 15 ±5 ms 16 ±1 ms
1,000 Update storm 72 ±3 ms 46 ±8 ms −36% 146 ±5 ms 39 ±0 ms
1,000 Selection storm 27 ±7 ms 12 ±0 ms −56% 53 ±4 ms 21 ±1 ms
10,000 Create 678 ±22 ms 696 ±12 ms +2.7%; noise 337 ±9 ms 420 ±8 ms
10,000 Update every tenth row 132 ±14 ms 93 ±1 ms −29.5% 70 ±13 ms 53 ±2 ms
10,000 Select one row 92 ±18 ms 47 ±1 ms −48.9% 40 ±8 ms 20 ±10 ms
10,000 Update storm 733 ±34 ms 344 ±8 ms −53.1% 1,421 ±123 ms 655 ±87 ms
10,000 Selection storm 179 ±31 ms 87 ±15 ms −51.4% 585 ±32 ms 315 ±52 ms

At 10,000 rows, selecting a row improves from 92 ms to 47 ms; updating every tenth row improves from 132 ms to 93 ms. Selection is now close to the same-run ReactLynx result of 40 ms, but remains slower than Vue Lynx VDOM's 20 ms. Tenth-row updates remain slower than ReactLynx's 70 ms and Vue's 53 ms. Both storms improve by more than half. Mounting changes from 678 ±22 ms to 696 ±12 ms; that small difference overlaps ordinary run variation, so this PR claims no mount improvement.

The mechanism is directly visible in deterministic counters: a 10,000-row selection now executes exactly two Row components, while updating every tenth row executes exactly 1,000. Existing wire guards already show that host commands scale with changed rows; this change makes component replay scale with changed rows too.

The upstream fork measured precisely this mechanism in Huxpro/octane#11: a 10,000-row selection dropped from 10,000 Row executions to exactly two; updating every tenth row dropped from 10,000 to 1,000. On that fork's different host, real-browser selection improved from 813 ms to 274 ms and the tenth-row update from 888 ms to 473 ms. Those are independent prior results, not claims about this branch; this branch will be judged against its own before/after browser runs.

The broader research context is Huxpro/octane#9. Its follow-up Huxpro/octane#21 explicitly stopped speculative code-staged setters and receiver collapse after measuring receiver evaluation at 0.8% of first paint, template expansion at 2.5% of creation, and wire transfer at 1.0% of creation. This change instead addresses the measured owner-replay bottleneck directly.

Changes

  • Remove only the categorical this.transport === null exclusion from the existing full-root retained-subtree eligibility predicate in packages/octane/src/universal-core.ts.
  • Preserve allowRetain, unchanged component identity and Object.is-shallow props, consumed-context invalidation, dirty/visibility/HMR checks, and the existing exclusions for bridges, suspended replay, transitions, regions, portals, and separately scheduled full-root attempts. Do not loosen memo equality, change the compiler, or introduce a new transport ABI.
  • Add real asynchronous MessageChannel regressions for unchanged keyed-child retention, changed-prop reentry, retained listener delivery after a newer acknowledgement, exactly-once effect mount/cleanup, provider invalidation and later readoption, and keyed reordering without remounting or changing public host identity.
  • Instrument only the existing canonical benchmarks/lynx-table profile build with per-operation Row execution counts; compile the counter out of shipping and ordinary browser bundles.
  • Add deterministic changed-row-floor guards: selection executes exactly two rows at both 1,000 and 10,000 rows; a tenth-row update executes exactly 100 and 1,000 rows, respectively. Preserve all existing wire-command, serialized-byte, and storm guards.
  • Include the required patch changeset for the public octane runtime change.

Validation

All affected complete project suites passed 12,531 tests with zero failures: 11,962 Octane development/production plus Three, 320 Lynx, and 249 Rspeedy/Rsbuild/Vite/Rspack plugin tests. The eight affected source, testing, and type-test configurations passed. Repository-wide aggregate commands remain accurately unchecked.

  • pnpm format:check — repository-wide check not yet run.
  • pnpm typecheck — aggregate typecheck not yet run.
  • pnpm test — aggregate test command not yet run.
  • Targeted development/production universal transport regressions, red-checked against the restored transport exclusion — 48/48 transport tests passed.
  • ./node_modules/.bin/vitest run --project octane --project octane-prod --project three — 11,962/11,962 tests passed.
  • ./node_modules/.bin/vitest run --project lynx --reporter=json --outputFile=/private/tmp/octane-lynx-transported-retention-tests.json — 320/320 tests passed across 54 suites and 24 files; zero failed or pending.
  • ./node_modules/.bin/vitest run --project rspeedy-plugin --project rsbuild-plugin --project vite-plugin --project rspack-plugin — 249/249 integration tests passed.
  • ./node_modules/.bin/tsgo --noEmit -p packages/octane/tsconfig.json
  • ./node_modules/.bin/tsgo --noEmit -p packages/lynx/tsconfig.json
  • ./node_modules/.bin/tsgo --noEmit -p packages/lynx/tsconfig.testing.json
  • ./node_modules/.bin/tsgo --noEmit -p packages/lynx/typetests/tsconfig.json
  • Octane/Three source and type-test configurations plus the Rspeedy plugin typecheck — all remaining affected TypeScript configurations passed.
  • node benchmarks/bench.mjs --ratios lynx-table — 16/16 guards passed, including all four exact row-render floors and unchanged existing wire/storm guards.
  • Same-host, same-browser, same-reference before/after run at 1,000 and 10,000 rows, three samples each: node benchmarks/lynx-table/web/run-web.mjs --scales 1000,10000 --reps 3.
  • Verify no regressions in keyed row identity, effects, native listeners, refs, context, transport acknowledgements, and real engine-delivered taps.
  • pnpm sync, scoped Prettier validation, git diff --check, and changeset validation.

Risk / follow-ups

  • Retention must never hide changed props or contexts, drop listeners after an asynchronous acknowledgement, skip required effect cleanup, alter keyed host identity, or preserve a subtree that was invalidated by visibility, dirty state, a transition, or a full-root replay. The new async transport regressions are intended to make those public behaviors observable.
  • The existing @for item lambda may still allocate descriptors for unchanged items; retained component adoption removes row-body execution, not every parent-loop allocation. Report remaining browser gaps honestly.
  • Browser wall-clock timings include host-specific layout and publication costs. Do not infer native Android/iOS paint or startup behavior from Chromium, and do not treat the earlier fake-PAPI parity result as proof of browser parity.
  • A no-worklet lazy main-thread bridge and absolute per-slice gzip budgets, as explored in Huxpro/octane#15, are explicitly deferred to a separate, narrowly scoped bundle-size PR. That fork measured a 2,556-byte (3.6%) main-thread gzip reduction with unchanged background bytes, but no measurable first-paint gain; it does not address transported owner replay and is not included here.

Provenance

  • An agent produced this diff (agent-authored)

Note

High Risk
Changes universal render retention for async transport commits; incorrect retention could skip updates, break listeners/effects, or desync acknowledgement ordering—mitigated by new transport regressions and deterministic render-breadth gates.

Overview
Transported universal roots can now reuse unchanged keyed component subtrees on ordinary full-root commits by dropping the blanket transport === null check from retainEligible in universal-core.ts. Existing guards (unchanged props, context invalidation, dirty/visibility, bridges, transitions, replay) stay in place.

New async transport tests cover keyed-child retention, context-driven invalidation, listener delivery after acknowledgement, effect mount/cleanup, and reordering without remounting hosts.

The lynx-table deterministic harness adds profile-only Row body render counts and CI ratio floors (e.g. two rows on select, ceil(rows/10) on tenth-row updates at 1k and 10k) alongside existing wire-command/byte gates.

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

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.

1 participant