Skip to content

Commit fd36d37

Browse files
ryansolidClaude via Cursorcursoragent
authored
feat: Chrome Performance panel tracks for Solid (@solidjs/web/performance-tracks) (#3580)
* feat(web): Chrome Performance panel tracks for Solid — engine foundation, adapter, timeline records Stage 0 — shared engine foundation (@solidjs/signals, @solidjs/web): - attribution.enable()/disable() are ref-counted: the engine is shared by every consumer on the page (a profiler track, an APM adapter, a diagnostics capture); the first hold installs, each enable() opens a fresh window over the ring buffers and folds without disturbing live tracking or others' subscriptions, the last disable() uninstalls. - `checks` option: one switch for the five thresholded cost checks, for records-only consumers. - isSilentHold / isLongHold exported, so adapters paint the engine's own verdicts rather than re-deriving thresholds. - dispatchAsInteraction passes at: e.timeStamp; InteractionEvent gains inputDelayMs (event creation → handler entry, the INP input-delay term) and handlerMs measures from the handler's actual start. - ownerPath re-exported from solid-js (client from @solidjs/signals, server via the ownerLabels twin). Stage 1 — @solidjs/web/performance-tracks: - enablePerformanceTracks() paints rerun / interaction / hold / navigation records and the web runtime's call / frame records as tracks in the `Solid` group, retroactively from the records' own performance.now() stamps: performance.measure with detail.devtools (rich: tooltips, properties; dev default) or the six-argument console.timeStamp (observe default). Track seeding for stable display order, minMs floor, scrub mode for shared traces, ref-counted disable. Prod artifact folds to a no-op. - rollup dev/observe/prod entries, ./performance-tracks export conditions, types script. Stage 2 — timeline records (@solidjs/signals, solid-js, @solidjs/web): - Five listener-gated records on attribution.subscribe: create (a computation's creation run), effect (an effect callback, timed and joined to its compute run), flush (one scheduler drain), flight (an async flight to landing or abandonment), fallback (a loading boundary's fallback from show to hide). None is built, logged or folded unless a listener for its type exists; OBSERVE.subjectOf answers for the node-bearing ones. - Core: flushStart hook beside flushEnd (one drain, never nested); effectRunStart now fires in observe like its effectRunEnd twin, so writes inside effect callbacks carry their effect origin in observe too. Observe core +67 B minified; prod byte-identical. - The effect-frame → node map is filled by the first write inside a callback rather than by every callback (every reader resolves it through a write's origin; most callbacks never write). Enabled-engine cost per effect callback is at or below `next` on every configuration measured. - Adapter: creation runs and callbacks on Effects/Memos, drains on a new Scheduler track, flights and fallbacks on a new Async track. Tests: ref-counting, checks, inputDelayMs, the adapter spec (18), the timeline records (12), dist-artifact coverage of both new hooks per tier. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * feat(web): Propagation track — each drain as a wave of its root writes, runs labelled by cause, flow internals folded Replaces the Scheduler track. Nothing re-renders in Solid, so React's component flame has no counterpart; the picture is the graph a write travelled. Each drain paints as a wave named by its root writes and the interaction (`count 0 → 1 — click on button#next · 5 runs, 1 unchanged`); compute runs, creations and effect callbacks paint inside it at their own time labelled `node ← cause`, and the panel stacks them beneath the wave. Labels fold framework structure into what the developer wrote: flow-control internals (Show/Switch/Loading/Errored/Reveal) present as the tag, `primitive.local` names as the primitive, the runtime name kept in a `Node` property. The boundary nodes and Switch's condition builder are now named in observe builds so the fold has names to key on. Engine: ChangeRecord.nodeId on writes and derived changes, same id space as RerunEvent.nodeId, so a derived cause joins the run that produced it. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * compiler: rename componentNames → sourceNames (boolean | { components }) The option becomes the home for every kind of source name the compilers carry into output for the dev/observe runtimes to label the graph with; `components` is the existing behavior, further kinds follow. Object form picks kinds; `true` turns on every kind. Both compilers, the node adapter's validation (rejects the old name and malformed shapes), typings, READMEs, tests, and the web server test config. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * compiler: sourceNames.bindings — name compiled binding effects by their target Attribute effects get `<tag>.<attribute>` as written (`span.textContent`, `div.class:active`; a merged effect lists all its bindings), holes `<tag>.children` through insert's options, spreads pass the tag and the runtime labels `<tag>.spread` / `<tag>.children`. Static holes (component calls, literals) create no effect and get no name. `prop:` the locked DOM property pre-pass added is undone in the label (`input.value`). @solidjs/web: `effect`/`insert` take `{ name }`, `spread` a trailing tag; names land on the render effect nodes for the dev/observe tiers. Both compilers, parity fixtures (dom-source-names suite replaces dom-component-names, run with `sourceNames: true`), option validation, runtime spec, READMEs. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * compiler: transformSourceNames pass names primitives from their declared identifier The sourceNames.primitives half of Stage 3.5, as its own native pass since it is plain JavaScript in and out and applies to .ts/.js modules: calls resolving to solid-js / @solidjs/signals imports (createSignal, createMemo, createOptimistic, createStore, createOptimisticStore, createProjection) gain { name } from the array pattern, binding, property key, or class field they initialise, prefixed with the enclosing non-component function so a composed primitive's nodes fold under it. Never overrides an explicit name; skips spread/opaque options and the ambiguous two-argument createStore(x, y). Stores now honour options.name in the observe tiers: property nodes read todos.title instead of store.title, derived/optimistic stores included. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * feat(performance-tracks): findings as markers, JSX-site stacks, richer node properties Stage 4 of the Chrome performance tracks plan. - Every DiagnosticEvent delivered while the tracks are enabled is a marker on the panel's Timings track (`SILENT_HOLD — <App> › <Search>`), coloured by severity; at warn or worse it carries detail.devtools.performanceIssue for the Insights sidebar, with the repair guide's section as learnMoreUrl. info stays a plain marker. Under the scrub only code, kind and owner travel. Plain mode uses the one-argument console.timeStamp. - Dev: observedComponent stores console.createTask(label) on _component.task; the adapter emits every span and marker inside the nearest component's task so the entry's stack in the panel is the JSX site (React's _debugTask). - Rich mode adds Owner path (unfolded), Node id and the root write's Origin to node spans. - solid-js exports diagnosticGuideUrl(code), shared with the console footer. - Docs: 08-dev-diagnostics gains the timeline records, the ref-counted enable, the INP join recipe and a performance-tracks section; the plan lands as documentation/plans/chrome-performance-tracks-plan.md. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * chore(size): fold source-name plumbing out of prod; ratchet observe caps for the tracks records Measured against the branch base (49887e1) with the size scenarios: prod core floor, + createStore, + isPending and frames byte-identical; simple app -26 B, CSR -7 B, hydrating + stores -38 B, hydrating +40 B (two `computed(fn, void 0)` trailing arguments the boundary names fold to; the restructured alternatives measured larger under brotli). - createStoreNext loses its `name` parameter - a parameter survives into the prod artifact; the public createStore records the name through nameStore (same attrHooks gate) under __OBSERVE__ instead. - web spread's `.spread`/`.children` labels sit behind "_SOLID_OBSERVE_" so prod folds them to undefined rather than testing the argument at runtime. - Observe tier 17.00 -> 17.15 KB (17,063 measured, +92 B: flushStart site, effectRun hooks under __OBSERVE__, flow-internal and binding names, store names). Observe + attribution 27.50 -> 28.30 KB (28,200 measured, +738 B: ref-counted enable, checks, hold verdicts, at/inputDelayMs, the flush / create / effect / flight / fallback records, nodeId on derived causes). Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * fix(signals): fallback records time the display, not the swap A <Loading> swap is a staged write that lands with its frame (#3575); the engine held the fallback open from the swap and so timed — and, for a swap the content outran or the commit's sweep cleared before any effect ran, recorded — a fallback that was never on screen. The show now carries the transaction the swap is staged in; the engine moves the open to the drain at transitionSettled, follows transitionMerged, stamps `at` at flushEnd, and drops an open hidden before that. The folds hear show/hide from the same gate. Observe caps ratcheted (+72 B tier, +253 B engine); prod unchanged. Co-authored-by: Claude via Cursor <[email protected]> * fix(web): performance-tracks review fixes — single instance, server-inert export, guarded host calls, owned clearing - enablePerformanceTracks: one instance per page; a call while enabled joins it and returns its own release; torn down at the last release - ./performance-tracks: node/worker/deno conditions resolve to the inert artifact under every posture (the tracks are a browser view) - Emitter guards performance/console calls; a throw drops the entry and never reaches the engine's record loop (dev warns once) - rich:false falls back to performance.measure when console.timeStamp is missing (the mirror of the existing fallback) - rich mode clears a User Timing name only while the timeline holds no more of it than the adapter made; an app measure sharing a label is left alone - signals: stagedFallbacks is a WeakMap keyed by transaction (DRAIN is an object key) so a dropped transaction releases its staged opens - changeset: stale 'Scheduler track' wording -> Propagation - docs: transformSourceNames is the compiler pass, sourceNames.primitives the Vite plugin option Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * feat(signals): attribution.enable returns its release; options layer per hold; dev component tasks only under an installed engine Review items 5 and 6 on #3580. - attribution.enable(opts) returns an idempotent release for the hold it takes. Options in effect = defaults with each live hold's opts layered in hold order, recomputed on release — a track's log:false beside a console session gives the log back when it leaves. disable() is the full teardown whatever holds are outstanding, so enable();enable();disable() cannot strand a hold. Prod twin: enable returns noop. - performance-tracks releases through the token and layers log:false only when it is the consumer installing the engine (OBSERVE.attribution.installed === null); joining leaves a co-holder's options alone. - solid-js dev: the component wrapper creates the console.createTask task only while an attribution engine is installed. The per-call stack capture roughly doubled dev mount (10k components 1.9 -> 4.1 ms) for sessions with nothing enabled; observe and prod builds never contained the call. - Tests: layered options + release, disable teardown, adapter join vs install log default, task gating; docs and changesets updated. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * test: CI fixes — tuple typing in the tracks harness, fallback timing asserted against the commit stamp - web test-types: the stubbed-API list is typed [object, string][] (the inferred (string | Console | Performance)[] failed tsc); getEntriesByName is restored with the rest - signals: the shell-landed-first fallback test asserts at >= the landing stamp and shownMs >= the wait instead of a wall-clock upper bound, which a slow runner exceeded Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * fix(diagnostics): captures hold the engine through enable()'s release token capture.ts and the browser bridge release their own hold instead of calling disable(), which under the token contract is the full teardown — a track or APM adapter enabled beside a capture now survives it. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * feat(signals): attribution options combine across holds by the most demanding request Replaces last-wins layering. Each hold's request is resolved against the defaults (an explicit undefined is unsaid; checks:false folds its five checks first), then combined per key: booleans OR, historyLimit max, a threshold config over false, and between configs the bound that fires sooner (lower count/budget/ms, longer windowMs). A hold adds to what the engine does and never takes away what another asked for, so the result is independent of the order holds were taken — a track enabled with log:false beside a console session leaves its log alone in either order; a capture with tight thresholds beside a records-only adapter runs the checks for its own duration. Prior art: Node trace_events (union of every enabled Tracing's categories), CDP per-session domain enablement. - performance-tracks: always asks {log:false, ...options.attribution}; the install-time heuristic is gone - tests: order independence, checks while any holder wants them, explicit undefined; adapter beside a console session - size: engine scenario 28.85 -> 29.00 KB (+194 B, engine-only), noted Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> * chore(size): CSR prod cap 15.80 -> 15.85 KB after rebasing over #3586/#3555 The merge with the new next measured 15,815 B against next's 15,764: the same +51 B brotli name-assignment noise this branch has carried (minified bundles 44,649 B on both sides), now on top of upstream bytes those PRs left 36 B under the cap. No prod source changed. Co-authored-by: Cursor <[email protected]> * docs: name the Vite plugin as the owner of sourceNames.primitives Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent 43fae6e commit fd36d37

102 files changed

Lines changed: 6707 additions & 263 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@solidjs/signals": patch
3+
"solid-js": patch
4+
"@solidjs/web": patch
5+
---
6+
7+
`attribution.enable(opts)` now returns the release of the hold it takes (idempotent, like `subscribe`), and options combine across holds by the most demanding request per key (the log prints while any holder wants it, a check runs while any holder wants it at the most sensitive threshold asked for, `historyLimit` is the largest), so a hold adds to what the engine does and never takes away what another asked for — a track enabled with `log: false` beside a console session leaves its log alone, in either order — instead of every call rebuilding the options from defaults. `disable()` is the full teardown whatever holds are outstanding (the console's reset), so re-enabling to reopen a window and calling `disable()` once cannot strand a hold. `enablePerformanceTracks` releases through the token. Dev builds create a component's `console.createTask` task only for components rendered while an attribution engine is installed — the stack capture per call roughly doubled dev mount for a session with nothing enabled; the tracks enabled at bootstrap still see every component's site.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@solidjs/signals": patch
3+
"@solidjs/web": patch
4+
---
5+
6+
Attribution engine: shared-consumer foundation
7+
8+
- `attribution.enable(opts)` is a hold on the engine and returns its release (idempotent, like `subscribe`). The engine is one per page and shared by every consumer (a profiler track, an APM adapter, a diagnostics capture); it stays installed while any hold remains, and the last release uninstalls and clears everything. Options combine across holds by the most demanding request per key — the log prints while any holder wants it, a check runs while any holder wants it at the most sensitive threshold asked for, `historyLimit` is the largest — so a hold adds to what the engine does and never takes away what another asked for, whatever order the holds were taken in; releasing a hold withdraws its requests. A hold taken while already enabled opens a fresh window over the ring buffers and folds without disturbing live tracking state or other consumers' subscriptions. `disable()` is the full teardown whatever holds are outstanding (the console's and a test harness's reset) — a consumer sharing the page releases its own hold instead.
9+
- New `AttributionOptions.checks` (default `true`). `false` turns off all five cost checks — `hotRuns`, `hotTime`, `wideDeps`, `unstableMemos`, `wideWrites` — at once, so a records-only consumer pays for none of their bookkeeping. Hold/long-hold/waterfall tracking are unaffected.
10+
- `isSilentHold` and `isLongHold` are exported from `@solidjs/signals/attribution` (inert in prod), so consumers apply the engine's own hold verdicts instead of thresholds of their own.
11+
- `InteractionEvent.at` is now the browser event's own `timeStamp` when `@solidjs/web` dispatches the handler (guarded against epoch-clock stamps), so it equals `PerformanceEventTiming.startTime` for the same interaction — a direct join to INP. New `InteractionEvent.inputDelayMs` reports event creation → handler entry; `handlerMs` is now entry → return, and `settledMs` continues to measure from `at`.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@solidjs/signals": patch
3+
"solid-js": patch
4+
"@solidjs/web": patch
5+
---
6+
7+
Attribution engine: timeline records, and a `flushStart` hook
8+
9+
Five new listener-gated records on `attribution.subscribe`: `create` (a computation's creation run — the mount flame), `effect` (an effect callback, timed and joined to its compute run), `flush` (one scheduler drain: runs, creations, whether it parked a transition, the interaction it served), `flight` (an async flight from origin to landing or abandonment, with the async node's owner path) and `fallback` (a loading boundary's fallback from show to hide). None is built, logged or folded unless something is subscribed to its type, so the console/agent readers pay nothing for records only a timeline wants. `OBSERVE.subjectOf` answers for the node-bearing ones.
10+
11+
Core: a `flushStart` hook beside `flushEnd` (one drain, never nested), and `effectRunStart` now fires in observe builds like its `effectRunEnd` twin, so writes inside effect callbacks carry their `effect` origin in observe too, not only in dev. The observe core grows by 67 bytes minified; prod is byte-identical.
12+
13+
The engine's effect-frame → node map is now filled by the first write inside a callback rather than by every callback (every reader resolves it through a write's origin, and most effect callbacks never write), which removes a WeakMap write per effect callback from the enabled engine's hot path.
14+
15+
`@solidjs/web/performance-tracks` paints the new records: creation runs and effect callbacks on the `Effects`/`Memos` tracks, drains on the `Propagation` track (one wave per drain), flights and fallbacks on a new `Async` track.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@solidjs/babel-plugin": patch
3+
"@solidjs/compiler": patch
4+
"@solidjs/web": patch
5+
---
6+
7+
`sourceNames.bindings`: compiled binding effects are named by what they write. An attribute effect gets `<tag>.<attribute>` as written (`span.textContent`, `div.class:active`, `div.style:color`; a template's merged effect lists all of its bindings), a hole's insert is named for the parent it fills (`div.children`), and a spread passes its tag so the runtime labels its attribute effect `div.spread` and its children insert `div.children`. The names travel as a trailing options argument on `effect`/`insert` (`{ name }`) and a trailing string on `spread`; `@solidjs/web`'s `effect`, `insert`, and `spread` accept them and put them on the render effect nodes, where the dev and observe tiers show them in owner paths, attribution chains, and the Propagation track — a binding effect reads `span.textContent ← count` instead of `effect ← count`. Production ignores the names; output with the option off is unchanged. DOM output only; `sourceNames: true` turns it on with `components`.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@solidjs/babel-plugin": patch
3+
"@solidjs/compiler": patch
4+
"solid-js": patch
5+
"@solidjs/web": patch
6+
---
7+
8+
Rename the compilers' `componentNames` option to `sourceNames`, now `boolean | { components?: boolean }`. `sourceNames: true` (or `{ components: true }`) is what `componentNames: true` was — the tag as written in source as `createComponent`'s third argument, on DOM and SSR output. The option is now the home for every kind of source name the compilers can carry into output for the dev and observe runtimes to label the reactive graph with (binding effects and primitives follow); the object form picks kinds. `@solidjs/compiler` rejects `componentNames` as an unknown option, so a stale `@solidjs/vite-plugin` fails loudly rather than compiling without labels.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@solidjs/compiler": patch
3+
"@solidjs/signals": patch
4+
---
5+
6+
`transformSourceNames`: the pass behind the Vite plugin's `sourceNames.primitives` option (a `@solidjs/vite-plugin` option, not a compiler `transform()` option — the compiler exposes it as this standalone function). Reactive primitives (`createSignal`, `createMemo`, `createOptimistic`, `createStore`, `createOptimisticStore`, `createProjection`) resolving to a `solid-js` / `@solidjs/signals` import are named after the identifier they are declared as — array pattern, binding, property key, or class field — prefixed with the enclosing non-component function (`createCounter.value`), never overriding an explicit `name`. Plain JavaScript in and out, so it runs on `.ts`/`.js` modules too.
7+
8+
Stores honour `name`: `createStore(value, { name: "todos" })` labels its property nodes `todos.title` in attribution output instead of `store.title`; derived and optimistic stores name their property nodes alongside the projection node.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/diagnostics": patch
3+
---
4+
5+
`captureDiagnostics` and the browser bridge hold the shared attribution engine through the release `attribution.enable()` now returns, and release only their own hold at the end of a capture — a profiler track or an APM adapter enabled beside the capture is left in place (previously `disable()` tore the engine down for every consumer).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/signals": patch
3+
---
4+
5+
The `fallback` attribution record (and the feedback fold's `shows`/`flashes`) times the fallback's display, not the boundary's swap. A `<Loading>` swap is a staged write that lands with its frame (#3575: `on` follows the frame); the engine now holds the show under that transaction and stamps `at` at the end of the drain that rendered it, and a swap cleared before then — the content landed before the frame did, or the commit's own sweep cleared it ahead of any effect (the `LOADING_ON_OUTSIDE_HOLD` shape) — was never on screen and produces no record. `AttributionHooks.boundaryFallback` gains a fourth argument, the transaction the swap is staged in (`null` for a lane swap).
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@solidjs/signals": patch
3+
"@solidjs/web": patch
4+
---
5+
6+
Fold the source-name plumbing out of the production artifacts: `createStore`'s declared name is recorded in an observe-only branch of the public entry (no extra parameter on the store constructor), the web `spread` labels ride a module-level `spreadName` that `effect` and `insert` read while the spread body runs (no options argument at the call sites), and the boundary node names gate the call or set `_name` after it. The minified prod bundles are structurally identical to `next` (identifier-normalised diff empty); the observe-tier caps are ratcheted for the performance-tracks records with an audit note.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@solidjs/web": patch
3+
"solid-js": patch
4+
---
5+
6+
`@solidjs/web/performance-tracks`: Solid's records on the Chrome Performance panel
7+
8+
`enablePerformanceTracks(options?)` paints the attribution engine's records — re-runs (`Effects`/`Memos`, coloured by self time, `warning` for a provably wasted run), interactions (input delay, handler, settle by outcome), holds (`warning` for a silent hold, `error` for a long one — the engine's own verdicts), navigations (named by route) — and the web runtime's server-function `call` and `frame` records (`Server`) as custom tracks in the group `Solid`, through the panel's extensibility API. Every span is emitted retroactively from the record's own `performance.now()` stamps; labels come from the shared formatters (`formatOrigin`, `formatRerun`, `ownerPath`), so the timeline agrees with the diagnostics artifact by construction. Dev builds emit `performance.measure` entries with `detail.devtools` (why-chain tooltips, cause/deps/blocker properties; entries cleared in batches); observe builds emit `console.timeStamp` spans with a `0.05ms` floor and scrub value previews and non-button element text. Prod builds fold the module to a no-op. Options: `attribution` (the engine hold's options, `log: false` by default — asking for no console log, which quiets it only while no other holder wants it), `minMs`, `rich`, `group`, `scrub`. Returns the release of this adapter's hold — the engine's and its own.
9+
10+
`solid-js` now exports `ownerPath` (already public on `@solidjs/signals`) — the root-first owner labels of a subject — on both the client and server entries, so in-process consumers of the records (this adapter) can label a re-run by its component path without importing signals directly.

0 commit comments

Comments
 (0)