Repository navigation
Conversation
A non-isolated worker asked the main process on every run request for the warm-modules snapshot and for every resolution again, including the `vi.mock` paths of setup files that run before each test file. Both answers are kept for the worker's life; watch mode and a request that invalidates files start over.
|
Hello @vjeux. Thank you for taking the time to contribute! Unfortunately, the team accepts pull requests only from maintainers, from anyone who contributed before, from approved contributors, or for issues with the If there is no issue for this change yet, please open one to discuss it with the team first. Your changes are not lost: a maintainer can reopen this pull request if the team decides to go forward with it. See our pull request policy for more context. |
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thanks for the PR. I ran benchmark on vitest-dev/benchmarks#2. Caching |
Prepared by @vjeux's coding agent at his request; he asked for this to be sent and follows up here himself. cc @cpojer
A worker with
isolate: falseasks the main process twice per run request for things it already knows: thefetchWarmModulessnapshot (once per request, so once per file whenmaxWorkers > 1), and everyresolve, including thevi.mockpaths of the setup files that run again before each test file. With many workers, each round-trip waits behind the others' calls on the main thread.Repro with counts and timings: https://github.com/vjeux/vitest-warm-rpc-repro. On vitest 5.0.5 with 32 workers, 2,000 test files over a 3,000-module tree and 6 setup files: 16.8 s stock, ~12.6 s with either answer kept, 6.3 s with both. A 6,600-file suite went from 96 s to 58 s with the same two changes applied as local shims.
This keeps both answers for the worker's life: the snapshot is asked once per worker, and a
(specifier, importer, environment)is resolved once (a rejected resolution is asked again). Watch mode, and a run request that invalidates files, start over.The test runs three files on two non-isolated workers and reads the worker's rpc calls through a custom runner: before this change the worker that ran two files asked the snapshot twice and repeated two resolutions; after it, once and none.