Repository navigation
perf: drop the signal tax from ordinary attribute, text and style bindings - #1270
Merged
Merged
Conversation
…dings
Opaque props in a signal-free module lower to potential signal bindings.
bindSignalAttribute routed statically named attributes through the generic
setAttribute, retaining every form-control writer, dom-tables.js and
sanitize-url.js (+7 KB gzip for one `title={props.label}`). The compiler now
passes the writer it already selects (setPlainAttribute, setURLAttribute,
setStringData, setAriaAttribute, setBooleanAttribute), so the runtime has no
generic fallback. The restored-textarea check moves behind the control policy.
In native-read modules, a style object literal whose values are all scalars is
written directly and allocates its owning Block only when a handle appears.
Components that evaluate no authored code skip the native-read bracket.
Adds a prop-attributes minimal bundle fixture with a budget, ratio guards and
a per-PR CI gate, since the existing fixtures never exercised this path.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Style block upgrade skips rollback
- Added journalRootProperty(binding, 'block', binding.block) before the assignment in the scalar-to-block upgrade branch so rollback restores binding.block to null, preventing dangling references to disposed blocks.
Or push these changes by commenting:
@cursor push 2e2920de31
Preview (2e2920de31)
diff --git a/packages/octane/src/runtime.ts b/packages/octane/src/runtime.ts
--- a/packages/octane/src/runtime.ts
+++ b/packages/octane/src/runtime.ts
@@ -1278,6 +1278,7 @@
const block = createBlock('control-flow', owner.block, el, null, null, body, props);
block.parent = owner;
if (binding.el === el) block.slots[0] = binding.style;
+ journalRootProperty(binding, 'block', binding.block);
binding.block = block;
} else {
const block = binding.block!;You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 699ab35. Configure here.
Contributor
domgan-oai
marked this pull request as ready for review
September 23, 2026 09:43
The scalar-to-block upgrade path in nativePresentationBinding assigned binding.block without journaling it. On transition rollback, the JOURNAL_CREATED entry would unmount and dispose the block, but binding.block still pointed at the disposed block, leaving a dangling reference that could cause later renderBlock calls to operate on a disposed block or let the block keep writing styles after rollback. Add journalRootProperty(binding, 'block', binding.block) before the assignment so rollback restores the binding to the scalar path. Applied via @cursor push command
3 of 5 tasks
trueadm
added a commit
that referenced
this pull request
Sep 23, 2026
… fast path #1282 removed `hydrateAttributeProbe` along with the side-render capture it served, deleting this exact guard from `nativePresentationBinding`. #1270, branched earlier, copied that guard into its new scalar-literal fast path in `nativeStyleBinding`. Both merged, leaving main referencing an undefined name: `tsc` fails (TS2304), the octane build and every package pack fail, and in dev the fast path throws `ReferenceError: hydrateAttributeProbe is not defined` (#1270's own style-transaction and signal-binding tests fail). Drop the guard to match #1282's removal in the general path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
added a commit
that referenced
this pull request
Sep 23, 2026
… fast path (#1283) #1282 removed `hydrateAttributeProbe` along with the side-render capture it served, deleting this exact guard from `nativePresentationBinding`. #1270, branched earlier, copied that guard into its new scalar-literal fast path in `nativeStyleBinding`. Both merged, leaving main referencing an undefined name: `tsc` fails (TS2304), the octane build and every package pack fail, and in dev the fast path throws `ReferenceError: hydrateAttributeProbe is not defined` (#1270's own style-transaction and signal-binding tests fail). Drop the guard to match #1282's removal in the general path. Co-authored-by: Claude Opus 5.5 <[email protected]>
1 task done
trueadm
added a commit
that referenced
this pull request
Oct 3, 2026
The compiled/source gzip guard (maxRatio 1.06) records 26132 / 24713 from 136b0e3 (#638). The suite wrote no numbers from 2026-09-16 until its Rspack chunk assertion was fixed, so nothing checked it. Main now measures 35039 / 27077 = 1.294x. Splitting the growth: - Compiler: the 136b0e3 corpus files the current compiler still accepts (14 of 16) compile to 22338 -> 25107 gzip. A sampled timeline plus git bisect over that fixed set names 5ead1ff (#1069): +2065 B in one step, because every opaque text and attribute binding became signal-capable. #1270 kept that design while removing its runtime tax. The rest is gradual. - Corpus: tests extended the context, boundary, control, controlled-forms-diff and components fixtures. Source gzip rose 24713 -> 27077 and those fixtures add the remaining +6138 compiled bytes. Both are intended, so the ceiling moves to 1.30, leaving 161 B. Co-authored-by: Claude Opus 5.5 <[email protected]>
4 of 7 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
This fixes items C1–C3 from the 2026-09-22 review sweep (the "signal tax" first reported in #1130). Ordinary code with no signals import was paying for the signal binding path in bundle size, and modules that import
octane/signalswere paying for it in per-row style Blocks.C1: prop-driven attributes (size). In a module with no signals import, an opaque value such as
title={props.label}still compiles tobindSignalAttribute. The runtime then sent the plain attribute case to the genericsetAttribute. That pulledsetValue/setChecked/setSelectValue,armControlled, the restore helpers,dom-tables.jsandsanitize-url.jsinto every such bundle: +7.0 KB gzip (+25%) for a one-component counter. #1141 split the value and checked policies, but the attribute policy still reached every control writer through that fallback.setPlainAttribute,setURLAttribute,setStringData,setAriaAttribute,setBooleanAttribute) as the writer argument.writeDirectSignalAttributehas no generic fallback anymore.classstays a string tag because its writer depends on the namespace. Development builds still pass the genericsetAttribute, as before.C2 (size).
createDirectSignalBindingcalledisRestoredHydrationTextareadirectly, which puthydration/control-capture.tsinto every text and attribute binding. It is now reached throughDIRECT_SIGNAL_CONTROL_POLICY.restored. Only control policies take a snapshot, so the behaviour is unchanged.C3: styles in native-read modules (perf). In a module importing
octane/signals,style={{ color: props.color }}created a per-elementcontrol-flowBlock and rendered it on every update.nativeStyleBindingwrites it directly, with transition journaling of its style cache. It creates the Block only when a structured value first appears, starting from the style already applied. After a Block exists, that element keeps using it.beginNativeReadScope/endNativeReadScopetry/finally. The check allows only listed node types and applies on the client only.Budget gap. None of the existing minimal fixtures exercised a prop-driven attribute, which is why the budgets missed C1. This adds
fixtures/minimal/prop-attributes.tsrx. It checks behaviour in the production runtime, including that ajavascript:href is sanitized, and asserts thatdom-tables.jsandcontrol-capture.tsare absent from the bundle. It gets a budget (about 3% headroom), threemaxRatio: 1guards, and a place in the per-PR CI budget step.Measurements (production Vite, measured locally on Node 24.18)
Before and after on the same base (c25a185):
prop-attributesfixturetitle={props.label}countercli-spa-starterNo other bundle-reachability scenario grew; one esbuild bundle differs by 1 byte. On the rebased head (2554d85, where main itself grew about 250 B),
prop-attributesmeasures 31,830 against its 32,528 budget.Style, 2,000 rows × (mount + 10 updates) in jsdom, in a module that imports
octane/signals:createBlock4,001 → 2,001 andrenderBlock44,011 → 22,011. The per-row style Blocks are gone.Validation
pnpm format:files:checkon the changed filespnpm format:check: not run repo-widepnpm typecheck: not run repo-wide.pnpm typecheck:filesreports one error, intests/compiler/signal-bindings.test.ts:2(@tsrx/corehas no declaration file). That import line is unchanged from main.pnpm test: the full run crashed with an out-of-memory error in the vitest main process after about 3.2 h, while the machine's load average was around 50. Before the crash, failures were timeouts across unrelated packages, plus a few hydration files that passed 452/452 on two reruns at lower load.octane,octane-prodand alloctane-signals*projects on c25a185 plus this change: 1,223 files, 23,514 tests passed.node --test scripts/ci-workflow.test.mjsandnode benchmarks/bundle-size/run-minimal.mjs --budgets root-static-local hooks-state prop-attributes contextboth pass.New regression tests. Each was seen to fail with the implementation deliberately broken.
compiler/signal-bindings.test.tschecks the writer each attribute gets, including that production never uses the genericsetAttribute.signals-dom-bindings.test.tscovers handles and scalars for every writer kind with dev and prod compiles. The prod case stubsNODE_ENV=production, because otherwise the narrow writers delegate tosetAttributein tests.signals-dom-bindings.test.tsmoves an object-literal style between scalars and signal handles for both fresh render and hydration, in dev, prod and strong compiles.style-transaction-rollback.test.tsnow also runs withimport 'octane/signals'. Removing the scalar-path journal entry makes 6 of its cases fail.compiler/native-reads.test.tschecks that the wrapper is kept for component tags, destructured parameters, setup statements and dynamic values.Risk / follow-ups
bindSignalAttributechanged from a kind string to a writer function (or'class'). It is a privateoctane/internal/clienthelper, and the compiler and runtime ship together._$enableSignalBindings(1, true)is still emitted for signal-free modules and accounts for the remaining ~1.6 KB. The runtime comments say it keeps component identities so that a signals module loaded later still works, so removing it is a design decision rather than a size fix.binding-aria-esbuildin the full reachability suite fails to build on main as well (Unexpected "enum"inTokenFieldValue.tsx).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 compiler emission and private
bindSignalAttribute/ direct-signal binding ABI plus native style and hydration paths; mitigated by new fixture gates and broad regression tests.Overview
Reduces bundle size and runtime work when code uses prop-driven DOM bindings or plain style objects without actually importing signals.
Prop-driven attributes and text now pass the compiler’s statically chosen scalar writer (e.g.
setPlainAttribute,setURLAttribute) intobindSignalAttributeinstead of routing through genericsetAttributeand form-control DOM tables. Text/attribute direct bindings only pull restored-textarea hydration through control policies, not every binding.Native style bindings in signal modules can write plain object-literal styles directly and defer allocating an owning Block until a non-scalar or handle-backed value appears; scalar caches journal for transitions and rollback.
Pure static host components (literal markup only, no setup/destructuring/component tags) skip the native-read scope wrapper around render.
Benchmarks/CI add the
prop-attributesminimal fixture with byte budgets and reachability checks thatdom-tables.jsandcontrol-capture.tsstay out of signal-free prop-attribute bundles.Reviewed by Cursor Bugbot for commit 345a769. Bugbot is set up for automated code reviews on this repo. Configure here.