Skip to content

perf: reduce core runtime and compiled application bundles - #638

Merged
domgan-oai merged 2 commits into
octanejs:mainfrom
openai-oss-forks:fix/632-core-runtime-compiler-bundle-size
Aug 8, 2026
Merged

domgan-oai merged 2 commits into
octanejs:mainfrom
openai-oss-forks:fix/632-core-runtime-compiler-bundle-size

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

  • Reduce JavaScript retained by Octane's own server runtime and production compiler output without changing supported rendering, hydration, streaming, callback, namespace, event, style, or View Transition behavior.
  • Address seven independently measured core-owned opportunities from Track bundle size, tree shaking, bootstrap side effects, SSR, and compiled output #632; no ecosystem binding packages, package metadata, or upstream bootstrap code are modified.

Why

  • An unrelated server helper previously retained the complete Hydrate/SSR graph: the minimal hookSlots production bundle falls from 12,595 to 204 gzip bytes.
  • Buffered renderToString falls from 13,667 to 10,889 gzip bytes; realistic buffered, prerendered, pipeable, and Worker applications save 666–1,207 gzip bytes.
  • Real Vite application/framework splits improve across all four measured applications: TodoMVC −186 gzip bytes, Weather −66, js-framework −54, and chat −17.

Changes

  • Bind permanent-static Hydrate metadata to a pure, Hydrate-owned initializer; construct the streaming swap script lazily and memoize it; make unused SVG lookup initialization tree-shakeable.
  • Cache compiler-generated lifetime-invariant callbacks in one immediately published cell while preserving authored dependencies, Object.is, suspension/replay, and callback identity.
  • Canonicalize proven-identical immutable DOM hosts in compiler binding bags while preserving independent hosts, spread/ref cleanup, controlled values, and hydration.
  • Intern exact production templates by HTML, parser namespace, and fragment mode while preserving every authored source origin and source map.
  • Keep optional View Transition hints, unique delegated event registration, and safe scoped-style initialization attached to their retained exported component; preserve development/HMR, shared-event, hoisting, barrel, style-order, and module-effect fallbacks.
  • Extend upstream executable production-bundle coverage from 24 to 27 scenarios and from 72 to 81 raw/gzip/Brotli guards, including isolated server hooks, buffered server rendering, and live-versus-dead component-owned effects.
  • Add an octane patch changeset.

The existing codegen-size gzip guard had already become impossible on current canonical main: behavioral fixture changes invalidated its historical 24,397 / 23,519 = 1.037× record, and a fresh unchanged-base run now measures 26,666 / 24,713 = 1.079×. This change reduces that same current corpus to approximately 26,130 / 24,713 = 1.057× and explicitly rebases the guard to 1.06×. This is stricter than the actual current-main baseline; it does not preserve the stale, already-failing 1.04× claim.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test — the unrestricted cross-package run is interrupted by sandbox network-approval cancellation in unrelated integration projects; the complete owning Octane development/production matrix and the affected isolated integrations all pass below.
  • pnpm exec vitest run --project octane --project octane-prod --reporter=dot — 774 files / 10,960 tests passed on the core-change head before the latest upstream merge, with VITEST_MAX_WORKERS=4 under Node 22.
  • pnpm sync
  • pnpm changeset:check
  • node benchmarks/bench.mjs --ratios bundle-reachability codegen-size — 85/85 applicable guards pass under Node 22 across all 27 executable scenarios, preserving upstream's Vite/esbuild package coverage.
  • merged-head verification: full pnpm typecheck, 282 SSR/hydration/streaming tests, 105 focused core integration tests, and all 85 bundle/codegen guards.
  • targeted tests: 282 server/hydration/streaming cases, 329 compiler/source-origin/style/View Transition/SVG/hydration cases, 235 callback/refs/controlled-input cases, executable production SSR and component ownership, plus isolated CMDK and Jotai integration parity.

Risk / follow-ups

  • Component-owned effects are restricted to provably safe production modules; development/HMR, hoisted declarations, shared events, module-observable style ordering, unowned styles, and unprovable transition references retain their existing conservative behavior.
  • The memoized streaming-script getter adds a small cold-path branch only when a response actually contains pending streaming boundaries.
  • The codegen-size guard rebase is explicitly documented above because its committed historical corpus no longer matches the current fixtures.

Provenance

  • An agent produced this diff (agent-authored)

Note

Medium Risk
Touches production compiler emission and server runtime initialization paths with broad behavioral test coverage; component-owned effects and codegen-size guard rebasing need careful review for edge-case regressions.

Overview
Shrinks Octane’s server runtime and production compiler output while keeping hydration, streaming, callbacks, styles, events, and View Transitions behaviorally the same.

Server runtime defers Hydrate permanent-static setup behind a pure initializer, builds the streaming swap script only when pending boundaries exist, and makes SVG tag lookup initialization tree-shakeable—so isolated helpers like hookSlots no longer drag the full Hydrate/SSR graph.

Production compiler adds several size wins: lifetime-invariant auto-useCallback results cache in one published cell (stable across suspend/replay); binding bags dedupe immutable DOM host locals; identical production templates intern by HTML/namespace/fragment with source-map aliases preserved; and in safe multi-export modules, delegated events, scoped styles, and ViewTransition hints move from module prelude into the retained exported component initializer (unused siblings no longer pull auxclick, dead styles, or __vtSeen). Dev/HMR, shared events, hoisting, and style-order edge cases still fall back to conservative module-level behavior.

