Skip to content

perf(bindings): adopt URL channels with the scalar adopter - #1525

Merged
trueadm merged 4 commits into
mainfrom
perf/scalar-url-bindings
Oct 2, 2026
Merged

trueadm merged 4 commits into
mainfrom
perf/scalar-url-bindings

Conversation

@trueadm

@trueadm trueadm commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Fixed-node 'use dom bindings' views that bind a URL attribute (href, src, action, formAction, xlink:href, …) now compile to the scalar adopter instead of the general one. A URL view adopted through adoptBindings drops from 5,732 to 3,872 B gzip (−32%).
  • The URL sanitizer reaches the scalar adopter only through a capability the compiler attaches to URL views. URL-free views never load it.
  • Fix: an early binding's URL update is now kept when the application hydrates over it, as its other attributes already were. Before, hydrateRoot reverted it to the rendered value.

Closes #1284. This is the last increment of proposal 4. The re-measurement and decisions comment covers everything else; follow-ups were split into #1513 and #1514.

Why

#1286 gave fixed scalar views (attr, boolean, aria, class, text) a lean adopter. A single URL channel still sent a view to the general adopter, which carries projections, controls, class groups, style restoration, host handoff and addressed topology. URL handling only needs one more normalizer and writer, both already in dom-bindings.ts.

The hydration gap turned up while checking parity. Both adopters publish the values they wrote to the legacy claim map, which hydrateRoot consults (allowAttribute) so it doesn't overwrite a newer early publication. URL channels were left out of that list, so after an early href update, hydration with the older props restored the old href while keeping the adopted title.

Changes

  • dom-bindings.ts
    • __bindingURL: a [accepts, normalize, write] tuple that reuses the existing general channel rules, so URL semantics keep a single source.
    • __adoptScalarBindings takes all three hooks from descriptor.url, falling back to the fixed scalar ones. It still refuses a URL descriptor without the capability (error 330), so version skew can't write an unsanitized URL.
    • write/writeFixedScalar return the value left in the DOM. Both adopters publish that value, and URL channels now join the handoff. An empty URL that the writer removes (an empty src, or href on anything but <a>) is therefore published as an absent attribute, which is what hydration compares against.
  • compiler/dom-bindings.js: url joins the scalar-adopter channel set. scalarURL(plan) imports __bindingURL and sets url on the descriptor, at both emission sites: adopt-only artifacts, and the scalar SSR adoption inside mountable artifacts.
  • verify-dist.mjs: the published build must export __bindingURL.

Measurements

Production esbuild bundles: minify, tree shaking, ESM, browser, NODE_ENV=production, gzip-9 / Brotli-11. The baseline is this branch's merge base b5277d166, built from a git archive of packages/octane. Each consumer is a compiled .tsrx view plus a compiled activation module calling adoptBindings (and mountBindings where noted).

Consumer Baseline raw / gz / br Candidate raw / gz / br gzip delta
href + text view 14,747 / 5,732 / 5,155 9,143 / 3,872 / 3,518 -1,860 (-32.4%)
<img src> + <svg><use href> 14,780 / 5,755 / 5,187 9,176 / 3,893 / 3,536 -1,862 (-32.4%)
href + text, adopt + mount 37,567 / 13,050 / 11,794 32,658 / 11,533 / 10,457 -1,517 (-11.6%)
Docs PrimaryAction (no URL) 7,708 / 3,401 / 3,079 7,751 / 3,419 / 3,092 +18 (0.5%)
title + text view (no URL) 7,510 / 3,329 / 3,015 7,553 / 3,344 / 3,025 +15 (0.5%)
class + text view (no URL) 7,518 / 3,329 / 3,027 7,561 / 3,345 / 3,042 +16 (0.5%)
title + text, adopt + mount (no URL) 32,556 / 11,446 / 10,401 32,620 / 11,505 / 10,425 +59 (0.5%)
.tsrx signal state + handle view (structural program) 80,502 / 25,430 / 23,042 80,523 / 25,437 / 23,071 +7 (0.0%)
export { __adoptBindings } 13,490 / 5,228 / 4,695 13,530 / 5,250 / 4,706 +22 (0.4%)
export { createRoot } from 'octane' 196,986 / 63,005 / 54,650 196,986 / 63,005 / 54,650 +0 (0.0%)
export { createScope, query } from 'octane/signals' 42,650 / 13,351 / 12,104 42,650 / 13,351 / 12,104 +0 (0.0%)
  • URL-free scalar views pay about 15–18 B gzip (+43 raw) for the capability lookup in the scalar adopter. The URL-free mountable fixture pays +59 B gzip for +64 raw, since it carries both the scalar adopter and the program's general writer.
  • The general adopter pays +22 B gzip for the handoff fix: it now records the written value and includes url.
  • Ordinary createRoot and the signals engine are unchanged.

