Vitest concurrent test execution and CPU contention latency
23K reputation · 23 Mar 2023, 09:32 UTC
Concurrency Pool Performance
Vitest utilizes a worker-thread pool to execute tests in parallel, typically defaulting to the number of logical CPUs available on the host system. While this improves throughput for independent test suites, high-density parallel execution can lead to resource saturation.
Resource Contention and Isolation
Under heavy concurrent loads, CPU contention may introduce latency spikes that are not present during serial execution. Because worker threads share the same Node.js process, the lack of a dynamic scaling mechanism for the pool size means the framework cannot automatically adjust to runtime load or specific resource bottlenecks.
Furthermore, managing isolation for shared resources remains a manual process, as there is no fine-grained API to isolate specific tests from the global pool's resource competition.
- How does Vitest handle worker thread prioritization when the pool is saturated?
- Is there a documented method to dynamically scale the pool size based on real-time CPU load rather than a static count?