Repository navigation
perf: skip head-close scan for SSR fragments - #1001
Merged
domgan-oai merged 2 commits intoSep 8, 2026
Merged
domgan-oai merged 2 commits into
domgan-oai merged 2 commits into
Conversation
domgan-oai
marked this pull request as ready for review
September 8, 2026 20:24
Closed
68 of 84 tasks
14 of 21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
</head>. Fragment renders with hoisted metadata now prepend the head without scanning the entire body.<!-- </head> -->, plus authored and synthesized document-head controls acrossrenderToString,renderToStaticMarkup, andprerender.octanepatch changeset. This addresses thespliceHeadfragment-scan item in Track V8 performance audit findings across runtime, SSR, universal core, and compiler output #981; the coordination issue remains open.Why
When a buffered fragment hoists a title or other head resource,
spliceHeadsearched its entire response for</head>even though only a document root can have the closing head it intends to target. On a large response this flattens and scans the whole string. It can also insert the title inside raw fragment content that happens to contain</head>in an HTML comment.Validation
headChannel: 'separate'recomposes the candidate folded output. Authored and synthesized document heads retain their placement. A cached compiler emitted both test fixtures with no diagnostics in dev/prod compile modes; the pinned compiler version awaits CI.Buffer.byteLength. Median of sample medians: baseline 0.0763 ms/render, candidate 0.0078 ms/render; every response SHA-256 and byte count matched. The no-hoist control was 0.00336 vs 0.00342 ms, and the document control ranged 0.00625–0.00880 vs 0.00759–0.00863 ms. This isolates the fragment scan, not typical application throughput.git diff --check, direct version generation, package inventory and context-budget checks passed. The production source bundle changed from 100,909 to 100,892 raw bytes.pnpm sync: dependency install stopped when the configured registry returned 403 for pinned@tsrx/[email protected]and@tsrx/[email protected]on successive attempts. Current-head CI covered the pinned toolchain.6056abb7497b57d38fa67780a22d74ad6eb8ad5c: all 26 jobs passed, including the corrected SSR regression in both development and production projects, typecheck, lint, browser integration, and provenance. The first head exposed a test-onlyprerenderimport error, fixed in the follow-up commit. Cursor Bugbot passed with no review comments.Risk / follow-ups
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Scoped to buffered SSR head splicing; document behavior is preserved and streaming was byte-identical in validation.
Overview
Buffered SSR fragments with hoisted metadata no longer search the full response for
</head>.spliceHeadnow uses a prefixisDocumentRootcheck: non-document bodies prepend hoisted head markup (or return unchanged when empty) without scanning, which avoids wasted work on large fragments and stops false matches when raw HTML contains</head>(e.g. inside a comment).Document renders are unchanged in intent—they still splice before an existing
</head>or synthesize a<head>after<html>—with a small control-flow simplification after the early fragment exit.Tests cover the comment regression,
headChannel: 'separate'recomposing folded output, and metadata placement for authored vs synthesized document heads acrossrenderToString,renderToStaticMarkup, andprerender. Anoctanepatch changeset records the fix.Reviewed by Cursor Bugbot for commit 8f6e2a6. Bugbot is set up for automated code reviews on this repo. Configure here.