Repository navigation
perf(octane): write unset and string native styles without a Block - #1854
Merged
Merged
Conversation
A module that imports octane/signals compiles every non-literal style, such as
a forwarded style={props.style}, to nativeStyleBinding, because the value might
carry signal handles. The binding then allocated and rendered a control-flow
Block even for undefined, null or a string, which carry no native read. A
production audit of a signed-out home page found 273 such Blocks in one
hydration (about 8 ms at 4x CPU throttling).
Any non-object value now takes the existing scalar writer while the binding has
no Block, whatever the compiler's literal flag. Presentation hydration prepares
the same plain style takeover write without a Block or read witness. The
existing upgrade still allocates the Block, seeded with the last applied style,
once a structured value arrives; the Block then stays, so a later unset style
releases its subscriptions through its own transactional render.
hydrateClaimedBindingCaches dereferenced binding.block for every native style
claim. A Block-less scalar style literal in a signal-enabled binding view made
hydration throw, so the host was rebuilt on the client; it now updates the
binding's own cache.
nativeProjectionBinding is unchanged: the compiler emits it only for
projections that syntactically read handles, so its Block owns real reads.
The signal-dom-bindings bench gains a forwarded-style lane with ratio guards:
style Blocks 2 -> 0 and native style bodies 200 -> 0 per 100 updates.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
October 7, 2026 19:19
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | 2408f1c | Commit Preview URL Branch Preview URL |
Oct 07 2026, 07:21 PM |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | 2408f1c | Commit Preview URL Branch Preview URL |
Oct 07 2026, 07:22 PM |
Contributor
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)
54 other measured values are unchanged. Public-import reachability bundles (bytes)No changes across 108 measured values. |
trueadm
added a commit
that referenced
this pull request
Oct 7, 2026
Conflicts: app-budgets.json and minimal-budgets.json, where #1854 and #1855 lowered the rows this branch had tightened. Take main's values, then write this branch's measurements (`--write-budgets`) on the merged tree, which only lowers: bindings app gzip and total raw, one app brotli, and three minimal gzip rows. hydrate-frame stays at main's 364,882 raw. It measures 364,886 here and on main alike, and main's own CI fails the same check, so the raise belongs in a budget-only change on main, not in this PR. #1852 stops the Vite plugin parsing modules it only passes through, such as the SSR chunks Nitro re-bundles. The @tsrx/core patch still bounds every module the plugin does compile, so its guard now transforms a 540 kB project module that uses a hook instead of a Nitro chunk: about 2 s patched, 20 s unpatched, against a 6 s bound. The patch note says so. Reformat main's new hydrate-frame fixture; its output is unchanged once position-derived ids are masked. main's changed test files pass on this branch (bundler-compiler, compiler-vite-options, behavior-root, binding-handoff, style-transaction-rollback). Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
In a module that imports
octane/signals, every non-literal style, such as a forwardedstyle={props.style}, compiles tonativeStyleBinding, because the value might carry signal handles. The binding then allocated and rendered its own control-flow Block even when the value wasundefined,nullor a string, none of which has a native read to subscribe to. A production audit of a signed-out home page found 273 of these Blocks among roughly 1,930 hydration-time block renders, about 8 ms at 4x CPU throttling, plus the retained Blocks.nativeStyleBinding). While a binding has no Block, any non-object value now takes the existing scalar writer (writeScalarNativeStyle), whatever the compiler'sliteralflag says. This coversundefined,null, strings, numbers, booleans, and functions, which the native read protocol never reads. It writes throughsetStyleexactly as the Block's body would, including hydration'skeepsStylecomparison, and journals its cache for rollback.presentationWrite('nativeStyleBinding')). This is the prepared-body and witness path that later swaps in the plain body, minified asjr/Mr. A scalar value now prepares the plain takeover write (setStyle(el, normalized, '')) without a Block or read witness.hydrateClaimedBindingCachesdereferencedbinding.block!for every native style claim. Since perf: drop the signal tax from ordinary attribute, text and style bindings #1270, a scalar style literal such asstyle={{ opacity: props.opacity }}has no Block. In a signal-enabled'use dom bindings'view whose early binding claimed the style, hydration threw aTypeError, surfaced as a recoverable mismatch, and rebuilt the host on the client. A Block-less binding now updates its own cache.nativeProjectionBindingis unchanged. The compiler emits it only when the projection expression syntactically reads a handle (lowerNativeAttributeReadsmarks itreactiveforx$orx$.get()), so its Block owns real reads. Skipping that Block would mean evaluatingcompute()outside it, which moves read ownership and error and suspense attribution and costs a second evaluation on upgrade.Performance
signal-dom-bindingssuite gains aforwardedlane: a host whose style is a forwarded string and a child whose forwarded style is unset, displaying the same CSS as the other lanes with the same host and child identity. Its observed bundle counts the native style Block allocation sites and body invocations. Onmainit allocates 2 style Blocks and runs 200 native style bodies per 100 updates; on this branch both are 0. Two newratios.jsonguards (style_blocksandstyle_update_bodies,forwarded/direct,maxRatio: 0) enforce this.capture-only,hydrate-rootandprop-attributesbyte-identical tomain, and every app's framework gzip identical (CI's bench report agrees: all app, minimal and reachability values unchanged). Thesignal-dom-bindingsproduction bundle, a native-read app with style bindings, grows by 42 B raw. The full-framework ceiling bundle, which also contains the presentation-hydration and claimed-cache paths, grows by 214 B raw / 73 B gzip, within its budget. No budget changes.octane-tsrxandoctane-jsxproduction bundles from both trees and they are byte-identical, so calls and DOM mutations per operation cannot change.Validation
pnpm format:check: not run repo-wide.pnpm format:files:checkon every changed file passes.pnpm typecheck: not run repo-wide.pnpm typecheck:fileson the changed tests, runtime and bench fixture reports no new errors; the remaining errors in those files are pre-existing onmain.pnpm test: not run in full, to keep local load down.octaneproject, all passing:style-transaction-rollback,binding-handoff,behavior-root,signals-dom-bindings,style-object-literals,scalar-dom-bindings,binding-handoff-displaced-host,signals-rendering,strong-hook-cache,hydration/signal-instance-identity(767 tests).node benchmarks/bundle-size/run-minimal.mjs --budgetsandnode benchmarks/bundle-size/run.mjs --budgets octane-tsrx octane-jsxhold.node benchmarks/bench.mjs signal-dom-bindings --ratios --quick: all 5 applicable guards pass. That suite's separateevent-owners.mjsharness fails its compile-output assertionenableSignalBindings(1, true)identically onmain; that is unrelated and noted below.New regression tests, each run native and ordinary, dev and prod:
Deliberate breaks, each caught:
undefinedinstead of''fails the takeover test.hydrateClaimedBindingCachesfix makes the native-literal adoption test fail: the host is rebuilt. It fails the same way onmain.Risk / follow-ups
stylethat the client leaves unset as a hydration mismatch, while the ordinary binding's unchanged-value guard skips that comparison. React would report it.keepsStylehonors only per-declaration (style:<prop>) early-binding claims. An early binding's whole-string style publication is reported in dev by both writers and is not claimed, so a render that returns to the hydration-time value would not republish over it.benchmarks/scoped-signals/event-owners.mjsfails its compile-output assertion on currentmain. It runs only in the weekly or manual bench.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 core DOM style binding, hydration takeover, and transactional rollback paths in the runtime; behavior changes are heavily tested but affect every signal-capable forwarded or optional
styleprop.Overview
Signal-enabled modules no longer allocate a native style presentation Block for
stylevalues that have nothing to subscribe to—undefined,null, strings, and plain scalar object literals. Those are written with the same scalar path as ordinary styles until a structured or handle-bearing value appears; only then is a Block created (and kept for transactional teardown on later unset/string renders).Presentation hydration prepares scalar native style takeovers as plain
setStylewrites without a Block, and claimed-binding cache adoption no longer assumes every native style binding has a Block—fixing hydration throws when an early binding claimed a scalar literal style.Benchmarks add a forwarded
stylelane and ratios guards that forwarded unset/string styles allocate zero blocks and skip native style bodies; tests cover hydration handoff, rollback while renders wait, and unset → signal handle → unset upgrades.Reviewed by Cursor Bugbot for commit 2408f1c. Bugbot is set up for automated code reviews on this repo. Configure here.