You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 886850b
Browse filesBrowse the repository at this point in the historyBrowse files
authored
feat(signals): GRAPH_GROWTH — the live graph counted at navigation settle (#3619)
* feat(signals): GRAPH_GROWTH — the live graph counted at each navigation's settle
The leak class a heap snapshot finds, as a finding. At every navigation's
settle the engine counts the live graph and emits a `graph` record
(GraphEvent: at, owners, roots, route, navigation); when the count at the
same route has climbed on `visits` consecutive visits (3) to `ratio`× the
first (1.25), GRAPH_GROWTH names the route with the counts. The count is
the whole graph's, so the first route to complete its climb reports and
names the others seen; the verdict then resets for the graph.
The plan assumed the core kept node counters; it does not — the fan-in/out
numbers are per-walk locals. Rather than add a live counter (an increment
at every creation and disposal, on the idle observe path), the observe
core registers top-level roots weakly — `createOwner` with no parent adds
a WeakRef to a Set reaped by a FinalizationRegistry, disposal removes it —
and the engine walks the owner tree from them: nothing per node, a walk at
navigation cadence, only while the check is on or something listens.
`graphSize()` is exported from solid-js/attribution for a consumer's own
schedule. Prod is byte-identical (the bodies fold to a return).
Size: tier +165 B (the registry; cap 17.5 -> 17.60 KB), engine +632 B
(cap 29.00 -> 29.65 KB). Idle tripwire unchanged.
Co-Authored-By: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
* feat(signals): GRAPH_GROWTH measures the reactive graph, not only the owner tree
The owner walk counted components and owned computations and missed the
leak it named in its own message: an effect created with no owner, held
alive only by the sources it reads. The walk now continues from the owner
tree into the reactive graph — each computation's dependency links
(`edges`) and the `signals` and computations they reach, and each reached
node's subscriber list, which is where an ownerless computation is met.
Iterative with a worklist; a subscriber chain can be thousands deep.
`GraphSize` is `{ roots, owners, computations, signals, edges }`;
`GraphEvent` carries it. GRAPH_GROWTH judges every series and the message
names the shape by which one climbed — owners is an undisposed root,
computations with owners flat is an ownerless effect, edges alone is a
subscription per visit to something long-lived. A node the app's own graph
never reaches is not counted, and the RFC says so.
Measured: 10k owners (9k computations, 9k edges) walk in 0.6ms, 50k in
3.6ms; the Set of met nodes is most of it. Engine cap 29.65 -> 29.95 KB;
tier 17.60 -> 17.65 KB (drift; the core is unchanged since the registry).
Co-Authored-By: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
* chore(size): GRAPH_GROWTH moves the tier cap to 17.65 KB and the engine cap to 30.00 KB (rebased)
Co-Authored-By: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
* chore(size): re-measure GRAPH_GROWTH at landing; engine cap 29.80 -> 30.70 KB
30,649 B against next's 29,725 on the rebased tree (+924 B); tier 17,618
under the 17.65 KB cap.
Co-authored-by: Claude via Cursor <[email protected]>
---------
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Claude via Cursor <[email protected]>
`GRAPH_GROWTH` (warn, perf): the live reactive graph — owners, computations, signals, edges — measured at each route's settle climbed on consecutive visits, and which measure climbed names the leak. The observe core registers top-level roots weakly; the engine walks the owner tree and the reactive graph it reaches at navigation settle (never a per-node counter), emits a `graph` attribution record (`GraphEvent`, `GraphSize`), and exports `graphSize()` from `solid-js/attribution`. `graphGrowth: { visits, ratio } | false` configures the check.
Copy file name to clipboardExpand all lines: documentation/solid-2.0/08-dev-diagnostics.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -426,6 +426,14 @@ One recompute pass tracked an unusually large number of distinct sources (same t
426
426
427
427
Related: `WIDE_SCOPE_DEPS` (below) fires at a much lower threshold, but only while the attribution engine is enabled — it names the offending sources. `HUGE_FAN_IN` is the always-on backstop for the pathological case.
428
428
429
+
#### `GRAPH_GROWTH`
430
+
431
+
**Message:** "the live graph grew on 3 consecutive visits to `/orders`: computations 900 → 903 → 906; edges 900 → 903 → 906 (2 roots), across visits to `/orders`, `/`. Each visit left something behind that the next did not reclaim — the shape says an effect or memo created with no owner (a module-level or callback `createEffect`) that only its sources keep alive. Dispose what a visit creates (`onCleanup`, or return the disposer from `onSettled`) and own it under the route's component so leaving the route tears it down."
432
+
433
+
Attribution-engine only; the leak class a heap snapshot finds, as a finding. At every navigation's settle (`withOrigin({ kind: "navigation" })`) the engine measures the live graph with a **walk**, never a per-node counter: the owner tree from the registered top-level roots (`owners`: roots, component owners, owned computations), then everything reachable from it through the reactive graph — each computation's dependency links (`edges`) and the `signals` and computations they reach, and each reached node's subscriber list, which is how a computation **no owner holds** (a `createEffect` with no owner, kept alive only by the sources it reads) is found and counted in `computations`. It emits a `graph` record (`GraphEvent`: the `GraphSize` fields plus `at`, `route`, `navigation`) for a `subscribe("graph", …)` listener, and keeps the size at each settle of the same route. When any series — `owners`, `computations`, `signals`, `edges` — has climbed on `graphGrowth.visits` consecutive visits (default 3) to `ratio` or more of the first (default 1.25), the route reports, and _which_ series climbed names the leak: `owners` is an undisposed root or a Portal per visit; `computations` with `owners` flat is an ownerless effect; `edges` alone is a subscription per visit to something long-lived. The count is the whole graph's, so a leak shows at every route's settle: the first route to complete its climb reports and `data.routes` names the others seen; the verdict then resets. `data`: `route`, `grew` (the series that climbed), `history` (the `GraphSize` at each settle, oldest first), `roots`, `routes`, `interaction`. No subject.
434
+
435
+
The observe core's part is the root registry: `createOwner` with no parent registers the root (weakly — a `WeakRef`, reaped by a `FinalizationRegistry` — so an undisposed root nothing references still collects; one a subscription keeps alive is exactly what the walk counts), and its disposal unregisters it. One Set write per top-level root, nothing per node; the walk runs at navigation cadence, only when the check is on or something listens for `graph` records. Measured on the observe artifacts (components of 1 signal, 3 memos, 6 effects): 10k owners walk in 0.6ms, 50k in 3.6ms — a `Set` for the reached nodes is most of it. A reactive node the app's own graph never reaches (an ownerless effect over a signal nothing owned reads) is not counted. `graphSize()` is exported from `solid-js/attribution` for a consumer that wants the measure on its own schedule. `false` disables.
Perf-kind warnings emitted by the **attribution engine** — they only fire while the attribution engine (`solid-js/attribution`) is enabled (see the next section). Defaults:
@@ -856,6 +864,7 @@ The runtime derives a request's trace itself in every tier — the W3C `tracepar
856
864
|`FLUSH_IN_EFFECT_CALLBACK`| warn | lifecycle |`flush()` from an effect callback (no-op; the drain is already running) |
857
865
|`HUGE_FAN_OUT`| warn | graph | One change reached 2000 live subscribers (always on) |
|`GRAPH_GROWTH`| warn | perf | The live owner count at the same route's settle climbed on 3 consecutive visits to 1.25× — something each visit leaves behind (attribution enabled) |
859
868
|`HOT_SCOPE_RERUNS`| warn | perf | 120+ re-runs of one scope in 1s (attribution enabled) |
860
869
|`HOT_SCOPE_FANOUT`| warn | perf | 5+/50+/500+ scopes hot from one root cause (attribution enabled) |
861
870
|`HOT_SCOPE_TIME`| warn | perf | 8ms+ self-time in one scope in 1s (attribution enabled) |
0 commit comments