CI ratio guard (bundle-boundaries.test.mjs, selected/general gzip): Scalar 0.50 adopt-only / 0.82 mountable (ceilings 0.6 / 0.88); Link 0.57 / 0.82 (ceilings 0.65 / 0.88).

Validation

  • packages/octane/tests/scalar-dom-bindings.test.ts, run through both the scalar and the general adopter, dev and prod compile, octane and octane-prod projects:

    • URL channels: javascript: blocking (including leading controls and embedded newlines), empty-URL rules (kept on <a href>, removed elsewhere), removal, signal-handle URLs updating without a source read, and teardown;
    • hydration keeps adopted URL and attribute publications, including a removed src, with no mismatch report;
    • hydration still repairs a URL changed after its publication (dev reports it);
    • a URL descriptor stripped of its capability is refused before claiming or subscribing, and the general adopter still sanitizes it.
  • Pre-fix failure: with url left out of the general adopter's handoff (the previous behavior), the general lanes of the hydration test fail.

  • Mutation checks, each applied alone and reverted, all caught:

    Mutation Failing tests
    general adopter leaves url out of the handoff 2
    scalar adopter skips url publication 2
    scalar adopter publishes the normalized value, not the written one 2
    general adopter publishes the normalized value 2
    capability skips sanitization 2
    capability writes url as a plain attribute 4
    scalar adopter accepts url without the capability 2
    compiler omits the capability 6
    (guard) URL views keep the general adopter bundle guard
    (guard) URL-free views load the sanitizer bundle guard
  • benchmarks/scoped-signals/bundle-boundaries.test.mjs (runs in ci:workflow:test): 30/30. The fixed-scalar guard now requires URL views to select the scalar adopter and keep sanitize-url.js, URL-free adopt-only views to emit zero sanitizer bytes, and per-view gzip ratio ceilings. It still checks identical DOM traces against the general adopter, adopt-only and mountable.

  • Nearby suites: binding-handoff, behavior-root, behavior-handoff-bundle, hydration/range-boundary, hydration/text-sibling-hydrate, and compiler bundler-compiler, compiler-vite-options, native-reads, production-bundle, typescript-text-inference.

  • pnpm --filter octane build: dist built, imports verified, and __bindingURL present in the browser and Node builds.

  • pnpm format:check and pnpm typecheck (repo-wide, after the first base merge), plus pnpm sync (no changes). After the final base merge: scoped pnpm typecheck:files, the targeted suites above and the bundle guard, all passing.

  • pnpm test (repo-wide): left to CI.

