Skip to content

perf: lower proven JSX components through compiled renderers - #619

Merged
trueadm merged 1 commit into
octanejs:mainfrom
openai-oss-forks:feat/tsx-component-dispatch-lowering
Aug 7, 2026
Merged

trueadm merged 1 commit into
octanejs:mainfrom
openai-oss-forks:feat/tsx-component-dispatch-lowering

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

  • Lower production-only, private, nonescaping, zero-argument, setup-free .tsx components through their existing compiled host renderers and lightweight component slots; preserve the original callable components and inspectable JSX descriptors.
  • Fail closed for exported, stateful, escaped, dynamic, or defaultProps-sensitive components, and add behavioral regressions for hooks, context, live getters, descriptor escapes, spreads, refs, keys, Suspense, error boundaries, and SSR/hydration.
  • Ratchet the existing production Chromium work gates to the measured reductions in renders, full component slots, child dispatch, descriptors, and teardown.
  • Part of Performance roadmap: targeted updates, JSX lowering, DOM mounting, SSR, reconciliation, and bundle budgets #611.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test — 16,797 tests across 1,556 files (run with NODE_OPTIONS=--no-experimental-webstorage for local Node 26 compatibility).
  • targeted tests: 1,128 client/hydration behavioral cases across development and production, plus 1,061 compiler regressions covering frozen ASTs and source maps.
  • node benchmarks/bench.mjs --quick --ratios signal-favoring js-framework — all 11 applicable performance-ratio guards pass.
  • node benchmarks/bench.mjs --quick codegen-size bundle-size — the fixed code-generation corpus and normalized .tsx/.tsrx application/framework bundles are unchanged.
  • Production shallow-update work: component renders 200 → 20, full component slots 100 → 10, child slots 99 → 9, JSX descriptors 199 → 19; visible text updates remain exact.
  • Production mount renders 201 → 21; teardown blocks 201 → 21 and scopes 201 → 111.
  • Order-balanced shallow-update .tsx/.tsrx ratio improves 3.46× → 1.04×; generated 100-component application output decreases 86,630 → 61,398 bytes.
  • A 250-component compiler scaling probe decreases generated output 180,731 → 108,964 bytes without quadratic analysis growth.

Risk / follow-ups

  • Eligibility is limited to same-module private components with no escaping references, parameters, setup, hooks, dynamic props, or unsafe descriptor holes; unsupported shapes retain the existing implementation.
  • Existing recursive-context and global code-generation ratio ceilings already fail against checked-in upstream baselines. Recursive-context production output and all deterministic work counters are byte-for-byte unchanged; fixed code-generation and application bundles are unchanged.

Provenance

  • An agent produced this diff (agent-authored)

Note

Medium Risk
Compiler-only optimization with conservative escape analysis; incorrect eligibility could change rendering or descriptor semantics, mitigated by extensive tests and unchanged paths for hooked or escaping components.

Overview
Production JSX now routes compiler-proven same-module, private, hookless components through their existing hoisted host renderers and componentSlotLite instead of building descriptors and full component slots on every nested call.

Eligibility is fail-closed: collectPrivateUnescapedComponents only keeps module-local functions whose references never escape and that appear as attribute-free, childless JSX under an immediate host return; exported, hooked, dynamic, keyed, spread, or stored JSX still use the prior path. Fragment extraction threads staticFragmentRenderer metadata so call sites reuse the compiled renderer and static props while authored component functions and inspectable descriptors stay unchanged for direct calls and escapes.

Benchmarks tighten octane-jsx production work ceilings (e.g. shallow update: ~200→20 block renders, ~100→10 full slots, ~199→19 descriptors). Tests add nested-component fixtures and coverage for hooks, context, defaultProps getters, refs/keys/spreads, Suspense, error boundaries, and SSR hydration.

Reviewed by Cursor Bugbot for commit b8460cb. 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 17:58
@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 9fa0b47 into octanejs:main Aug 7, 2026
49 of 52 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 perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants