vitest: Vitest 3 runs 3 times slower than Vitest 2
Describe the bug
My unit tests took ~12 seconds on the latest v2 of Vitest, then switching to v3, they now take ~36.5 seconds to run locally. Importantly they went from 3.2 seconds to 3.0 seconds on CI (GHA).
My assumption is this local slowdown is caused by the live update “Duration” timer constantly refreshing the terminal multiple times a second. From my experience in the past, these constant update severely slow down running tasks. On Windows for example, minimizing a command prompt will cause it to run faster as it stops performing repaints. On Ubuntu, minimizing the terminal actually caused it to go much slower (~65 seconds). I assume minimized windows on Ubuntu are given less resources?
I looked around but couldn’t find any way to turn the “Duration” field off when running tests. This would be a good option even if it is unrelated to performance because I just don’t like it. It’s annoying and distracting to have something constantly flashing. I don’t care how long it’s been running, I care how long it took at the end (and only very rarely).
Reproduction
This is the library repo I’m working on where I noticed this:
System Info
12 second details:
System:
OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
CPU: (2) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
Memory: 4.84 GB / 7.71 GB
Container: Yes
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 23.6.0 - ~/.volta/tools/image/node/23.6.0/bin/node
npm: 11.0.0 - ~/.volta/tools/image/npm/11.0.0/bin/npm
npmPackages:
@vitejs/plugin-vue: ^5.2.1 => 5.2.1
@vitest/coverage-v8: ^2.1.8 => 2.1.8
vitest: ^2.1.8 => 2.1.8
36 second details:
System:
OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
CPU: (2) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
Memory: 4.82 GB / 7.71 GB
Container: Yes
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 23.6.0 - ~/.volta/tools/image/node/23.6.0/bin/node
npm: 11.0.0 - ~/.volta/tools/image/npm/11.0.0/bin/npm
npmPackages:
@vitejs/plugin-vue: ^5.2.1 => 5.2.1
@vitest/coverage-v8: ^3.0.2 => 3.0.2
vitest: ^3.0.2 => 3.0.2
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 16 (13 by maintainers)
You can see the redraws/repaints being done by the terminal/command prompt. Because the duration is updating so frequently, it is causing flashing to occur more often. My assumption is it is also related to the performance issue, as I’ve seen this same outcome from other CLI’s in the past. Also turning summary off seems to confirm this suspicion.
I absolutely want a
summary: { duration: false }option. I think there may even be a case for making that the default.@boldurean cool, then you had the same issue as me. There is a PR up to resolve it (https://github.com/vitest-dev/vitest/pull/7291), so you won’t need to turn off the summary after that is merged/released.
Yip that improves the speed. Thank you!
Trying with
npm i https://pkg.pr.new/vitest@7291.Setting
{ summary: false }with it gives:So about the same. So this PR removes the difference in performance between enabling/disabling Summary.
Switching back to
2.x.x:Switching back to
3.0.2:So this seems fixed to me!
There’s preview release that you can try now:
https://github.com/vitest-dev/vitest/pull/7291#issuecomment-2600842425
Confirmed, applying the
summary: falseremoves the “Duration” and also fixes the performance issue. @boldurean try it out, you may be able to upgrade after all.Though honestly, I’d rather have the summary on, but the duration off. Since the duration is what makes the performance slow, and also is annoying to look at. Basically “exactly like it was in v2”.
By annoying and distracting flashing, do you mean the summary? Use following to disable it: https://vitest.dev/guide/reporters.html#built-in-reporters
No flashing at all on Windows. On the Ubuntu VM, there is some, but it’s very minor and not really any different from any other CLI usage.
In Vitest 2 we used to repaint whole terminal window every 16ms. Now the repainting is limited to only the summary. We’ve actually seen improved reporting performance now.
What terminal is that? I have some improvement ideas but before that I need to be able to reproduce this issue. Your reproduction works fine on Github Codespaces, running on Ubuntu. I would expect that to match your reported environment
Linux 6.8 Ubuntu 24.04.1 LTS. 🤔@fmal please create new issues for reports that are unrelated to this one. Let’s keep this one focusing on Vitest 3 performance only, as the title says.