Repository navigation
fix: stop the compiled @for path retaining the descriptor renderer - #767
Merged
Merged
Conversation
`mountItem` decided whether a de-opt list's items render through the plain `deoptItemBody` by comparing the body function by identity. `mountItem` sits on the compiled `@for` mount path that every list-rendering application reaches, so naming `deoptItemBody` from it is a live reference a bundler must honour, and retaining it retains `childSlot` — and through it the descriptor renderer, fragment refs, portals, transitions, controlled-form restoration, focus preservation and the DOM attribute tables. Applications that only render compiled templates shipped all of it. Record the fact on the `ForSlot` as `plainDeopt`, stamped by `childSlot` where the body is chosen — inside the graph that already retains those modules — and read the flag in `mountItem` instead. The value is exactly the identity test it replaces: within the de-opt branch the body is `deoptItemBody` precisely when the compiler supplied no map body and this is not the mapped fallback, because both body-wrapping assignments are guarded by those same two conditions. Both `ForSlot` literals declare the field so every slot keeps one hidden class. Normalized production gzip: rows 40,752 -> 20,609, TodoMVC 41,293 -> 21,835, chat-stream 41,530 -> 21,968, weather-app 49,524 -> 31,742, and the CLI-generated starter 40,362 -> 23,903. No compiler output changed, so every application chunk is byte-identical; the saving is entirely framework reachability. Budgets are re-recorded for the ceilings this moves, tightened only. Co-Authored-By: Claude Opus 5 <[email protected]>
trueadm
marked this pull request as ready for review
August 16, 2026 22:27
This was referenced Sep 3, 2026
This was referenced Sep 17, 2026
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
mountItemdecided whether a de-opt list's items render through the plaindeoptItemBodyby comparing the body function by identity. The comparison iscorrect and cheap, but
mountItemis on the compiled@formount path thatevery list-rendering application reaches, so naming
deoptItemBodyfrom it is alive reference a bundler must honour. Retaining
deoptItemBodyretainschildSlot— the universal renderable-hole dispatcher — and through it thedescriptor renderer,
FragmentInstanceand fragment refs, portals, transitions,controlled-form restoration, focus preservation and the DOM attribute tables.
Applications that only ever render compiled templates, and never present a
generic renderable hole, shipped all of it.
The fact is now recorded on the
ForSlotasplainDeopt, alongside the existingmappedNativeflag, and stamped bychildSlotwhere the body is chosen — insidethe graph that already retains those modules.
mountItemreads the flag insteadof naming the function.
The recorded value is exactly the identity test it replaces. Within the de-opt
branch the body is
deoptItemBodyprecisely when the compiler supplied no mapbody and this is not the mapped fallback, because both body-wrapping assignments
above it are guarded by those same two conditions:
compiledMapBody !== undefinedwrapper cannot apply when there is no mapbody, and
markerlessMappedFallbackwrapper impliesmappedFallback === true.Both
ForSlotliterals declare the field, so every slot keeps one hidden classand the stamp transitions nothing.
Where this came from
Bisected to
4c1ecd143("Float style resources and the Context.Consumerdecision made concrete", #712, 12 Aug), which introduced the identity tests.
Same app source and build config throughout, only
packages/octane/srcvarying:a1d506777d2c9e1ca9a03ff0f334c1ecd14348fa46cdcruntime.tsgrew 9% over that window while the rows bundle grew 147%, so thiswas reachability, not code growth.
Changes
packages/octane/src/runtime.ts— recordForSlot.plainDeoptinchildSlot;read it in
mountIteminstead of comparing againstdeoptItemBody; declarethe field in both
ForSlotliterals.packages/octane/tests/hydration/mapped-fallback-hydrate.test.ts+_fixtures/mapped-fallback-list.tsx— new coverage for the mapped-fallbackhydration path, which had none.
benchmarks/bundle-size/app-budgets.json,benchmarks/bundle-size/minimal-budgets.json— re-record the ceilings thischange moves. Tightened only; nothing is loosened.
Results
Normalized production builds, gzip, via
benchmarks/bundle-size/run.mjs:benchmarks/bundle-size/run-minimal.mjs:cli-spa-starter— the entryoctane initgenerates — drops 40,362 → 23,903 gzip (−40.8%).The saving is entirely in the framework chunk (rows 38,380 → 18,237 B). Every
application chunk is byte-identical, because no compiler output changed. The rows
bundle drops from 559 surviving top-level declarations to 340:
childSlot,FragmentInstance,deoptItemBody,renderPortalState,startTransition,setAttributeandattachLiveFragmentRefall become unreachable, whilereconcileKeyedandmountItemcorrectly remain.Validation
pnpm format:check— clean.pnpm typecheck— clean.pnpm test— 21,759 / 21,761 passed. The two failures are bothpackages/octane/tests/browser/native-change/native-change.test.ts, failing onFailed to load resource: 504 (Outdated Optimize Dep)— a Vite dependency-optimizer race on this fresh worktree's first browser run, not an assertion
about behavior. Re-running that file alone passes 12/12.
hydration/descriptor-list-hydrate,hydration/map-hydrate,hydration/mapped-fallback-hydrate,deopt-item-selfmark,deopt-item-path-switch, plus the wholetests/hydrationdirectory and thedeopt-*/descriptor-childrenfiles.benchmarks/bundle-size/run.mjsandrun-minimal.mjs, Node 24 (the pinnedCI version), before and after.
Mutation-checked rather than assumed: forcing
plainDeoptto the inverse, andseparately to a constant
false, turns 18 tests inhydration/descriptor-list-hydrate.test.tsred. See the coverage note below forthe direction that is not pinned.
Risk / follow-ups
plainDeoptto a constanttruepasses all730 tests in
tests/hydration+ thedeopt-*files, and passes the newmapped-fallback test. I could not construct a case where the
truedirectionis observationally different: for pure host items the third disjunct at each
read site rescues it, and for component items the fall-through is the marked
path that is correct anyway. The equivalence argument above is what carries
that direction, not a test. Worth a second opinion.
mountItemre-invoked throughhydration.suspendre-readsforSlot.plainDeoptrather than a captured value,where it previously used the captured
body. For the value to differ, the samefor-slot would have to re-render with a flipped native/fallback verdict between
the suspension and its resumption — at which point the captured
itemand theslot's markers are already inconsistent, so this is not a new risk class. Not
covered by a test.
octane-jsxremains 1.17× over its committed framework ceiling (38,975 vs33,344 gzip) and this change does not move it. The JSX dialect legitimately
reaches the descriptor renderer, so it is exposed to that graph's real growth
over the same 08-10 → 08-13 window. I did not diagnose it and deliberately did
not raise
jsx-budgets.json; it needs its own investigation.source is unchanged since the ceiling was recorded on 08-08, so this is
compiler-output growth from that window. It is unrelated to this change — the
app chunk measures 2,198 B before and 2,199 B after — and I left the ceiling
alone rather than bless it.
bundle-reachabilityceilings stay exceeded (hydrate-root,deferred-hydration,suspense-transition,server-render,capture-only,the
binding-*scenarios). All were already over before this change; theyreach
childSlotthrough the general-root path, which this fix does not touch.Left as a true signal rather than re-recorded.
root-static-specializedships12,285 B gzip against
root-static's 36,434 B: escaping compiler-proven rootspecialization still costs ~24 KB in one step, because
childSlotis a runtimedispatcher rather than a set of compiler-injected entry points. That is a
design change, not a fix, and is out of scope here.
Provenance
agent-authored)Note
Medium Risk
Touches core list mount/hydration (
mountItem, SSR markerless paths) with equivalence argued but one direction ofplainDeoptnot fully mutation-tested; behavior should match prior identity checks.Overview
Compiled
@forlists no longer pull the full descriptor renderer into every app bundle by avoiding adeoptItemBodyidentity check on the hotmountItempath.ForSlotgains aplainDeoptflag (set inchildSlotwhen there is no compiled map body and the list is not on the mapped-fallback path).mountItemand related hydration branches read that flag instead of comparingbody === deoptItemBody, so bundlers can dropchildSlotand the descriptor graph for apps that only use compiled templates. BothForSlotobject literals initialize the field for a stable hidden class.Bundle-size budgets in
app-budgets.jsonandminimal-budgets.jsonare tightened to match roughly ~50% smaller framework gzip for sample apps. New mapped-fallback hydration tests ensure exoticitems.maparrays still adopt server DOM and stay keyed after reorder.Reviewed by Cursor Bugbot for commit e24b3a7. Bugbot is set up for automated code reviews on this repo. Configure here.