Skip to content

perf(compiler): add opt-in fixed primitive child bindings - #1226

Merged
domgan-oai merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/dom-binding-fixed-primitives
Sep 21, 2026
Merged

domgan-oai merged 3 commits into
octanejs:mainfrom
openai-oss-forks:codex/dom-binding-fixed-primitives

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add opt-in specialization for primitive props in named DOM binding child programs. Select repeated presentation fields with domBindingFixedProps: ['variant', 'radius']; default requests remain generic and shared. The versioned extraction request carries proven values so the selected child program can fold unreachable presentation branches. Ordinary renderer output retains its authored behavior.

The public seven-child fixture has distinct literal labels and one shared extracted child module in both profiles. The child shrinks from 828 to 699 gzip bytes; its complete production binding/runtime bundle shrinks from 11,825 to 11,652 gzip bytes (173 bytes), and by 545 minified bytes. Source, tooling, and semantic controls are matched; only the explicit propagation option differs. These measurements do not establish a default application or startup benefit.

Changes

  • Expose the default-off prop-name allowlist through compile, createOctaneCompiler, octane/compiler/vite, and @octanejs/vite-plugin, including Vite compiler resets. Keep literal labels and IDs live to share extracted programs.
  • Carry explicit primitive facts in version-2 extraction requests; existing version-1 ordered-key requests retain their generic identity. Missing fields and uncertain values stay live, and explicit undefined retains supported literal-default semantics.
  • Fold proven expressions and setup aliases copy-on-write. Validate used facts during preparation and preserve native callback assignments, shadowing, and execution order.
  • Omit inactive conditional payloads while keeping authored site IDs, arm indices, range proofs, closed-prop validation, and renderer hydration handoff.
  • Add meaningful behavioral/default-profile/wrapper regressions, a patch changeset, and a seven-child benchmark with six strict ratio guards exposed through the unified runner and MCP tool.

Validation

  • pnpm sync, scoped formatting, and git diff --check
  • Core and Vite package tsgo; public TSRX fixture and Vite option type checks
  • Final affected compiler, behavior-root, and MCP suites: 2,898 tests across 73 project-files
  • Vite options, integration, resolution, and public wrapper suites: 63 tests across four files
  • node benchmarks/bench.mjs --quick --ratios dom-binding-fixed-props: all six guards pass, including full-bundle non-growth and one shared child module with seven distinct labels
  • Matched frozen 16-source default-profile comparison: equal per-file raw/minified/gzip bytes and totals (210,637 / 102,508 / 34,338 bytes)
  • Default automatic propagation produced multiple child modules in the pre-fix multi-child control; the default profile now stays shared and the bounded opt-in removes branches without specializing labels
  • Both new Vite forwarding cases failed with generic version-1 requests before their fixes; callback assignment/update and lexical-shadowing regressions also have observed pre-fix failures
  • Full local pnpm format:check, pnpm typecheck, and workspace pnpm test were not run; current-head CI is required separately

The general codegen-size suite fails its Rspack CSS SSR asset assertion (496.main.cjs plus main.cjs, expected only main.cjs); the unchanged base 34e83cee9 reproduces the same failure. No existing ratio guards or budgets were changed.

Risk / follow-ups

Imported child bodies are unavailable during parent planning, so automatic selection of profitable prop facts is deliberately disabled. Opting in to fields with many different literal values can duplicate programs; measure the complete bundle and select repeated presentation fields. Rspack/Rsbuild wrapper option surfaces are not extended by this change. Consumer adoption and release validation remain separate work.

Specialization adds one primitive comparison per used fact during preparation. CPU, memory, and page latency were not measured. Arbitrary helper calls and module object tables are not evaluated or pruned, and non-finite literal defaults stay live.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Touches DOM binding codegen and runtime prop validation on an opt-in path; default generic child requests are unchanged but enabled builds alter generated programs and failure modes.

Overview
Adds an opt-in domBindingFixedProps compiler option (via compile, bundler, Vite, and @octanejs/vite-plugin) so parent call sites can propagate caller-authored primitive literals into extracted DOM binding child programs. Default extraction stays on the generic shape [1, orderedPropNames]; specialized requests use [2, props, fixedPairs] on the existing octane-props query.

The new fixedBindingProps pipeline constant-folds proven primitives in child projections, drops unreachable conditional/template arms, and emits prepare-time checks that throw if fixed props drift at runtime. Only bounded primitives qualify; dynamic props, callbacks, uncertain reads, and non-finite defaults stay live. Generic plans keep a no-op specializer.

Ships a dedicated dom-binding-fixed-props benchmark (six ratio guards), MCP benchmark registration, fixture/docs, and broad compiler/behavior/plugin tests covering adoption, mount, updates, hydration handoff, and shared child modules across differing literal labels.

Reviewed by Cursor Bugbot for commit e01bbb7. 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 Sep 21, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 21, 2026 20:58
@domgan-oai
domgan-oai marked this pull request as draft September 21, 2026 21:19
@domgan-oai domgan-oai changed the title perf(compiler): specialize fixed primitive child bindings perf(compiler): add opt-in fixed primitive child bindings Sep 21, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 21, 2026 21:31
@domgan-oai
domgan-oai merged commit 3a859dd into octanejs:main Sep 21, 2026
48 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