Risk / follow-ups

  • Behavior change: URL publications by early bindings now survive hydration. That matches the documented handoff, where fixed native views transfer attributes. A URL changed by something else afterwards is still repaired and reported.
  • write now returns the published value. Other callers (__writeBinding in programs, styles, projections) ignore it.
  • Under heavy parallel load, two behavior-root textarea retirement tests can exceed the 5 s default timeout. They take 0.5–5.6 s each on unmodified main too, and pass in isolation.
  • DOM bindings: a signal handle cast to number in a text hole cannot adopt its own SSR output (#318) #1513: a handle cast to number in a binding text hole can't adopt its SSR output. Pre-existing, separate.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


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
Changes binding codegen, URL sanitization wiring, and hydration handoff for URL attributes; incorrect capability or claim publication could affect security or hydration mismatches.

Overview
Fixed-node 'use dom bindings' views that bind URL attributes (href, src, etc.) now compile to the scalar adopter instead of the full general adopter. The compiler attaches a url capability (__bindingURL) only when the view needs it, so URL-free bundles do not pull in sanitize-url.js; adopt-only URL views are roughly 32% smaller gzip.

__adoptScalarBindings delegates normalize/write to that capability while still rejecting URL bindings without it. Both adopters now publish the value left in the DOM (not just the normalized snapshot) into the legacy claim map for scalar and URL channels, so hydrateRoot keeps early-adopted URL updates instead of reverting to SSR props.

Bundle-boundary tests and scalar DOM binding tests cover sanitizer inclusion, gzip ratios, sanitization, and hydration parity.

Reviewed by Cursor Bugbot for commit 05b76a8. Bugbot is set up for automated code reviews on this repo. Configure here.

trueadm and others added 4 commits October 1, 2026 23:36
Fixed-node `'use dom bindings'` views that bind a URL attribute now
compile to `__adoptScalarBindings` instead of the general adopter. The
compiler attaches a `__bindingURL` capability (accept, normalize and
write through the existing general channel rules) only to artifacts
that bind a URL, so URL-free views never load the sanitizer. The scalar
adopter still refuses a URL descriptor without that capability.

URL publications now join the legacy hydration handoff in both
adopters, publishing the value actually left in the DOM. Previously an
early binding's URL update was reverted when the application hydrated,
while its other attributes were kept.

Refs #1284.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Oct 1, 2026
@trueadm
trueadm marked this pull request as ready for review October 1, 2026 23:23
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🟡 js-framework: 4 timed operation(s) possibly slower

Compares 3e3749d3f with 3f5944340 on the same runner. Timing verdicts require a change beyond the combined margin of error (at least 5%) and one 0.1ms timer tick, with the fastest sample moving the same way. Workflow run

js-framework: 1k/10k row operations (ms, lower is better)

target operation base head Δ noise
octane-tsrx replace 8.55 14.34 +67.7% ±62% 🟡 slower
octane-tsrx update 0.45 0.79 +75.6% ±55% 🟡 slower
octane-tsrx swap 0.38 0.63 +65.8% ±43% 🟡 slower
octane-tsrx remove 0.37 0.53 +43.2% ±39% 🟡 slower
All 20 timed operations (16 within noise)
target operation base head Δ noise
octane-tsrx run 3.92 6.53 +66.6% ±67% ⚪ within noise
octane-tsrx replace 8.55 14.34 +67.7% ±62% 🟡 slower
octane-tsrx add 3.98 7.05 +77.1% ±79% ⚪ within noise
octane-tsrx update 0.45 0.79 +75.6% ±55% 🟡 slower
octane-tsrx select 0.19 0.24 +26.3% ±63% ⚪ within noise
octane-tsrx swap 0.38 0.63 +65.8% ±43% 🟡 slower
octane-tsrx remove 0.37 0.53 +43.2% ±39% 🟡 slower
octane-tsrx runlots 41.29 46.22 +11.9% ±43% ⚪ within noise
octane-tsrx select_lots 0.24 0.20 −16.7% ±55% ⚪ within noise
octane-tsrx clear 39.78 43.43 +9.2% ±25% ⚪ within noise
octane-jsx run 6.45 6.92 +7.3% ±88% ⚪ within noise
octane-jsx replace 8.56 11.52 +34.6% ±52% ⚪ within noise
octane-jsx add 4.59 6.24 +35.9% ±104% ⚪ within noise
octane-jsx update 0.77 1.23 +59.7% ±62% ⚪ within noise
octane-jsx select 0.51 0.68 +33.3% ±59% ⚪ within noise
octane-jsx swap 0.91 1.31 +44.0% ±56% ⚪ within noise
octane-jsx remove 0.76 1.07 +40.8% ±63% ⚪ within noise
octane-jsx runlots 36.87 51.60 +40.0% ±77% ⚪ within noise
octane-jsx select_lots 3.32 3.46 +4.2% ±44% ⚪ within noise
octane-jsx clear 42.46 47.91 +12.8% ±28% ⚪ within noise

Application bundle size (bytes)

No changes across 45 measured values.

Public-import reachability bundles (bytes)

No changes across 105 measured values.

CI job durations

  • 🟡 1 job(s) slower than every recent main run: React parity checks
  • 🟢 4 job(s) faster than every recent main run: example apps (3/3), example apps (2/3), typecheck checks, test shard (Node 24, 2/4)

Compares the CI run for 05b76a823 (run) with the last 5 successful main push runs. A job is only slower or faster outside the whole main range, by at least 10% and 15s.

job main median main range this PR Δ
wall clock (first job start to last job end) 17m 36s 13m 51s–23m 15s 30m 06s +12m 30s (+71%) 🟡 slower
total job time 178m 49s 157m 01s–242m 49s 164m 49s −14m 00s (−8%) ⚪ within noise
React parity checks 16s 15s–18s 5m 36s +5m 20s (+2000%) 🟡 slower
example apps (3/3) 4m 19s 3m 41s–6m 06s 3m 37s −42s (−16%) 🟢 faster
example apps (2/3) 4m 44s 3m 44s–9m 58s 3m 37s −1m 07s (−24%) 🟢 faster
typecheck checks 10m 02s 8m 33s–11m 07s 8m 02s −2m 00s (−20%) 🟢 faster
test shard (Node 24, 2/4) 14m 32s 12m 25s–15m 53s 11m 26s −3m 06s (−21%) 🟢 faster
All 26 timed jobs
job main median main range this PR Δ
React parity checks 16s 15s–18s 5m 36s +5m 20s (+2000%) 🟡 slower
test shard (Node 24, 1/4) 13m 16s 10m 39s–17m 32s 15m 45s +2m 29s (+19%) ⚪ within noise
classify changeset release 16s 15s–17s 16s ±0s (±0%) ⚪ within noise
lint 4s 4s–5s 4s ±0s (±0%) ⚪ within noise
typecheck 4s 3s–5s 4s ±0s (±0%) ⚪ within noise
test (24) 4s 4s–5s 4s ±0s (±0%) ⚪ within noise
CI provenance 4s 3s–4s 4s ±0s (±0%) ⚪ within noise
examples 4s 4s–4s 3s −1s (−25%) ⚪ within noise
Lynx compatibility 2m 10s 1m 35s–2m 55s 1m 48s −22s (−17%) ⚪ within noise
example apps (1/3) 4m 03s 3m 12s–9m 27s 3m 36s −27s (−11%) ⚪ within noise
validate publishable packages 5m 03s 4m 32s–5m 22s 4m 34s −29s (−10%) ⚪ within noise
heavy integration (package builds, eval corpus, runtime loaders, Astro) 6m 35s 5m 30s–16m 52s 6m 00s −35s (−9%) ⚪ within noise
website integration suite 6m 30s 5m 59s–11m 41s 5m 52s −38s (−10%) ⚪ within noise
React parity shard (2/4) 11m 47s 10m 32s–19m 40s 11m 08s −39s (−6%) ⚪ within noise
example apps (3/3) 4m 19s 3m 41s–6m 06s 3m 37s −42s (−16%) 🟢 faster
test shard (Node 24, 3/4) 11m 39s 10m 05s–13m 34s 10m 52s −47s (−7%) ⚪ within noise
Three compatibility 3m 42s 2m 41s–3m 51s 2m 52s −50s (−23%) ⚪ within noise
lint checks 9m 40s 8m 35s–11m 33s 8m 44s −56s (−10%) ⚪ within noise
React parity shard (4/4) 13m 19s 11m 22s–22m 17s 12m 15s −1m 04s (−8%) ⚪ within noise
example apps (2/3) 4m 44s 3m 44s–9m 58s 3m 37s −1m 07s (−24%) 🟢 faster
React parity shard (3/4) 12m 46s 10m 11s–18m 01s 11m 31s −1m 15s (−10%) ⚪ within noise
React parity shard (1/4) 12m 33s 10m 54s–18m 11s 11m 14s −1m 19s (−10%) ⚪ within noise
test shard (Node 24, 4/4) 12m 54s 11m 03s–14m 15s 11m 22s −1m 32s (−12%) ⚪ within noise
typecheck checks 10m 02s 8m 33s–11m 07s 8m 02s −2m 00s (−20%) 🟢 faster
heavy integration (browser - chromium) 16m 56s 12m 15s–19m 08s 14m 23s −2m 33s (−15%) ⚪ within noise
test shard (Node 24, 2/4) 14m 32s 12m 25s–15m 53s 11m 26s −3m 06s (−21%) 🟢 faster

@trueadm
trueadm merged commit 791f12e into main Oct 2, 2026
75 of 78 checks passed
@trueadm
trueadm deleted the perf/scalar-url-bindings branch October 2, 2026 00:12
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.

Reduce runtime reachability for scoped signals and fixed-node bindings

1 participant