Benchmarks & tests extend bundle-reachability with server-hooks, server-render, and component-owned-effects (81 byte guards), rebase codegen-size gzip to 1.06×, and add compiler, SSR production-bundle, callback-identity, and spread-host coverage. Patch changeset for octane.

Reviewed by Cursor Bugbot for commit c48808f. 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 8, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review August 8, 2026 01:00
@domgan-oai
domgan-oai merged commit 136b0e3 into octanejs:main Aug 8, 2026
13 of 31 checks passed
trueadm added a commit that referenced this pull request Aug 8, 2026
Regenerate lockfile-derived parity/evals records after the React
Compiler benchmark rollout (#639) and bundle-size reductions (#638).

Co-Authored-By: Claude Fable 5 <[email protected]>
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
jonkwheeler pushed a commit to jonkwheeler/octane that referenced this pull request Aug 8, 2026
leonidaz pushed a commit that referenced this pull request Aug 9, 2026
* feat: add Solana React binding

* refactor(solana-react): stabilize wallet snapshots

* fix(solana-react): address preflight review findings

* chore(evals): refresh corpus lockfile hashes

* Address PR review feedback (#387)

- version reactive client snapshots
- normalize omitted query options compiler slots

* style(solana): format hook-slot fixes

* fix(solana): defer reactive subscriptions to consumers

* feat(playground): showcase solana client context

* fix(solana-react): stabilize derived hook slots

* chore(evals): refresh solana playground digest

* fix(solana-react): replace clients during render

* chore: refresh package inventory

* chore: refresh binding parity gaps

* chore: refresh binding status inventory

* fix(solana-react): keep null request queries idle

* style(solana-react): format null query guard

* fix(ci): retain trusted Octane peer resolution

* fix(solana-react): validate capabilities before cancellation

* fix(ci): stabilize merged RainbowKit hydration checks

* chore(solana-react): refresh package inventory

* fix(solana-react): make package tests cwd-independent (#387)

* fix(solana-react): stabilize idle refetch

* chore(solana-react): refresh parity gap index

* chore(solana-react): refresh bindings status

* chore(solana-react): refresh merged inventories

* fix(solana-react): treat superseded sign failures as cancellation

Check active generation and context before wrapping sign errors as signing-failed.

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

* fix(website): list solana-react once in Web3 bindings catalog

Remove duplicate @octanejs/solana-react entry from AI/data section;
Web3 is the correct category per Bugbot review.

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

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

Regenerate lockfile hashes and inventory for solana.

* 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)

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

Regenerate lockfile hashes and inventory for solana.

* fix(solana-react): stabilize null-source query result identity

Cache the idle useRequestQuery result object and update it in place when
the underlying TanStack result changes, preserving referential stability
across parent re-renders.

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

* chore(ci): refresh inventories after main merge

Keep generated package/binding inventory and eval corpus digests current after merging origin/main into the solana-react binding branch.

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

* feat(solana-react): add React parity evidence lanes

Wire packages/solana-react into the generic react-parity:check path with a
vendored @solana/[email protected] pin, pristine/adapted runtime lanes, and
repo-authored type probes, while keeping Octane-only conformance outside
parity ownership.

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

* fix(solana-react): expand pristine/adapted parity for query and types

Address leonidaz feedback: run useRequestQuery in the pristine suite with
per-file dispositions and omission/rename controls, adapt the overlapping
cases, and replace repo-authored type probes with upstream __typetests__
lanes plus assertion-group inventories.

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

* fix(solana-react): prefer reactiveStore over send for Kit sources

PendingRpcRequest duck-types expose both APIs; dispatch through
reactiveStore().withSignal so getAbortSignal composition matches upstream.

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

* fix(solana-react): one-for-one adapted parity and expanded type lane

Preserve every selected pristine runtime identity in the adapted suite,
expand the pristine type lane across wallet/transaction/query typetests
with machine-checkable dispositions, and reject thenable ClientProvider
clients at mount.

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

* fix(solana-react): pin pristine-only typetests in type inventory

Include every adapted and pristine-only upstream typetest in
pristine-types.json so assertion-group drift is caught for wallet,
signing, request, and deferred query artifacts.

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

* fix(ci): refresh vitest parity hashes and format solana-react audit

Keep neighbor react-parity manifests aligned after vitest.config.js changed for solana-react lanes, and satisfy Prettier on the new audit file.

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

---------

Co-authored-by: Dominic Gannaway <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: domgan-oai <[email protected]>
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 Oct 3, 2026
The compiled/source gzip guard (maxRatio 1.06) records 26132 / 24713 from
136b0e3 (#638). The suite wrote no numbers from 2026-09-16 until its Rspack
chunk assertion was fixed, so nothing checked it. Main now measures
35039 / 27077 = 1.294x.

Splitting the growth:
- Compiler: the 136b0e3 corpus files the current compiler still accepts
  (14 of 16) compile to 22338 -> 25107 gzip. A sampled timeline plus git
  bisect over that fixed set names 5ead1ff (#1069): +2065 B in one step,
  because every opaque text and attribute binding became signal-capable.
  #1270 kept that design while removing its runtime tax. The rest is gradual.
- Corpus: tests extended the context, boundary, control,
  controlled-forms-diff and components fixtures. Source gzip rose
  24713 -> 27077 and those fixtures add the remaining +6138 compiled bytes.

Both are intended, so the ceiling moves to 1.30, leaving 161 B.

Co-authored-by: Claude Opus 5.5 <[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.

1 participant