@ogygia/devtools · Profiler
CPU
The raw CPU numbers every other part of a report is built from. The treemap of where the CPU went, components by self and total time with their render counts, every hot function down to the line, the flame graph and raw profile, deoptimizations, and costs no single function shows.
On this page
The last part of a report is the data everything above it aggregates. Reach for it when a slow pattern or a finding points at a component or a function and you want to see its whole picture: who calls it, how often, and which of its lines.
Two numbers appear everywhere here, and they’re easy to confuse:
- self is the time spent in a component’s or function’s own code. For a component, that’s its script and the building of its own HTML, not its children.
- total is self plus everything it calls.
In a page profile, both are added up over every run, and the per call column brings them back to one call.
CPU by self time
An interactive treemap where each box is real work, sized by its self time, so the largest box is the bottleneck. Click a box to zoom in, and use the breadcrumb to zoom out. Hover a box for its file and cost. Because it’s built from self time, structural parents like _layout and Root barely show, and only code that burns CPU takes up space.
Components
The root component of a page always has a large total and a small self, because its total contains the whole page. That’s expected.
- Sort by self (the default) to find the components that burn CPU.
- Sort by total to find the most costly subtree, when the cost is spread over many small children such as a long list of rows.
The bar on each row shows self (bright) inside total (dim), so you can see at a glance whether a component is slow itself or slow because of what it renders. Two more columns answer the next questions:
- markup / logic splits the component’s own time into Svelte writing its template (escaping, attributes, pushing markup) and its script plus the code it calls. A row that’s mostly markup has a big template, and the fix is fewer elements per instance rather than a faster script (
markup-heavy,logic-heavy). - under names the component that rendered most of it, which for a row is the owner of the
{#each}. ”ProductCard ×48under_page” tells you where the list lives, andhot-listpoints at that parent.
Click a row to open it: the full path with line and column (an open in editor link when the file is on your machine, a copy button otherwise, and on the dev server the source lines with the hot line marked), and the heaviest call stacks that rendered it, nearest caller first. The filter box narrows the rows by name or file.
A component, here, is the function Svelte compiles a .svelte file into, named after the file. A capitalised name isn’t enough, because a class in your code (IntersectionObserver, an Error subclass) uses the same case, so a name from a bundled chunk counts as a component only when its subtree reaches Svelte’s server internals. Everything else is app code.
Render counts
A component’s cost often comes from repetition rather than one heavy render. A ×N tag next to a name means it ran N times in one page render, counted in one extra render with V8’s inlining off. HeavyRow ×800 is eight hundred cheap renders, not one slow component. No tag means it ran once.
per call is the time per page render divided by N, the cost of a single call. A component can top the table on self and total and still sit near the bottom on per call: that’s the “thousand small rows” shape, and the fix is to render fewer. A component that’s high on per call is the one that’s heavy to render once. component-repeat warns at 20 or more renders of a component that holds 20% of busy time, and component-heavy when one render of it costs 20 ms or more.
Hot functions
Every function on the server, sortable by self, total or per call. It shows where the CPU went below the component level (a formatter built per row, a regex pass, a serializer), with the file, line and column. The same ×N tag flags a hot loop (escape_html ×7800) as against one slow call.
A row from a dependency names its package in a chip (devalue, @sveltejs/kit). Native built-ins (Node and V8 internals such as existsSync or the UTF-8 codecs) have no source file, so they’re labelled node core with a native location. Click a row for its full path and its three heaviest call stacks, nearest caller first: escape_html is hot in every profile, and the stack tells you which component’s loop calls it.
Hot lines. An opened row shows where inside the function the self time landed. V8 records a sample count per line, and the report turns it into “line 41: 38 ms, line 12: 4 ms”, mapped through the source map. On the dev server the source preview widens to cover those lines and shades each by its heat.
hot-function warns when one function of yours or a package’s holds 20% of busy time, or three together hold 40% with the first at 12% or more, each 5 ms or more. serialization warns when devalue or a package’s stringify takes 10% of busy time and 5 ms or more.
Flame graph and raw profile
A flame graph of the merged call tree for the whole window, and a .cpuprofile download of the raw V8 profile. Open that file in Chrome DevTools’ Performance panel or at speedscope.app to use their tools on the same data. The raw profile stays on the instance that recorded it.
Type in the search box above the graph to find a function or file. Matching bars stay highlighted while the rest dims, and the count and summed time show how much of the graph the match covers. Enter zooms to the heaviest match.
The JSON report carries the same locations and call stacks (path, column and stacks on every hot function and component), so an agent can locate a function without the UI.
Deoptimizations
V8 can record in the CPU profile why it threw a function out of optimized code: “wrong map” (objects of different shapes at one site), “not a Smi” (a number that changed kind), or a megamorphic call site. When it does, the report lists the functions deoptimized during the window with the reasons and how hot they are. A hot function that deoptimizes on every render runs slow code on every render, and the reason names the assumption to fix.
V8 reports this only for a function it gave up on inside the window, so one that re-optimized shows nothing, and the section is hidden when there’s nothing to show. deopt warns for the top three that deoptimized at least twice with 2 ms or more of self time.
Hidden costs
Costs no single hot function shows:
- Synchronous I/O inside the render (
readFileSync,execSync, a sync compression or key derivation) is listed with the app line that called it, because while it runs nothing else on the instance moves.sync-iowarns at 2 ms or more. - Promises per render come from the async hook, which counts every promise and keeps one stack in 256 for attribution. Tens of thousands per render means an allocation and a microtask each, a cost spread too thin to show as a function.
promise-stormwarns at 10,000 per render, and names the component Svelte’s async renderer repeats when that’s where they come from. - Memoization candidates are app functions called many times per render at a steady cost each, shown with the allocation per call. If the result depends only on the argument, a cache keyed on it runs the function once per distinct value. It’s a heuristic based on counts and cost, and the report says so (
memo-candidate). - Leftover timers: a render that starts an interval or schedules a timer still pending after the response went out (
render-leftover).
The usual fix for sync I/O is to do it once at start-up, or asynchronously: