Skip to content

Performance roadmap: targeted updates, JSX lowering, DOM mounting, SSR, reconciliation, and bundle budgets #611

Closed

Description

@domgan-oai

Goal

Reduce avoidable rendering work, live DOM mutations, server-side allocations, reconciliation churn, and shipped JavaScript while preserving Octane's existing component, hook, context, lifecycle, hydration, transition, and immutable-update contracts.

Treat these six workstreams as independently measurable and independently landable investigations. Record a relevant baseline before implementation and reject changes that merely shift cost into compilation, hydration, garbage collection, or less-visible execution paths.

Existing evidence

  • The checked-in signal-favoring work gate shows one shallow text update taking 10 renderBlock calls and 0 createElement calls through .tsrx, versus 200 renderBlock calls and 199 createElement calls through .tsx.
  • The checked-in row-application bundle baseline reports approximately 22,498 bytes gzip for .tsrx versus 39,455 bytes gzip for .tsx.
  • The keyed-list runtime explicitly documents that a selected-row change can reevaluate 1,000 survivor bodies even though only two classes change.
  • These are checked-in historical baselines, not a claim about an unmeasured current run.

References: benchmarks/signal-favoring/work.mjs, benchmarks/baselines/local/bundle-size.json, packages/octane/src/runtime.ts.

Progress

  • 1. Compiler-proven keyed selection with changed-row-only updates — completed in perf: specialize compiler-proven keyed selection updates #613 (merged 2026-08-07). Production selection now updates only the previous and next rows; the 10,000-row regression guard measured an 11× improvement against the JSX control.
  • 2. Reduce .tsx descriptor and component-dispatch overhead — completed in perf: lower proven JSX components through compiled renderers #619 (merged 2026-08-07). Compiler-proven JSX components now reuse existing renderers: shallow updates dropped from 200 to 20 component renders and from 199 to 19 descriptor allocations, with unchanged application bundles.
  • 3. Optimize compiler-certified keyed list mounting. — completed in perf: streamline compiler-certified keyed host mounting #621 (merged 2026-08-07). Detached fragments were benchmarked and rejected after slowing production mounts by 13–18%; compiler-certified direct mounting instead cuts TSRX/JSX framework calls by 25%/19% while preserving ordinary live DOM insertion.
  • 4. Optimize server-rendered loop throughput and allocations. — completed in perf: speed up server-rendered HTML escaping #629 (merged 2026-08-07). Native eager array snapshots remain intact; optimizing the measured HTML escaping bottleneck instead improved escaped SSR throughput by 20.8% and reduced sampled allocation volume by 14.1%.
  • 5. Reuse bounded scratch storage for general keyed reorders. — completed in perf: reuse bounded keyed-reorder scratch storage #630 (merged 2026-08-07). Warmed JSX/TSRX general reorders avoid both typed-array allocations (8 KB per 1,000 rows; 80 KB per 10,000 rows), with exclusive nested leases and a 128 KiB retained-storage ceiling.
  • 6. Add deterministic minimal-import bundle reachability budgets. — completed in perf: add minimal-import bundle reachability budgets #631 (merged 2026-08-08). Ten public production scenarios enforce 30 raw/gzip/Brotli ceilings, executable behavioral checks, and dependency-graph isolation.

Roadmap status: All six independently reviewed workstreams are merged: #613, #619, #621, #629, #630, and #631.

Workstreams

1. Compiler-proven keyed selection with changed-row-only updates

Investigate recognizing keyed-list expressions such as selected === row.id when the iterable and row identities are unchanged, the equality operand matches the list key, selection is the only relevant changed dependency, and the host binding is compiler-proven safe for targeted updates.

Use the existing keyed block lookup to update the previously selected and newly selected rows without reevaluating every unaffected survivor. The owning component must still rerender normally.

Validate duplicate keys, initial/null selection, repeated selection, immutable row replacement, context changes, hydration, refs, effects, Suspense, transitions, rollback, and teardown. Add deterministic survivor-body and DOM-write counters across multiple list sizes.

Likely owners: packages/octane/src/compiler/compile.js, packages/octane/src/runtime.ts, benchmarks/js-framework/.

