Skip to content

perf: keep scoped JSX descriptors on fast shapes - #1013

Merged
domgan-oai merged 2 commits into
octanejs:mainfrom
openai-oss-forks:codex/scoped-descriptor-shapes-981
Sep 9, 2026
Merged

domgan-oai merged 2 commits into
octanejs:mainfrom
openai-oss-forks:codex/scoped-descriptor-shapes-981

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

Address the scoped JSX descriptor and props dictionary-mode finding in #981 on the client and server runtimes.

Why

A new children getter per scoped element changes V8's accessor transition on later instances; overwriting the descriptor's children: null field also normalizes its shape. Complete scoped-value records create a fresh set of five getters on every instance. These descriptors occur in compiled value-position JSX, including lists with dynamic children.

Changes

  • Share scoped-element and scoped-value accessor identities, with a per-instance private resolver. Construct scoped descriptors without a temporary children data field and keep source/default children reads and enumerable key order intact.
  • Preserve deferred children through cloneElement, Children.map, and Children.toArray, including nested scoped values, custom production getters, inherited setters, and SSR.
  • Add public client/server/TSRX/TSX regressions, a production benchmark with plain-element controls and semantic hashes, MCP benchmark registration, and patch changesets for octane and @octanejs/mcp-server.

Validation

  • pnpm sync; no generated changes.
  • Direct Prettier check on changed files, git diff --check, tsgo --noEmit -p packages/octane/tsconfig.json, and standalone TSX fixture typecheck.
  • Scoped JSX, clone, signals, SSR, and hydration tests: 1,019/1,019 in 19 Vitest project runs; added nested-value clone tests: 4/4 in dev/prod.
  • Direct node scripts/check-changesets.js && node scripts/check-release-plan.mjs; production Octane build; node benchmarks/bench.mjs --quick scoped-descriptor-shapes (48 targets).
  • Frozen production baseline vs candidate, B–C–C–B with 13 samples per run, five warmups, client/server in separate processes: 48/48 public semantic hashes match; a nested scoped-value clone/map preflight reproduces the earlier regression on the previous build and passes the final build. V8 %HasFastProperties reports fast for four of four scoped elements, props objects, and value descriptors in both runtimes.
  • Current-head CI passed 26/26 jobs at 547a369, including formatting, typecheck, Node 24 tests, React parity, browser integration, and package validation. The repository-wide commands were not separately run locally; direct scoped equivalents passed. A pnpm dependency-status preflight attempted an install through an unavailable internal registry for the final local formatter and changeset commands, so their direct equivalents were run.

Risk / follow-ups

At 1,024 elements, matched-control-adjusted scoped-element enumeration is 0.09× client / 0.08× server and scoped-value enumeration is 0.18× / 0.17×. Scoped-value creation is 1.02× / 1.04× and field reads are 1.08× / 0.85×, within observed run drift; full SSR throughput is inconclusive. The benchmark measures Node property access rather than browser layout, GC pauses, or full application throughput. Exceptional prototype/setter paths preserve ordinary copy semantics and may remain dictionary-mode. The #981 issue remains open for its other findings.

Provenance

  • An agent produced this diff (agent-authored)

Note

Medium Risk
Touches core JSX descriptor creation, cloning, and SSR serialization paths used by compiler value-position JSX; behavior is heavily tested but edge cases around prototypes and accessor identity remain sensitive.

Overview
Refactors scoped element and scoped value JSX descriptors on client and server so V8 can keep fast object shapes: shared children / field getters backed by per-instance symbol resolvers, construction without a transient children data field, and copyScopedElementConfig so spread props, defaultProps, and rare inherited children setters still match prior observable behavior while deferring evaluation.

cloneElement, Children.map, and key replacement keep each element’s deferred child resolver (including scoped values wrapping scoped elements and production custom getters) without resolving children early; SSR paths use the same rules.

Adds a Node-only scoped-descriptor-shapes benchmark (plain createElement controls, semantic hashes, client/server in separate processes), wires it into bench.mjs, docs, and the MCP suite list, plus client/server/TSRX regressions and patch changesets for octane and @octanejs/mcp-server.

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


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

@domgan-oai
domgan-oai marked this pull request as ready for review September 9, 2026 11:53
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Sep 9, 2026
@domgan-oai
domgan-oai merged commit 1c28da5 into octanejs:main Sep 9, 2026
30 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.

1 participant