Skip to content

perf: streamline compiler-certified keyed host mounting - #621

Merged
trueadm merged 1 commit into
octanejs:mainfrom
openai-oss-forks:feat/compiler-certified-fragment-list-mounting
Aug 7, 2026
Merged

trueadm merged 1 commit into
octanejs:mainfrom
openai-oss-forks:feat/compiler-certified-fragment-list-mounting

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

  • Complete the third performance investigation from Performance roadmap: targeted updates, JSX lowering, DOM mounting, SSR, reconciliation, and bundle budgets #611 for compiler-certified keyed host rows in both .tsrx and .tsx.
  • Reject detached DocumentFragment batching after same-session browser measurements showed 10,000-row direct DOM insertion at 7.05 ms versus 8.65–8.85 ms with fragments; end-to-end fragment variants were 13–18% slower.
  • Instead, select narrow, tree-shakable direct host-mount entry points from the production compiler and skip unnecessary per-row component-render bookkeeping while retaining ordinary live-parent insertion, existing keyed-selection optimizations, and guarded native JSX mapping.
  • Add consumer-visible coverage for duplicate keys, throwing getters and retry, represented context, suspension, dynamic JSX children, connected refs, custom elements, controls, hydration, transitions, survivor identity, and delegated events.
  • Extend the production js-framework benchmark with deterministic direct-insertion, identity, event, and whole-production-call gates for both dialects.

Same-session production measurements:

Measurement Upstream This change
TSRX framework calls, 1,000 rows 32,051 24,048 (-25.0%)
JSX framework calls, 1,000 rows 47,070 38,066 (-19.1%)
TSRX 10,000-row mount, 16 ABBA samples 13.45 ms 12.80 ms
JSX 10,000-row mount, 16 ABBA samples 15.50 ms 15.20 ms

The unrelated TodoMVC application is byte-for-byte unchanged after production tree-shaking. Certified row applications retain approximately 399–439 additional gzip bytes in their framework chunks; the existing JSX/TSRX application-size guard remains satisfied.

Part of #611.

Validation

  • pnpm format:check
  • pnpm typecheck
  • NODE_OPTIONS=--no-experimental-webstorage pnpm test (1,556 files; 16,829 tests passed).
  • targeted tests: 40 Octane development/production suites covering 1,362 runtime cases; 36 compiler suites covering 1,061 cases.
  • node benchmarks/bench.mjs --quick --ratios js-framework js-framework-reorder signal-favoring (all 12 applicable ratio guards pass).
  • node benchmarks/bench.mjs --quick codegen-size bundle-size.
  • Same-session upstream/candidate Chromium ABBA timing, precise production call coverage, and normalized application/framework gzip comparisons.

Risk / follow-ups

  • Activation is production-only and fails closed for non-HTML or unknown hosts, custom elements, customized built-ins, refs, spreads, controls, resources, render-time calls, nested authored components or control flow, @empty, indexed/destructured loops, universal renderers, hydration, transitions, adoption, first slot creation, non-array inputs, and lists below 16 rows. Native JSX mapping retains its existing array/species/accessor guard and fallback.
  • Existing generic reconciliation remains unchanged; append, prepend, and middle insertion continue to use their proven paths and now have explicit survivor-identity and live-insertion coverage. Further lightweight specialization for contiguous insertions should be considered separately because adding dispatch to the generic reconciler would increase unrelated application bundles.
  • The reordered Ripple fixture has an existing, explicitly allowlisted upstream identity failure; both Octane dialects pass.
  • The historical code-generation gzip/source ratio ceiling is already exceeded on untouched upstream (26,533 / 24,722 = 1.073 > 1.04); this change adds eight gzip bytes, leaves its diagnostic sentinel unchanged, and does not weaken any guard.

Provenance

  • An agent produced this diff (agent-authored)

Note

Medium Risk
Touches core list mounting and reconciliation entry points with many fail-closed guards, but incorrect certification could break DOM identity, hydration, or lifecycle semantics for edge-case lists.

Overview
Adds a narrow fast path for mounting large keyed lists whose item bodies are compiler-proven safe plain HTML host trees, cutting per-row component-render overhead while keeping one direct live-parent DOM insertion per row (no DocumentFragment batching).

The compiler introduces hostMountSafe via isHostMountSafeTree (allowlisted tags/attrs) and emits fastForBlock, fastKeyedForBlock, or fastMapSlot instead of the generic helpers when eligibility holds (production auto-memo, single host root, no refs/controls/components, etc.). The runtime mounts through mountFastHostItems when the slot is empty, arrays have ≥16 items, and hydration/transitions are inactive; otherwise it falls back to existing forBlock / keyedForBlock / mapSlot.

Benchmarks extend run.mjs with untimed Octane gates for direct tbody insertions, survivor identity, events/selection, zero fragment commits, and jitless production call ceilings. Tests add broad FastHost* fixtures covering hydration, suspense, context, refs, controlled inputs, and error rollback.

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

@trueadm
trueadm marked this pull request as ready for review August 7, 2026 19:29
@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
@trueadm
trueadm merged commit 60004f0 into octanejs:main Aug 7, 2026
21 of 47 checks passed
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 7, 2026
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 7, 2026
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