2. Reduce .tsx descriptor and component-dispatch overhead

Extend existing compiler-proven component, region, host, and list specializations to more safe .tsx authoring shapes so the compatibility path approaches equivalent .tsrx work.

Focus on unnecessary createElement descriptors, redundant full component blocks, avoidable child-slot dispatch, and optional runtime graphs retained only by the descriptor path. Preserve authored return behavior, spreads, refs, context, conditional hooks, error boundaries, and component rerender guarantees.

Track renderBlock, componentSlot, componentSlotLite, childSlot, createElement, DOM writes, generated JavaScript, and final application/framework gzip and brotli sizes. Extend existing production work ceilings instead of relying exclusively on timings.

Likely owners: packages/octane/src/compiler/compile.js, packages/octane/src/runtime.ts, benchmarks/signal-favoring/work.mjs, benchmarks/codegen-size/, benchmarks/bundle-size/.

3. Optimize compiler-certified keyed list mounting

Evaluate building eligible initial list fills and contiguous insertions in a DocumentFragment, followed by a single insertion into the live parent.

Evaluation in #621: Same-session Chromium benchmarks found detached fragment construction slowed 10,000-row production mounts by 13–18%, despite replacing thousands of live-parent insertions with one fragment commit. The proposed implementation therefore preserves ordinary connected DOM insertion and specializes compiler-certified initial host-row mounting instead: TSRX production calls fall from 32,051 to 24,048 (25%) and JSX calls from 47,070 to 38,066 (19%), with faster 10,000-row mounts in both dialects. Existing append/prepend/middle reconciliation remains unchanged and receives explicit identity, insertion, event, and lifecycle coverage.

Restrict the fast path to compiler-certified, single-host-root rows where detached construction cannot change observable behavior. Preserve block ownership, anchors, DOM order, keyed identity, lifecycle/ref timing, custom-element connection behavior, mutation visibility, hydration adoption, Suspense recovery, transition journaling, rollback, and cleanup. Determine whether a minimum list-size threshold is necessary.

Measure live-parent insertBefore counts, initial mount, append/prepend/middle insertion, allocations, and small-list regressions.

Likely owners: packages/octane/src/runtime.ts (mountItemsLinear, keyed insertion branches), packages/octane/src/compiler/compile.js, benchmarks/js-framework/.

4. Optimize server-rendered loop throughput and allocations

Ordinary server-rendered @for output currently materializes iterables with Array.from(...), including values that are already arrays. Investigate a compiler-proven or carefully guarded plain-array fast path that avoids unnecessary copies.

Evaluation in #629: The 10,000-row production SSR fixture spends only about 0.64% of sampled allocated bytes and 0.025% of render time on its eager array snapshot. Reusable snapshots that preserve custom iterators, sparse arrays, proxies, observable getters, render-time mutation, and suspension were 6–20× slower than the native Array.from fast path. The proposed implementation therefore preserves the exact existing snapshot and instead optimizes escaped text inside server-rendered loops: 120 balanced production renders improve from 3.7462 ms to 2.9676 ms (20.8%), sampled allocation volume falls from 249.04 MB to 213.98 MB (14.1%), and normal/streaming SSR output remains byte-identical. A deterministic gate requires zero regex escaping passes and exactly one 10,000-item eager snapshot.

Preserve custom array iterators, sparse arrays, proxies, observable getters, iterable consumption, nullish inputs, render-time mutation, suspension, and item identity. Avoid a broader helper or runtime branch unless measured allocation and throughput improvements justify it.

Measure SSR throughput, allocation counts, heap growth, generated output, streaming behavior, and hydration-equivalent HTML.

Likely owners: packages/octane/src/compiler/compile.js, packages/octane/src/runtime.server.ts, benchmarks/ssr-throughput/, benchmarks/streaming-ssr/.

5. Reuse bounded scratch storage for general keyed reorders

Investigate reusing typed-array scratch storage currently allocated during the general longest-increasing-subsequence reconciliation path.

