Skip to content

perf: reuse nested implicit SSR descriptor key prefixes - #1035

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:fix/ssr-nested-key-prefix-981
Sep 10, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:fix/ssr-nested-key-prefix-981

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

  • Reuse one serialized wrapper path for nested implicit SSR descriptor siblings, preserving the exact identity key bytes, async retry behavior, and hydration output.
  • Keep flat and singleton lists on their original small key helper. Prefix state is local to a synchronous container walk; explicit keys and exotic serialization use the existing tuple encoding.
  • Add public SSR retry/streaming regressions, an isolated minified production work gate with flat and explicit controls, benchmark evidence, and a patch changeset.

Continues #981 after #1034; the combined list-key item remains open.

Performance evidence

Compared with merged main afdc3618a on Node 26.4.0 / Apple M5 Max, using frozen minified production bundles:

  • 1,000 full nested implicit key JSON calls become zero, plus one shared path JSON call.
  • Flat implicit calls stay zero; the adjacent explicit key stays one. Fully explicit nested lists retain 1,001 explicit calls and create no shared prefix.
  • All 1,001 rows and complete HTML/CSS bytes match baseline in all three modes. The observer imports its runtime in a separate process before clean timing.
  • Fixture bundle grows by 524 raw / 177 gzip bytes (58,519 → 59,043 / 20,021 → 20,198).
  • Four fresh processes per variant, ABBAABBA order, 350 ms warmup + 2 seconds per mode: final timing ranges overlap; no throughput improvement claimed. A slow baseline process is retained in the published ranges.

Self-review caught a 17.1% flat-list slowdown in the initial larger-helper design. Restoring the original flat/singleton helper removed the separated control distributions. Final rebuilt artifact matches the measured SHA. Full numbers and reproduction commands are in benchmarks/ssr-throughput/README.md.

Validation

  • Current-head CI: 26/26 jobs passed at cfc786198fd14d64bdb970deaa36930e673d16d4. Cursor Bugbot completed successfully with no findings; there are no unresolved review threads. The PR contains live main afdc3618a and has no merge conflicts.

  • Targeted dev/prod SSR, streaming, async retries, descriptor identity, and hydration tests: 28 files / 550 tests passed.

  • Deliberate wrapper-path removal made the new reorder case fail in both modes with another wrapper's settled value; restored implementation passed.

  • tsrx-tsc --noEmit -p packages/octane/tsconfig.json

  • Scoped Prettier checks, git diff --check, changeset/release-plan checks, and pnpm sync

  • Final minified nested work/HTML/CSS gate; existing unkeyed-work.mjs gate

  • Final rebuilt benchmark artifact equals the timed artifact.

  • pnpm format:check (scoped checks run locally)

  • pnpm typecheck (core program checked locally)

  • pnpm test (targeted core suites run locally; repository coverage runs in CI)

Risk / follow-ups

Nested leaf key strings still exist; this removes repeated wrapper-path serialization. Explicit coercion, the per-list key callback, and other #981 items remain open. The local prefix adds a small bundle cost; timing does not establish a throughput gain. No state is retained across retries, requests, or aborts.

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
Changes SSR child-list identity key generation used by Suspense retries and hydration; behavior is heavily tested but mistakes could mis-associate async row results.

Overview
Server rendering now reuses one serialized wrapper-path prefix for siblings inside nested implicit descriptor lists, appending each position index instead of calling JSON.stringify on the full [path,"index",i] tuple every time. Flat top-level lists and single-child containers still use the original scopedSsrDeoptKey fast path so common cases are not slowed down.

The optimization is scoped to a synchronous flattenSsrChildContainer walk: prefix state does not carry across retries, explicit keys still use the full tuple encoding, and patched JSON.stringify / exotic paths fall back to the prior behavior so identity bytes stay compatible with hydration and async Suspense retries.

Adds SSR regressions for nested sibling ordering under interleaved retries and out-of-order streaming, plus an opt-in nested-work.mjs production gate (nested vs flat vs fully explicit controls) and benchmark notes documenting reduced JSON work without claiming throughput wins.

Reviewed by Cursor Bugbot for commit cfc7861. 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 10, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 10, 2026 16:20
@domgan-oai
domgan-oai merged commit 3459196 into octanejs:main Sep 10, 2026
50 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