You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/benchmarking/compiler-profiling.md

1.6 KiB

Compiler CPU profiling

Run the full test suite with V8 CPU profiling enabled in every Vitest worker:

pnpm profile:compiler

Arguments are passed to pnpm test, so a smaller smoke run can target a suite:

pnpm profile:compiler snapshot

Each run is stored under benchmarking/.profiles/compiler-tests/<timestamp>. Set SVELTE_PROFILE_NAME to give a run a stable name; existing runs are never overwritten. benchmarking/.profiles/compiler-tests/latest.txt contains the latest successful run name.

Each run contains:

  • raw/*.cpuprofile: the original V8 profile from every Vitest worker
  • flamegraph.speedscope.json: compiler-active stacks merged for use in Speedscope
  • summary.md: ranked self/inclusive hotspots and files
  • summary.json: the same measurements for further analysis
  • manifest.json: the command, revision, timestamps, and test result

The merged profile includes downstream callees while a compiler source frame is on the stack. This captures parser, walker, and printer dependencies without including unrelated test runtime. V8 reports garbage collection outside the originating stack, so the summary reports process-wide GC separately rather than attributing it to the compiler.

The default sampling interval is 5 ms. It can be changed for shorter, focused runs:

SVELTE_CPU_PROF_INTERVAL=1000 pnpm profile:compiler snapshot

Existing raw profiles can be analyzed again without rerunning tests:

node benchmarking/analyze-compiler-profile.js benchmarking/.profiles/compiler-tests/<run>