Evaluation in #630: Production .tsrx and .tsx reversals, rotations, and shuffles previously allocated two Int32Array buffers per general reorder (8,000 bytes for 1,000 rows; 80,000 bytes for 10,000 rows). Exclusively leased source scratch and synchronous LIS predecessor scratch now eliminate both warmed allocations while retaining at most 128 KiB; 18,000-row operations allocate disposable buffers, and explicit garbage collection confirms 80,000 bytes retained after growth and shrink. Deliberately sharing a live source lease fails the new mixed nested-reorder regression. The implementation preserves exact survivor identity and DOM moves, passes 10,835 development/production core tests plus the existing React and TodoMVC guards, and adds 71/77 gzip bytes to the TSRX/JSX production bundles. Minor-GC collection counts were unchanged; no collection-count improvement is claimed.

Allocate lazily only when that path is reached; isolate storage across nested/reentrant reconciliations; bound or shrink retained capacity after unusually large lists; and clear any temporary object references before returning, throwing, suspending, or rolling back.

Preserve existing prefix/suffix paths, small-displacement shortcuts, minimal move behavior, duplicate-key handling, identity, and cleanup. Measure repeated shuffles/reversals, allocation volume, garbage-collection pressure, retained heap after large-list shrinkage, and tiny-list overhead.

Likely owners: packages/octane/src/runtime.ts (reconcileKeyed, lis), benchmarks/js-framework/run-reorder.mjs, benchmarks/lifecycle-memory/.

6. Add deterministic minimal-import bundle reachability budgets

Complement existing whole-application bundle suites with narrow production-build scenarios that lock the incremental cost of commonly used entry points:

  • createRoot and a minimal host render.
  • Basic state/effect hooks.
  • Context.
  • hydrateRoot and deferred hydration.
  • Suspense and transitions.
  • Representative lightweight binding entry points.

Evaluation in #631: Ten real public-entry production bundles now cover isolated hydration-event capture, disposable specialized and reusable roots, state/effects, context, ordinary and deferred hydration, Suspense/transitions, and vanilla/hooked Zustand bindings. Every measured IIFE runs unchanged in an isolated browser realm and proves observable DOM, updates, adoption, deferred click replay, store notifications, or cleanup. Hydration capture is 1,666 bytes gzip and vanilla Zustand is 428 bytes gzip; neither reaches the Octane runtime. A compiler-specialized disposable root is 16,240 bytes gzip, versus 35,409 bytes for a genuinely reusable public root. Thirty raw/gzip/Brotli ratio guards enforce committed ceilings with 3.0–3.9% headroom, and module-graph guards reject accidental runtime, React, server, profiling, or serialization dependencies. Two independent builds were byte-identical; deliberate budget, leaked-runtime, and incorrect-behavior controls failed as intended. Existing full-application bundles and fixed compiler output remained byte-identical, and 120 focused hydration, production-bundle, Zustand, React-parity, and MCP-server tests passed.

Measure complete reachable dependency graphs with consistent production defines, minification, gzip, and brotli. Do not externalize dependencies that real applications ship. Keep existing full-application and generated-code budgets as the primary end-to-end controls.

Likely owners: benchmarks/bundle-size/, benchmarks/bench.mjs, benchmarks/baselines/ratios.json, relevant package exports.

Validation and acceptance criteria

  • Capture a same-session, same-command baseline before each implementation.
  • Add correctness coverage for every affected execution mode and observable lifecycle contract.
  • Add deterministic work/DOM/allocation counters or ratio guards where timing noise would obscure the effect.
  • Compare .tsrx and .tsx paths and verify production, SSR, hydration, transitions, and cleanup where applicable.
  • Demonstrate improvements outside observed variance without regressing unrelated workloads or bundle size.
  • Run relevant existing suites, including js-framework, js-framework-reorder, signal-favoring, ssr-throughput, streaming-ssr, lifecycle-memory, compiler-throughput, codegen-size, and bundle-size as applicable.
  • Keep each workstream independently reviewable and document tradeoffs, invalidation/lifetime rules, and remaining risks.

Activity

  1. added
    enhancement
    agent-authored
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-authoredenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions