Skip to content

perf: avoid implicit SSR descriptor key serialization - #1032

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:fix/ssr-deopt-implicit-index-981
Sep 10, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:fix/ssr-deopt-implicit-index-981

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

  • Use the numeric positional identity for top-level unkeyed SSR descriptor children.
  • Preserve JSON-scoped identities for explicitly keyed and nested children, with async retry, concurrent request, and out-of-order stream regressions.
  • Add an opt-in production SSR work gate that keeps output bytes constant while measuring implicit key serialization.

Why

The server counterpart to #1030 still serialized every top-level unkeyed position into a JSON string and then encoded it for async identity. The existing async encoder has a distinct numeric namespace, so these positions can enter it directly. This continues the open de-opt list item in #981.

Changes

  • Return a numeric index only when an SSR descriptor list leaf has no wrapper path and no explicit key; leave other keys unchanged.
  • Cover changing list shapes across suspended retries, nested unkeyed children, explicit "0", interleaved requests, and streaming reveals in both dev and production test projects. A deliberate omission of the nested-path guard made the regression fail in both projects before restoration.
  • Add a separate SSR fixture with 1,000 unkeyed component descriptors and one explicitly keyed control. The normal throughput fixture is untouched.

Validation

  • pnpm format:files:check on changed files
  • pnpm typecheck:files packages/octane/src/runtime.server.ts packages/octane/tests/ssr-deopt-list-identity.test.ts
  • pnpm exec tsgo --noEmit -p packages/octane/tsconfig.json
  • pnpm changeset:check
  • pnpm exec vitest run --project octane --project octane-prod packages/octane/tests/ssr-deopt-list-identity.test.ts --silent=passed-only (8/8)
  • pnpm exec vitest run --project octane --project octane-prod --silent=passed-only (17,631 passed, 14 expected failures, three unrelated 5-second timeouts while two broad runners competed)
  • Isolated rerun of timed-out Volar and HMR files in both projects (96/96 passed at default timeout)
  • Production SSR work gate: baseline/candidate HTML SHA 83d216ef73c364b89da459c53f83f27150878ba4cd004a65c5c036db567dd980 (64,921 bytes, 1,001 rows); implicit JSON key serializations 1,000 → 0, explicit key control 1 → 1.

Risk / follow-ups

The change only affects the server's implicit top-level descriptor identities. Explicit and nested key encoding, list closures, and keyed component slot coercion remain open under #981. In four paired production-bundle A–B–B–A cycles, candidate/baseline median ratios were 0.901, 0.827, 0.938, and 0.972; absolute latency varied with concurrent machine work, so these are directional rather than a precise throughput claim.

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 server async child-list identity for descriptor SSR; behavior is narrow (top-level unkeyed only) but correctness across retries, concurrency, and streaming is security-adjacent for output isolation.

Overview
Top-level unkeyed server descriptor children now use a numeric positional identity in scopedSsrDeoptKey instead of wrapping each index in JSON.stringify, while explicit keys and nested wrapper paths still use the JSON-scoped identity shape.

Regression coverage adds SSR list scenarios across suspense retries (changing list shape), implicit vs explicit "0" keys, concurrent prerenders, and streaming reveals. An opt-in unkeyed-work.mjs benchmark gate (1,001-row fixture) asserts unchanged HTML/CSS and counts implicit positional serializations (1000 → 0 on the candidate).

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

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