Repository navigation
perf(octane): move feature-only Block state to a lazy record - #1896
Conversation
Fourteen BlockImpl fields served only Suspense/try/Activity boundaries, use() thenables, fetch-tree warming, the commit-callback update guard, useEffectEvent and ViewTransition. They now live on a `rare` record that blockRare() allocates from one literal the first time a feature needs it. BlockImpl drops from 79 to 66 fields and its constructor bytecode from 437 to 371 bytes; LiteBlockImpl carries `rare: null` so parentBlock walks stay uniform. Paired cold mounts (Chromium, 40 fresh pages): memo-wall 0.960, portal-swarm 0.981, recursive-context 0.985 against main. Adds a regression test for the per-render use() call-position reset that now runs only when the record exists. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)❌ 30 value(s) exceed their committed budget. Reduce the growth, or raise the budget in a separate pull request that names the bytes and the reason (CONTRIBUTING.md, "Size budgets").
8 other measured values are unchanged. Public-import reachability bundles (bytes)❌ 59 value(s) exceed their committed budget. Reduce the growth, or raise the budget in a separate pull request that names the bytes and the reason (CONTRIBUTING.md, "Size budgets").
35 other measured values are unchanged. |
|
The bundle-size check fails for two reasons:
Next steps, once #1875 merges:
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | d0b3f9c | Commit Preview URL Branch Preview URL |
Oct 08 2026, 02:08 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | d0b3f9c | Commit Preview URL Branch Preview URL |
Oct 08 2026, 02:06 PM |
Measured over main 68aa481 with --write-budgets; only raw rows that this branch makes smaller. The matching gzip and Brotli raises are the budget-only #1906, which merges first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Fourteen
BlockImplfields served only a few features: Suspense,@tryand<Activity>boundaries,use()thenables, fetch-tree warming, the loop guard for updates scheduled from commit callbacks,useEffectEvent, and<ViewTransition>. They now live on ararerecord.blockRare()allocates it from a single object literal the first time one of those features touches a Block. Every other Block carriesrare: null.BlockImpldrops from 79 to 66 fields, and its constructor bytecode from 437 to 371 bytes.LiteBlockImplgainsrare: null, so walks alongparentBlockchains read one field on every block shape and need noundefinedcases.drainStamp/drainRendersstay onBlockImpl.sortWaveByDepthuses them as scratch on every ancestor, so moving them would allocate a record per ancestor on update waves.use(),useEffectEvent, warm cache, ViewTransition, or commit-callback update for a Block.countNestedUpdate(), which runs only for commit-callback updates. A user update now resets the count and error only when a record already exists. A Block without one already reads as a fresh chain, and chain ids only grow, so a stale stored chain also reads as fresh.This is step 1 of the cold-mount plan agreed in the session: slim Block first, then lite control-flow arms in a separate PR.
Why
Octane trails React on cold first mounts of component-heavy trees. The ratios are 1.19–1.25× on memo-wall, portal-swarm and recursive-context. These are paired cold mounts in Chromium, one fresh page per sample.
BlockImplas the largest allocation, at 1.29 MB of 4.1 MB.BlockImplwith 36 dummy fields cost memo-wall +7.8% and portal-swarm +5.7%.The gain is not linear in field count. With 3 dummy fields added back (69 fields, 386 bytes of bytecode), memo-wall's gain disappears: 0.990 instead of 0.955. That is consistent with V8 inlining a hot callee only within a bytecode budget. The
BlockImpldoc comment now records this, so new always-present fields get weighed against it.Measurements
Paired cold first mounts. Each round opens one fresh page per target in alternating order and times the first
__mount(). There were 40 rounds, using production builds served statically. Base is8444db8ae9, before the merge of main.run.mjs, base and candidate in the order-balanced dialect slots) shows no op regressed: mount 1.00×, update_root 0.97×, unmount 0.99×. The 0.1 ms partial ops sit at the timer's resolution.Bundle bytes: needs a companion budget-only PR
Raw bytes fall in most scenarios, by 8–84 B. Gzip grows, because the
.rare?.reads at boundary, thenable and effect-event sites compress worse than the repetitive constructor lines they replace. Local measurements against base:hydrate-frameis +25 raw.A feature PR cannot raise budgets (
benchmarks/bundle-size/budget-raises.mjs). The companion budget-only PR is #1906. It raises the 48 gzip and Brotli ceilings this change exceeds (36 gzip, 12 Brotli), measured on this branch merged with main68aa48102b. This PR lowers the 36 raw ceilings it shrinks, from the same--write-budgetsrun. Merge #1906 immediately before this PR. Until #1906 lands, the bundle-size check here fails on the gzip rows, as expected.spa-navigation's warm navigations, from the order-balanced harness: nav_mount 0.979 and nav_deep 0.976, with the other ops neutral.
The two smaller variants measured worse:
Block(11 fields moved, 69 left) still grew gzip by 23–111 B in Suspense and app bundles. It lost the memo-wall gain entirely (0.994–1.000).Validation
pnpm format:files:checkon every changed file.pnpm typecheck:files packages/octane/src/runtime.ts packages/octane/src/signals/transition-coordinator.ts packages/octane/tests/render-block-dormant.test.tspnpm format:check,pnpm typecheckandpnpm testare left to CI, following the shared-machine load rule.octaneproject: 19 files and 307 tests before the merge, 13 files and 200 tests after it. They cover Suspense,@try, Activity, ViewTransition,useEffectEvent, warm plans, nested suspension, update depth, transitions and foreign delegation.render-block-dormantandupdate-reconciliationalso pass inoctane-prod.render-block-dormant.test.ts: an uncacheduse()promise created on every render resolves from its call position. It covers a component with onlyuse()and one with an Effect Event beforeuse(). It passes on main and on this branch. It fails in 1–3 ms when the per-renderthenableIdxreset is removed, because it stays on the fallback. Before this change no test covered that reset; removing it passed 50 Suspense tests.conformance/update-reconciliation.test.ts, "resets the update counter for unrelated updates".node --test scripts/perf-review-scan.test.mjs: 17/17. The whole-runtime sanity check now expectsrareamong the Block fields instead ofvt.perf-reviewreport:Risk / follow-ups
useEffectEventversion bump that invalidates payloads from abandoned attempts. Removing it passes every Effect Event test, before and after this change.vtNearestBoundaryAncestorused to treat aLiteBlockImplin the chain as a boundary, because a missingvtis notnull. Withrare: nullon lite proxies, it now skips them.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Refactors core renderer
Blockshape and every boundary/Suspense/update-depth code path that touched the moved fields; behavior is intended to be identical but mistakes would show up as subtle suspension,use(), or max-update-depth failures.Overview
Moves fourteen rarely used
Blockfields into a lazily allocatedBlockRarerecord (block.rare/blockRare()), shrinking the hotBlockImplconstructor from 79 to 66 fields so ordinary mounts pay one null pointer instead of initializing Suspense/@try/<Activity>,use()thenables, fetch-tree warming, commit-callback update guards,useEffectEvent, and<ViewTransition>state up front.Call sites that used
block.vt,__trySlot,__suspenseHandler, nested-update counters, and similar are rewired torare(with helpers likevtPropsand extractedcountNestedUpdate).LiteBlockImplalways exposesrare: null, fixing ancestor walks that previously misread missing ViewTransition props. Bundle raw budgets drop slightly; gzip may rise until a companion budget PR lands.Adds regression coverage for
use()replay when an Effect Event runs before it (per-renderthenableIdxreset), and updates the signal transition coordinator plus perf-scan expectations for the new field name.Reviewed by Cursor Bugbot for commit 9ca327e. Bugbot is set up for automated code reviews on this repo. Configure here.