Skip to content

@ogygia/devtools · Profiler

Page data

Where a page's data comes from, what it costs and who reads it. Data lineage per page.data key, the data river from upstream calls to islands, why each seed key ships, the document as bytes, a streamed document held open, deferred holes and their cache, and what ogygia and Kit add to a render.

On this page

A load that fetches data nobody reads costs the server its wait, and a key an island reads whole costs every visitor its bytes. The data part of a report follows each page.data key from the upstream call that produced it to the islands that read it, so both kinds of waste have a name and a line.

The usual fix is to read keys by name in an island, so seed shaping (dataShake()) can ship only those:

<script lang="ts">
  import { page } from '$app/state';

  // before: the whole object, so every key of page.data ships
  // const data = page.data;

  // after: one key by name, so only `cart` ships
  const count = $derived(
    page.data.cart?.items.length ?? 0
  );
</script>

<span>{count}</span>

Data lineage

Every page.data key on one row: the load that returns it (read from the load’s source), the bytes the seed shipped for it, the time that load spent waiting on upstream calls per render, who reads it, and a verdict.

The readers are found in the code: the route’s page and layouts, every component the profile saw that has a .svelte source on the machine, and the islands’ closures from the build. The scan walks the source with comments and strings blanked out, and recognizes data.key, data['key'], page.data.key, $page.data.key, and destructurings such as const { a, b: c } = data. A component that hands the object on whole (fn(data), { ...data }, Object.keys(page.data)) is marked as reading every key, but <Child {data} /> isn’t, because the child is scanned on its own.

The verdicts:

  • read by an island: it must ship.
  • server only, not shipped: the good case.
  • server only, but shipped: rendered into the HTML and also in the seed for no island, because the shaping couldn’t see who reads it. seed-server-only notes 2 KB or more of these.
  • nobody reads it: fetched for no one, so the load’s wait behind it is pure waste. key-unread warns, with exactly which rows of the render build only those keys and what they cost (Unused data).
  • unknown: a reader couldn’t be scanned, or an island takes the whole page. No key is called unread while any of its readers is unknown.

In the JSON it’s lineage.

Data river

Where the page’s data comes from and where it goes, as a flow in four columns: the upstream calls (with their waiting time), the load functions that made them, the page.data keys those loads return (with their bytes in the seed), and the islands that read each key. Band width is the amount, in ms on the left and bytes on the right.

A key in red is fetched and shipped for no one. A load whose source the profiler couldn’t read shows its keys as unknown, and an island that reads page.data through a helper the build couldn’t follow takes the whole seed; the note under the river says how to make the seed shrink. The keys each load returns are read from its source (return { products, flags }), the keys each island reads come from the build, and the bytes per key come from the rendered document. In the JSON it’s river.

Page seed

Every top-level page.data key in the seed, with its size and why it ships:

  • an island’s client code reads it (the build’s answer, from seed shaping);
  • an island’s props reference it (a seed reference, so the data isn’t written twice);
  • whole, because some island reads page.data without naming keys. Everything ships, and the report names that island (seed-whole).

Keys that seed shaping left out are greyed, so you can see what was trimmed, and clicking a key shows who asks for it. When the seed left the fast JSON lane for devalue, the value that forced it appears in the heading (seed-devalue).

Findings: seed-whole; seed-explainer when no island takes it whole but one key is 20 KB or more; seed-large when the seed is over 100 KB; props-large when island props total over 200 KB; and props-devalue when an island’s props needed devalue (a warning from 2 KB).

fp-unstable notes an island whose fingerprint changed between the profiler’s renders because one of its props did (a date, a random id). The router compares fingerprints to keep a live island across a navigation, and the fingerprint is part of the page’s bytes, so such an island is patched on every navigation and any cache keyed on the HTML (a CDN, postrender, an ETag) misses every time. Make the value the same for the same inputs.

Oversized island data

An island that takes page.data whole (through Object.keys(page.data), a spread, or by handing the object on) makes every key ship to the browser on every page view. The ships all page data card (seed-whole-read) points at the line in the island that does it and the bytes the seed ships. Read the keys by name instead, as above.

Document bytes

The HTML the server sent, as one strip with every byte coloured by what it is: head markup, inline styles, stylesheet links, the runtime’s bootstrap, other scripts, the page seed, the remote seed, the island props, the holes record, each island’s markup (hover for its name and size), lakes and holes, and plain markup, in the order the server wrote them. Declarative shadow DOM a design system rendered is counted wherever it sits. The legend gives the bytes and share of each kind, and clicking a kind highlights only that.

When a visit is known, hovering a segment also says when it arrived at the browser, assuming a steady download. A seed that’s a tenth of the document and sits in the middle of the body is a tenth of the download everything after it waits for. dom-large warns when the HTML makes 1,500 elements or more, and names the island that holds 30% or more of them. In the JSON it’s strip.

Streamed documents

For a page that streamed, the strip also shows when each chunk of the document left the server. The profiler requests the page as a browser navigation, so a load’s streamed promises stream during its render as they do for a visitor.

When the document paused a long time before its last part, the report names what held it open: each streamed promise by its page.data key, and when it left. Islands wake only once the whole document has arrived, so a slow streamed promise holds back every island on the page, including ones that read nothing late. html-held-open says so, with the islands that waited when a browser visited.

Holes

Each deferred hole the page rendered, named by its component and its props as written in the page (Recommendations {"forProduct":"P1"}, with the manifest id in small print). For each: the fetch schedule, whether it wakes afterwards, its maxAge, and, when hole requests landed in the window, what the render cache did (hits, misses or uncached renders) and the average time.

  • hole-cache-cold warns when a hole with a maxAge was asked for twice or more and never hit: its cache key includes the props and the session seal, so per-visitor props make every key unique.
  • hole-cache notes the hits of one that did.
  • hole-uncached notes holes with no maxAge that take 20 ms or more a render, which could take one if their content is the same for every visitor for a while.

The dashboard’s Holes on this server adds up every hole the server answered (Hole statistics).

Framework overhead

A page profile shows what ogygia’s handle added: its transform’s wall time, the islands and holes it emitted, and the bytes of every side channel (page seed, island props, remote seed, function manifest, context bridge). The ogygia-cost note gives the numbers. In the JSON it’s ogygia.

Kit’s own costs that grow with the document are named too:

  • ETag: Kit hashes the whole HTML for its ETag on a page that doesn’t stream. kit-etag notes it at 3 ms and 3% of busy time or more. A streamed page skips the hash.
  • devalue.uneval of the server load data, which Kit runs on every page as each load returns: kit-uneval notes it at 3 ms and 3% of busy time. A csr = true page puts that copy in the HTML for Kit’s client router. A csr = false page never reads it, but Kit still builds it on every request and drops it, so the fix either way is returning less from server loads. Islands take what they read from ogygia’s own seed, shaped apart from it.

In the JSON it’s kit.