Repository navigation
feat: print performance hints after the run (experimental.diagnostics) - #10821
Merged
Merged
Conversation
sheremet-va
force-pushed
the
feat/duration-breakdown
branch
from
July 23, 2026 16:08
cfcf684 to
4b54a1a
Compare
sheremet-va
force-pushed
the
feat/perf-hints
branch
from
July 23, 2026 16:09
487a703 to
5971d13
Compare
sheremet-va
force-pushed
the
feat/perf-hints
branch
from
July 23, 2026 16:09
5971d13 to
fd3342a
Compare
…at/perf-hints # Conflicts: # docs/guide/improving-performance.md # packages/vitest/src/node/environments/fetchModule.ts # packages/vitest/src/node/state.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #10710 (part 2 of 3). Stacked on #10820 (duration breakdown percentages);
vitest doctorfollows.When the collected timings show a config change would significantly speed up the run, the summary is followed by a hint (at most one of the isolate family per run, the most specific one), gated behind
experimental.diagnostics: boolean | { isolate?, environment?, import?, transform? }.Isolate hint — the pool now tracks how long each worker start takes (spawn + bundle load + environment setup, summed as
state.startupTime/state.workersSpawned); whenisolate: truespends a significant share of the run spawning a fresh worker per test file, the summary estimates whatisolate: falsewould save. Reused workers also keep evaluated modules alive, so the estimate includes the module evaluations later files skip — per-module evaluation times exist only whenexperimental.importDurationsis collected, so without it the hint reports the spawn saving alone as a lower bound ("at least ~12.5s faster").Environment hint — for DOM suites (≥2s and ≥25% of a project's tracked time spent re-creating jsdom/happy-dom per file):
Import hint — import-dominated suites previously got no hint at all. Barrel-style imports re-evaluate the same module graph for every isolated test file; the server already records how many times it served each module (
state.metadata[project].duration), so the hint measures the duplication exactly — suites whose files import mostly disjoint graphs stay quiet, because reusing workers wouldn't reduce their import work. On an 800-module barrel fixture (20 test files importing a few symbols each through the root index):(measured:
isolate: falsetakes that fixture from 2.05s to 1.25s)Transform hint — when transforms dominate instead (≥2s and ≥25% of tracked time) and nothing persists them, the hint points at the fs module cache; it only speaks up when the import hint didn't (e.g.
isolatewas set explicitly), so the two disclose progressively. On CI the cache directory is discarded with the runner unless explicitly persisted, so the hint adds a line saying exactly that:transformStarted/transformFinishedtake the project name (derived inModuleFetcherfrom its config), so per-project times are busy-window measurements, not summed per-fetch wall times.configDefaultsis merged into the options (captureProvidedOptionsinresolveTestConfig, from the raw options andviteConfig.test) — computing it later sees defaults as user values.--merge-reportsruns (blobs replay past durations; no environments were created by the merge process).Docs:
experimental.diagnosticsinconfig/experimental.md;improving-performance.mdgained "Test Environments" (the trade-off table the environment hint links to) and the hint pointer in "Profile First".