Skip to content

perf(octane): stop bundling FragmentInstance for Activity-only consumers - #1802

Merged
trueadm merged 7 commits into
mainfrom
perf/activity-fragment-refs
Oct 6, 2026
Merged

trueadm merged 7 commits into
mainfrom
perf/activity-fragment-refs

Conversation

@o-alexandrov

@o-alexandrov o-alexandrov commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Why

  • queueCurrentActivityRefs used instanceof FragmentInstance, which keeps the constructor and its traversal, listener, and focus machinery reachable in every bundle that reaches the Activity reveal path.
  • Every mounted FragmentInstance already registers itself in activeFragments (constructor) and removes itself on _destroy, so membership is an exact equivalent for live instances without referencing the class.

Bytes (esbuild 0.28.1 probe from #1789, browser ESM, minify, production, gzip -9, on 8aeb6c0e5)

entry main raw / gzip this PR raw / gzip
__createVoidRoot, activityBlock 125,860 / 40,254 117,644 / 38,040 (−2,214 gz)
createRoot 200,880 / 64,465 unchanged
hydrateRoot 280,903 / 88,922 unchanged

No committed run-minimal.mjs or run.mjs scenario compiles an <Activity> without a Fragment ref, so committed budgets do not move beyond noise: re-recorded against current main, 8 entries move down by 1–8 bytes and none rises (budget-raises.mjs --base origin/main). A same-base A/B of deferred-hydration, prop-attributes, context and binding-radix-vite is byte-identical with and without the change. An earlier revision of this description attributed a larger budget drop to this PR; that drop came from #1781 landing on main and is not part of this change.

Changes

  • packages/octane/src/runtime.ts: one-line change in queueCurrentActivityRefs.
  • fragment-refs-activity.test.ts: regression test. A Fragment callback ref revealed by Activity must see child ownership published (reactFragments) when it runs, which only happens through the attachLiveFragmentRef trampoline. The existing suite stayed green when the routing was removed, so it did not pin this; the new test fails without it ([false] vs [true]) and passes with it.
  • Budgets re-recorded with --write-budgets (noise-level only, see above); changeset added.

Validation

  • pnpm typecheck (exit 0)
  • pnpm vitest run --project octane --project octane-prod: 41,520 passed. The 15 failures were in behavior-root, hydration-ssr-diagnostics and compiler/volar (timeouts under full-suite load). Rerun in isolation, those 3 files pass 334/334 both with and without this change.
  • node benchmarks/bundle-size/run-minimal.mjs --budgets and run.mjs --budgets octane-tsrx octane-jsx hold
  • pnpm sync, pnpm format:files:check
  • full pnpm test (left to CI)

Risk / follow-ups

  • A FragmentInstance that was destroyed but still appears in a visible manifest would now be routed as a plain ref. Destroyed instances are removed from scope cleanups in the same pass, so this should not occur; the conformance suite covers reveal after hide, nested Activity and portals.

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 Activity reveal ref attachment in the runtime; behavior should match live Fragment instances via the existing registry, but stale registry entries could theoretically mis-route refs.

Overview
Apps that use <Activity> without <Fragment ref> no longer pull in the FragmentInstance implementation. When an Activity reveals, queueCurrentActivityRefs now picks the live Fragment ref trampoline via activeFragments.has(entry.el) instead of instanceof FragmentInstance, so minifiers can drop the class unless Fragment refs are actually used.

A conformance test asserts that revealing a hidden Activity runs Fragment callback refs only after attachLiveFragmentRef has published child ownership on reactFragments, guarding the routing change. A patch changeset documents the bundle-size fix.

Reviewed by Cursor Bugbot for commit 3a0a4ec. 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 Oct 6, 2026
@vercel

vercel Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
octane-website Skipped Skipped Oct 6, 2026 12:04am UTC
octane-website-mcp Skipped Skipped Oct 6, 2026 12:04am UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp October 6, 2026 00:04 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website October 6, 2026 00:04 Inactive
@o-alexandrov
o-alexandrov marked this pull request as ready for review October 6, 2026 00:04

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue. You can view the agent here.

Reviewed by Cursor Bugbot for commit 9becbaa. Configure here.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No budget breaches, no added work, and no timing changes beyond ±3%.

Compares 087cd7775, the merge commit's first parent with 94a3b35f6 on the same runner. A byte value over its committed budget or any increase in a js-framework work counter fails this check. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.300 3.208 −3.5% −8.0% … +0.0% ⚪ within noise
octane-tsrx replace 6.950 7.258 +4.1% −4.3% … +12.0% ⚪ within noise
octane-tsrx add 2.475 2.458 ±0.0% −1.9% … +2.0% ⚪ within noise
octane-tsrx update 0.136 0.132 −3.5% −6.2% … −1.8% ⚪ within noise
octane-tsrx select 0.006 0.006 +0.3% −0.9% … +2.2% ⚪ within noise
octane-tsrx swap 0.039 0.038 −1.4% −2.9% … −0.7% ⚪ within noise
octane-tsrx remove 0.019 0.019 +1.9% +0.0% … +3.9% ⚪ within noise
octane-tsrx runlots 26.733 26.258 −1.6% −5.0% … +1.3% ⚪ within noise
octane-tsrx select_lots 0.006 0.006 ±0.0% −1.3% … +1.3% ⚪ within noise
octane-tsrx clear 43.767 43.242 +1.6% −1.3% … +4.3% ⚪ within noise
octane-jsx run 3.183 3.167 ±0.0% −2.9% … +3.0% ⚪ within noise
octane-jsx replace 6.075 5.875 −2.3% −5.6% … +1.5% ⚪ within noise
octane-jsx add 3.117 3.283 +3.0% ±0.0% … +3.2% ⚪ within noise
octane-jsx update 0.365 0.366 +3.5% −1.3% … +8.5% ⚪ within noise
octane-jsx select 0.140 0.138 −0.5% −1.3% … +1.9% ⚪ within noise
octane-jsx swap 0.228 0.232 +0.8% −0.5% … +2.3% ⚪ within noise
octane-jsx remove 0.181 0.181 +1.0% −1.3% … +2.4% ⚪ within noise
octane-jsx runlots 32.033 33.992 +0.7% −2.8% … +8.6% ⚪ within noise
octane-jsx select_lots 1.429 1.498 +1.1% −0.6% … +3.6% ⚪ within noise
octane-jsx clear 45.133 43.417 +1.7% −1.1% … +3.9% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx full_fw_raw 562,209 562,203 −6 (−0.0%) 🟢
octane-tsrx full_fw_gzip 168,941 168,939 −2 (−0.0%) 🟢
octane-tsrx full_fw_brotli 142,229 142,189 −40 (−0.0%) 🟢
octane-jsx full_fw_raw 562,209 562,203 −6 (−0.0%) 🟢
octane-jsx full_fw_gzip 168,941 168,939 −2 (−0.0%) 🟢
octane-jsx full_fw_brotli 142,229 142,189 −40 (−0.0%) 🟢

54 other measured values are unchanged.

Public-import reachability bundles (bytes)

No changes across 105 measured values.

trueadm and others added 5 commits October 6, 2026 12:27
Resolve the budget conflicts against main after #1784: take main's
budgets and lower the 28 values this branch now measures below them
(min(main, measured + headroom)); none is raised.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the budget conflicts against main after #1792 re-cut every
budget for Vite's oxc minifier: take main's budgets and lower the values
this branch now measures below them (min(main, measured + headroom));
none is raised.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Take #1811's budgets: its todo raw raise matches this branch's
measurement, and its deferred-hydration row is kept as main has it so
#1803 still fits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Take main's budgets after #1803. Re-recording with this branch's
runtime ratchets every value to main's (#1803 already cut them to
measured + headroom), and deferred-hydration keeps main's row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Failed ❌

View logs ↗
3a0a4ec 2026-10-06T12:24:24.618Z View logs ↗

@trueadm
trueadm merged commit ed57b1e into main Oct 6, 2026
30 of 31 checks passed
@trueadm
trueadm deleted the perf/activity-fragment-refs branch October 6, 2026 12:35
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.

perf(runtime): compiled Activity retains Fragment refs without using them

2 participants