Repository navigation
perf: trim production runtime overhead - #1356
Merged
Merged
Conversation
finishRoot and both abandonRoot callers built the dev warning's inputs in production: componentSourceLoc (Function.prototype.toString over the root component) and describeHydrationNode strings, only for a stripped warning to drop them. abandonRoot now takes the diagnostic as a dev-gated thunk, finishRoot gates its warning, and HydrationCapability.describe returns '' in production so its dev-only callers stop retaining the describer. Production hydrateRoot bundle: -295 B gzip; createRoot: -111 B gzip (the childSlot root path no longer drags componentSourceLoc into non-hydrating bundles). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o handler Once any component registers a delegated type, every native event of that type under the root reaches the capture and bubble queues, including pointer, touch, and input traffic that no Octane handler can see. Both queues still read the stopPropagation descriptor, installed a patched method, and restored it (plus an unconditional currentTarget delete) per event. snapshotDelegatedSlots now reports whether the phase found a handler. With none (and, for bubbling, no form action to drive) the queue leaves the native event untouched. The capture queue keeps reporting 'not stopped' so non-bubbling families still reach their bubble queue. dispatch-work gains an idle-target gate: 128 idle clicks go from 512 Event descriptor reads/definitions to 0 (ratio guard idleEventDefinitions), median idle dispatch 2.70 -> 2.43 us, handled dispatch unchanged at 4.85 us. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
September 28, 2026 07:24
Modules that import octane/signals bracket every compiled block body with beginNativeReadScope/endNativeReadScope. An empty @if/@else arm has no code that can read, yet it still entered and published an empty read scope on every render (a production application bundle ships six such bodies). wrapNativeReadScope now returns an empty statement list unchanged; module activation already enables collection. compiler-output gains native-read-scopes.mjs: per empty-arm module, 1 -> 0 empty brackets, 448 -> 320 runtime scope entries over 64 cycles, 833 -> 811 minified bytes, with signal-driven text asserted at every step and a two-arm control unchanged. Ratio guards hold empty_brackets at zero. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uction Production bundles shipped ~250 plain-English framework error messages from signals/*, hydration/*, and dom-binding*.ts because the error-code catalog was enforced only in runtime.ts and runtime.server.ts. Every framework-owned construction in those modules now formats a catalog code (81-331); dev messages are byte-identical, production gets the minified code. The generator now enforces the covered paths (including Error subclasses, checked at their construction or super() call). Shared modules use formatClientError with codes registered for both runtimes. Two audited exceptions re-wrap foreign or compiler-provided message data. Production client surface (index + signals + hydration + dom-binding entries): -3.6 KB gzip; hydrateRoot -265 B gzip. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
force-pushed
the
perf/prod-runtime-overhead
branch
from
September 28, 2026 07:32
8234b60 to
83dc7ec
Compare
This was referenced Sep 28, 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
Four production-overhead:
5ef1af04a).finishRootand bothabandonRootcallers built the dev warning's inputs, which were then thrown away by the stripped warning. Those inputs arecomponentSourceLoc(Function.prototype.toStringover the root component) and thedescribeHydrationNodestrings.abandonRootnow takes the diagnostic as a dev-gated thunk,finishRootgates its warning, andHydrationCapability.describe()returns''in production so its dev-only callers stop retaining the describer.childSlotroot path from pullingcomponentSourceLocintocreateRoot-only bundles.e99af7160).stopPropagationdescriptor, installed a patched method, restored it, and deletedcurrentTargetunconditionally.snapshotDelegatedSlotsnow reports whether the phase found a handler. With none (and, for bubbling, no form action to drive), the queue skips the propagation frame.playcontinue into their bubble queue.1383e7e5a).@if/@elsearms compiled tobegin/endNativeReadScopearoundtry {}, entering and publishing an empty read scope on every render. A production application bundle carries six of these.wrapNativeReadScopenow returns an empty statement list unchanged. Module activation already enables collection.83dc7ec42).signals/*,hydration/*anddom-binding*.tsshipped in production, because the catalog was only enforced inruntime.ts/runtime.server.ts.%sconcatenations.formatClientErrorwith codes registered for both runtimes.data-encoding.tsand most ofserver/*are still in English (see follow-ups).Production bundle size (esbuild, minified,
NODE_ENV=production)origin/maingziphydrateRootconsumercreateRootconsumeroctaneexportDeterministic work (new benchmark gates plus ratio guards)
event-delegation/dispatch-work, new idle target (Chromium, 3 × 15 rounds × 4,000 events):defineProperty/getOwnPropertyDescriptorcalls on the Event.idleEventDefinitions.compiler-output/native-read-scopes(new script, per empty-arm module):empty_brackets.Validation
pnpm format:checkpnpm typecheckpnpm test: package prechecks passed. The single-processvitest runhits the default heap limit locally (CI shards it), so I reran it withNODE_OPTIONS=--max-old-space-size=16384: 4,310 files and 72,091 tests passed, 2 failed. Both failures are inbase-ui-pristine-browser, which runs upstream Base UI against React rather than Octane, and both are hover/pointer timing tests. Rerun 3× in isolation on this branch and on an untouchedorigin/mainworktree, each passed 3/3.tests/hydration/mismatch-structural.test.ts: 3 new production cases failed onmain(1 root-source read each) and pass now. A new dev case pins the location warnings; it went red when I disabled either dev path.tests/unhandled-delegated-events.test.ts(new): nativecurrentTarget/stopPropagationfor native listeners, capture-only paths, the non-bubblingplaypath, and disabled controls. Sabotage checks:submitRecguard fails 11 action/submission tests.currentTargetfails the new suite.stoppedexpression fails theplaycase.tests/native-read-empty-branches.test.tsrx(new): the reading arm stays reactive and unsubscribes cleanly beside empty arms. This is a preservation test: reads are also framed by the runtime, so the size and work claim lives in the ratio-guarded benchmark.node scripts/error-codes/generate.mjs --checkandnode --test scripts/error-codes/generate.test.mjs(5/5). The new generator test went red when the covered-path pattern was emptied.pnpm ci:workflow:test(276/276) and every later lint-job step, includingpnpm build.benchmarks/scoped-signals/bundle-boundaries.test.mjsnow expects the coded production error Feat/playground layout #301 instead of the English "duplicate keys" text.node benchmarks/bench.mjs --quick --ratios compiler-output: 18 guards, pass.node benchmarks/event-delegation/dispatch-work.mjs: gate pass.Risk / follow-ups
Minified Octane error #N, asruntime.tsalready does. One compiler test that bundles for production now expects the coded message.data-encoding.tsandserver/*still ship English errors.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches event dispatch semantics, hydration failure paths, and production error text across large runtime surfaces, though new benchmarks and tests aim to pin behavior.
Overview
This PR cuts production bundle size and hot-path work across hydration recovery, delegated events, compiled native-read scopes, and framework error formatting.
Production error codes (81–331) replace full English strings from the signal engine, hydration, and DOM-binding runtimes with
Minified Octane error #<code>in production; dev messages stay the same. Catalog, CLI data, and generated formatters are extended accordingly.Delegated events skip installing/restoring
stopPropagationandcurrentTargeton theEventwhen a phase has no handler on the path (and bubbling has no form action), while capture still reports “not stopped” so non-bubbling types keep flowing. Benchmarks add an idle click target and anidleEventDefinitionsratio guard.Compiler
wrapNativeReadScopeno longer wraps empty@if/@elsearms, avoiding pointless read-scope entry each render;native-read-scopes.mjsand ratio guards lock this in.Hydration (per changeset/PR context) gates dev-only root recovery diagnostics in production so bundles do not stringify root components or build mismatch descriptions.
Tests and benchmark READMEs are updated (e.g. production bundle expectations for coded duplicate-key errors).
Reviewed by Cursor Bugbot for commit 83dc7ec. Bugbot is set up for automated code reviews on this repo. Configure here.