Repository navigation
perf(octane): install never-run capabilities from their creators - #2246
Merged
Merged
Conversation
Applications that never use a capability no longer ship its runtime: - Context dependency checks (the memo and implicit bail checks, cache-hit refreshes and skipped list rows) install with the first recorded context read, through one driver that replaces SKIPPED_ROW_REFRESH. - The memo bail installs with memo(), the only writer of `__memo`, so memo-free applications skip its call on every component update. - A portal registers Fragment-ref owners only once a FragmentInstance exists. - Controlled select restoration installs with the first controlled select value, the only writer of a non-null `sv`. - Renderer-region bridge lookups are guarded by a truthiness test of the region-owner count at each caller, so bundles that never bind a region owner drop them. - Two recursive functions that oxc kept only through their own recursion become named function expressions. Bundle-size reachability controls cover each split; a fresh-module test pins provider updates through a memo boundary that bailed before the first read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | bedcfea | Commit Preview URL Branch Preview URL |
Oct 26 2026, 09:43 PM |
trueadm
marked this pull request as ready for review
October 26, 2026 21:27
Contributor
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
Work counters (an increase fails this check):
54 other measured values are unchanged. Application bundle size (bytes)
13 other measured values are unchanged. Public-import reachability bundles (bytes)
38 other measured values are unchanged. |
The render-write check classifies DOM writers by their declaring function. As a const-bound function expression, placeMarker's insertBefore resolved to the module top level and failed the check. Restore the declaration: the function is reached from every bundle that places hydration or descriptor markers, and its saving was a few dozen bytes in one example. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | bedcfea | Commit Preview URL Branch Preview URL |
Oct 26 2026, 09:42 PM |
This comment has been minimized.
This comment has been minimized.
10 tasks done
6 of 9 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
Chrome coverage across the examples showed runtime code that ships in every app but only runs when a particular feature is in use. This PR makes five of those capabilities install only from the API or compiled code that needs them, using the
drivers.tspattern: the creator installs the capability, readers test it by truthiness, and it is declared above its readers. It also lets a dead recursive function tree-shake. Render work is unchanged: js-framework work counters are equal or lower, DOM mutations are equal, and the timing A/B is flat.CONTEXT_DEPENDENCIESdriver, replacesSKIPPED_ROW_REFRESH)recordContextDependency)MEMO_BAIL:tryMemoBail,shallowEqualProps)memo(), the only writer of__memoFRAGMENT_REFS)FragmentInstancejoiningactiveFragmentsportal()/ value portal<select>restoration (SELECT_RESTORE)setSelectValue, the only writer of a non-nullsvbindRendererRegionOwner(callers now testRENDERER_REGION_OWNER_COUNTby truthiness, since=== 0does not fold)handleRenderErrorcollectRetiredSignalRetryOwners(dead in 6 of 8 sampled apps) became a named function expression, assignalRetrySlotalready is. oxc keeps an unreferenced top-level function alive through its own recursion. (placeMarkerhas the same shape but stays a declaration: the render-write check classifies DOM writers by their declaring function.)Each gate is exactly the runtime condition it replaces. Every Block dependency,
__memomarker, owned portal,svvalue and region bridge implies its installer already ran. One exception: before the first recorded context read, bails no longer stamp$$ctxDepsEpoch, which only makes later checks scan. The new fresh-module test pins that window.Per-app client JS (production
vite build, gzip-9 sum of client chunks, main 7246709 → head)hacker-news builds through its own two configs, so it is measured with each one:
jsx/vite.config.ts460,142 → 458,847 raw, 148,841 → 148,526 gzip (−315);tsrx/vite.config.ts470,850 → 469,567 raw, 150,652 → 150,340 gzip (−312).Measured with the descriptor renderer stubbed out, which approximates the tree after the descriptor-renderer PR: relay goes from 53,865 to 52,584 B gzip (−1,281).
Byte rows that grew in the benchmark report
The CI bundle-size report shrinks almost every row: `fw_gzip` −370 B, todo −495, chat −481, weather −797, `root-static` −860, `descriptor-children` −809, `binding-radix-vite` −822. A few rows grew; each of them installs every capability, or uses esbuild:
The listed never-run code this PR leaves alone, and why
Coverage alone is not proof. Each item below is reachable from a generic path, so splitting it would change behavior:
rollbackRootRender,rollbackTransitionJournal,restoreForSlot,journalForListClear,dropRootOps): every root render journals. Any uncaught render error or root-level suspension rolls back (makeRoot,drainQueue,suspendRootRender), with or without transitions.drainHydrationRenderPhaseUpdatesin acreateRootapp: despite its name,makeRootuses it to replay mount-time render-phase updates (QUEUE.length > 0after the firstrenderBlock). That is anysetStateduring the first mount.registerDelegatedCaptureinstallsCAPTURE_FINISH, and compiled capture props call__delegateCaptureEvents). relay reaches it only throughsetHostProps, so the descriptor-renderer PR removes it there.captureFocusedMovement,dom-focused-move.ts, contentEditable selection capture): runs whenever anything is focused during a keyed move. Third-party editors setcontenteditableimperatively, so no creator can see it..tsrxapps without descriptors, select, checked,defaultValueandautoFocusare reachable only throughsetAttribute/setHostProps, which the descriptor PR removes. Composition handling is needed by any controlled text input. The select restore projection was the one creator-gated piece, split here.forEachSubtreeChild,collectVisibleSubtreeRefs, used by many render and teardown paths); Activity itself is already split. Theactions.tsandFragmentInstanceweight (about 10 KB min in six apps) comes fromenableDescriptorCapabilitiesinstalling everything on anycreateElement. That belongs to the descriptor-renderer session, which has been told.Validation
pnpm typecheck:files packages/octane/src/runtime/*.tspnpm format:files:checkon the changed files, andpnpm sync(no generated changes)pnpm test: left to CI. Ran locally in--project octane: context*, memo-bailout, implicit-element-bailout, auto-memo*, fragment-* conformance, fragment-events, audit-events-portals, controlled-select, controlled-forms, descriptor-form-controls, react-hosted/*, lazy-components and audit-lazy-metadata (44 files, 729 tests);hydration/(180 files, 8,290 tests);--project octane-signals(31 files, 421 tests); and the new test inoctaneandoctane-prod.FRAGMENT_REFSfails 8 fragment-future-children tests; never installingMEMO_BAILfails 3 memo-bailout tests; never installingSELECT_RESTOREfails 4 controlled-select tests; never installingCONTEXT_DEPENDENCIESfails 8 context and memo tests and the newcontext-first-read.test.ts(Expected "dark", Received "dim").node benchmarks/bundle-size/run-minimal.mjs): newmemo-contextandcontrolled-inputscenarios. Dropped/kept controls:descriptor-childrendrops the context checks, the memo bail, region lookups andcollectRetiredSignalRetryOwners(keepschildSlot,tryImplicitBail).contextdrops the memo bail and region lookups and keeps the context checks.memo-contextkeeps both.controlled-inputdropsprojectSelectValueandrestoreCheckedState(keepsrestoreControlledElement).hydrate-framedrops the Fragment-ref portal owners (keepsrenderPortalChild).example appsshards.perf-review: see below.concise-code: see below.Performance A/B (same session, base = main 7246709, whose runtime is identical to 232464b; alternating base↔head)
js-framework (
benchmarks/js-framework/pair.mjs, 30 alternating pairs; work counters from--work-only, jitless precise coverage)dbmon (8 rounds, base/head order alternating per round; median ms, median per-round ratio [min, max])
effectful-list (8 rounds, base/head order alternating per round; median ms, median per-round ratio [min, max])
transition-hooks (6 rounds, alternating; Node + happy-dom). 106 of 115 rows identical in both trees (renders, map gets, every runtime and application creation count). Timing rows, median per-round ratio [min, max]:
suspense-recovery (4 rounds, alternating; ms median, median per-round ratio [min, max]):
app-frame-hydration (
run.mjs 30 --base=<main>, 30 interleaved pairs per run, 4× CPU; Block, render and renderBlock counts identical, heap equal or lower). The A/A builds the head tree as both sides and gives the harness noise floor: 0.984–1.012, with one CI excluding 1.0. The A/B cells sit inside it, and the cells whose CI clears 1.0 change between runs.js-framework second timed pass (30 pairs, same builds): octane-tsrx run × 1 1.9ms head/base 1.000 [0.946, 1.056]; octane-tsrx replace × 1 3.7ms head/base 1.000 [0.974, 1.029]; octane-tsrx add × 1 1.5ms head/base 1.000 [1.000, 1.000]; octane-tsrx update × 344 51.5ms head/base 1.006 [1.001, 1.009]; octane-tsrx select ×5000 16.7ms head/base 1.009 [0.991, 1.025]; octane-tsrx swap ×1301 19.6ms head/base 1.021 [1.003, 1.029]; octane-tsrx remove × 800 8.4ms head/base 1.000 [0.976, 1.012]; octane-tsrx runlots × 1 13.1ms head/base 0.992 [0.978, 1.023]; octane-tsrx select_lots ×5000 16.5ms head/base 1.006 [1.000, 1.012]; octane-tsrx clear × 1 24.8ms head/base 1.005 [0.992, 1.010]; octane-jsx run × 1 2.2ms head/base 1.000 [0.978, 1.000]; octane-jsx replace × 1 4.0ms head/base 1.000 [0.976, 1.025]; octane-jsx add × 1 1.9ms head/base 1.000 [0.956, 1.051]; octane-jsx update × 108 16.6ms head/base 1.006 [0.988, 1.015]; octane-jsx select × 232 19.3ms head/base 1.000 [0.993, 1.016]; octane-jsx swap × 139 16.0ms head/base 0.994 [0.988, 0.997]; octane-jsx remove × 190 18.0ms head/base 0.997 [0.983, 1.009]; octane-jsx runlots × 1 15.3ms head/base 1.003 [0.971, 1.030]; octane-jsx select_lots × 22 19.6ms head/base 0.988 [0.980, 0.995]; octane-jsx clear × 1 25.4ms head/base 1.026 [1.011, 1.054]. The first pass's outliers flip sign (tsrx remove 1.024 → 1.000, swap 0.977 → 1.021; jsx clear 0.990 → 1.026), with identical work counters.
perf-review: perf/creator-installed-capabilities (232464b..d942043)
Scan:
node scripts/perf-review-scan.mjs→ 0 candidates.Hot paths touched:
tryMemoBail's three call sites (per component update): one driver read replaces a call that returned at once withoutmemo().tryMemoBail/tryImplicitBail(per bail): one driver read, then the same two calls through a one-literal driver object.compilerCacheContextpast its fast path, andrenderBlockInner's hydrate-slot branch (only with direct context reads): one driver read. Teardown handler selection and context default reads: the existing count test moved to the caller, so there are fewer calls when no region exists. TheFragmentInstanceconstructor andsetSelectValueadd one store each.??=allocates the driver once; later reads do one nullish test where a store ran beforeNot checked: browser Event Timing (no interaction latency claim is made).
concise-code: src +128 −60 (runtime +128 −60); no new runtime files. New exportsctxBailDepsClean,restampCtxDepsandrestampCachedSlotContext(for the context.ts installer),MEMO_BAIL/installMemoBail,CONTEXT_DEPENDENCIESandFRAGMENT_REFS, each with callers in this diff. Alternatives: a boolean context flag with direct calls (smaller diff) was rejected because oxc then kept the mutually recursive refresh walk. Installing atcreateContextwas rejected because lazily created contexts make promotion unsafe to gate, while gating consumption on recorded reads is exact. Bytes: per-app table above.Risk / follow-ups
createRootapps): about 25 sites testrenderOwner?.signalOwnerat runtime.signalDocumentEnabled || registerRootOptionsis a sound foldable gate, because both root constructors callinstallRootOptionsandpruneSignalRetryVisitalready relies on it. Several sites are per-render paths, so it belongs in its own PR with its own A/B.memo()pulls the generic return path: onememo()in the minimal context fixture grows it from 69.7 to 149.8 KB raw, because the wrapper forwards the body's return value. That is whymemo-contextis a separate scenario.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Touches hot render, bail, teardown, and context paths with lazy initialization; behavior is validated by tests and benchmarks, with a narrow pre-first-context-read window where bail epoch stamping differs.
Overview
Octane client bundles shrink by installing five optional runtime paths only when an app actually uses them, following the existing
drivers.tspattern (creator installs, readers null-check).The first recorded context read wires
CONTEXT_DEPENDENCIES(memo/implicit bail context checks, cache-hit refresh, skipped list rows), replacing always-onSKIPPED_ROW_REFRESH.memo()alone setsMEMO_BAILso apps withoutmemo()skiptryMemoBailon every update. Fragment refs flipFRAGMENT_REFSwhen the firstFragmentInstanceis created, gating portal owner registration. Controlled<select>setsSELECT_RESTOREon the first non-nullsv, so text-only controlled inputs avoid select projection and checked restore. Renderer-region bridge lookups run only whenRENDERER_REGION_OWNER_COUNTis truthy at call sites (teardown, context defaults, suspense/error routing).Call sites use driver indirection (
MEMO_BAIL && …,CONTEXT_DEPENDENCIES?.clean, etc.).collectRetiredSignalRetryOwnersis a named function expression so unused signal-retry retirement can tree-shake. Bundle-size benchmarks addmemo-contextandcontrolled-inputfixtures; a test covers provider updates through a memo wall that bailed before any context read was recorded.Reviewed by Cursor Bugbot for commit bedcfea. Bugbot is set up for automated code reviews on this repo. Configure here.