Skip to content

perf(ssr): skip redundant loop HTML carriers - #945

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/perf-ssr-loop-carriers
Sep 3, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/perf-ssr-loop-carriers

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

Follow up to #943. Compiled server loops currently wrap each item's serialized HTML in a carrier, then immediately coerce it back to a string during concatenation. Return that string directly from those private item helpers.

The compiler option applies only to the current item body. Public components, opaque children callbacks, and returned fragments keep their carriers; authored early returns, replay identity, hydration boundaries, and client output are unchanged.

Performance evidence

Baseline is merged main 44d50dbc0. The untimed benchmark observer compares complete responses and enforces factory-call budgets:

Fixture Baseline calls Candidate calls
Compiled 300-card page 1,801 601
Descriptor control 0 0
10,000-item escaping case 10,001 1

These are source factory calls, not measured V8 heap allocations. The clean production fixture bundle shrinks by 54 bytes. Baseline and candidate HTML/CSS are byte-identical for both card variants, escaping, and hydratable/static control-flow fixtures. The instrumented bundle is never timed.

Four samples per version in ABBAABBA order, using the same production fixtures and CONFIGS=deopt-page,escape node run.mjs 2 --no-build on Node 26.4.0/macOS ARM64:

Fixture Baseline median run score Candidate median run score
Compiled 300-card page 1.871 ms 1.891 ms
Descriptor control 3.814 ms 3.902 ms
Escaping case 3.318 ms 3.338 ms

Timing ranges overlap and paired directions vary, including in the unchanged descriptor control. Throughput improvement is unproven in these end-to-end fixtures; the demonstrated reductions are wrapper calls and emitted bytes. Full methodology and ranges are in the SSR-throughput README.

Validation

  • pnpm exec vitest run --project octane --project octane-prod --maxWorkers 4 --silent=passed-only: 935 files, 16,242 tests passed.
  • Focused server-renderable contract suite: 86 passed; final new list scenarios: 20 passed.
  • Negative controls: unboxing opaque children fails all 8 forwarding executions; unboxing public bodies fails all 20 new list executions. Restoring the compiler byte-for-byte returns all 20 new scenarios to green.
  • pnpm exec tsgo --noEmit -p packages/octane/tsconfig.json.
  • Changed fixture and test pass strict tsrx-tsc --noEmit with tsrx.compiler explicitly selecting octane/compiler/volar. Default scoped discovery selects React lowering and also fails on the unchanged baseline; no type workaround is included.
  • Development/production compilation with native reads on/off, including source-map inspection.
  • Repository synchronization and scoped formatting checks.
  • Repository-wide pnpm format:check, pnpm typecheck, and pnpm test were not run locally; the complete core projects and scoped checks above were run.
  • Current-head CI: passed on ae132218c, including website/browser integration, examples, React parity, typechecking, lint, and package validation. One unchanged Volar typing test exceeded its 5-second timeout on the first attempt; the focused local reproduction passed in 1.35 seconds and the failed-job retry passed without source or timeout changes. Cursor Bugbot also passed with no findings.

Risk / follow-ups

Coverage preserves nested and empty loops, multi-root items, escaped text, public mixed returns, opaque children forwarding, all five server-rendering APIs, and hydration adoption with live events. Broader SSR return-protocol changes and transition/manual-hook optimizations are separate follow-ups.

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 SSR compiler return semantics for loop bodies; mitigated by broad contract tests across APIs, streaming, and hydration, with carriers unchanged for public boundaries.

Overview
Compiled @for item helpers no longer wrap each iteration’s serialized markup in ssrHtml; they return the concatenation string directly, while public components, empty arms, and other SSR bodies still use the carrier so text vs template HTML stays distinguishable.

The ssr-throughput harness adds an untimed ssrHtml call counter (instrumented bundle copy) with budgets on the 300-card compiled page, descriptor control, and 10k-hole escape fixture, plus README notes that factory-call counts dropped sharply with byte-identical output and no proven end-to-end timing win.

Contract tests add nested/empty lists, hostile escaping, loop children forwarded through component descriptors, all five server render paths, and hydration with click handlers (dev and prod compile).

Reviewed by Cursor Bugbot for commit ae13221. 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 3, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 3, 2026 19:57
@domgan-oai
domgan-oai merged commit bf860be into octanejs:main Sep 3, 2026
73 of 76 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