-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jest is 3x slower on all windows machines (Windows 10 and lower) #7631
Comments
Related: #6783 Is it slow starting up, or in watch mode as well? If just during startup, you can try to install |
When its going through the tests it seems fine from there on out (EDIT: Actually it is slower when running tests as well. It goes through one by one at the speed of 0.5 secs while the norm feels like 0.05 I will try watchman and get back to you |
If you could profile using e.g. |
The delay is still slow even with watchman installed. Screenshot of the first 1.7 seconds:Screenshot of 1.8 secs to 2.7 secsA .json file and a .heapsnapshot file saved from the profile tab in ndb after recording: |
@pfftdammitchris what is your [exact] usecase where you noticed the slow? |
It is slow for both single and multiple files, with or without watch mode. Pretty much every time it runs any test there is a 3+ second delay on initializing the tests, and it is slow running the tests one by one by 0.3 or 0.4 or 0.5 seconds each while other test runners like mocha/chai would usually just run each as if it feels like 0.05 seconds each. I use jest in codesandbox and they seem to run jest instantly on initialization/running tests, I watched my coworkers run jest on their mac machines and they run it instantly like normally. It's just windows machines as far as I know. I use a windows machine at work and jest is having the slow problem there, and I also use a windows machine at home and the problem continues here. I used --runInBand but it seemed to have slightly slowed down the unit tests even further by an additional 0.2 seconds each, based on feeling. |
Clarification
=> did you try with v24? from v23 to v24, You 'll see a good improvement for this scenario ONLY:
2. I can consider this issue as: speed problem for jest [Mac vs Windows] for ALL problematic scenarios. |
Hello all ! |
We have a suite of 144 tests files with 1302 tests that take 1 minute and 43 seconds to run on a Windows 10 build 15063 machine, Core i7 with 16GB , and they takes 28 seconds on a MAC OS Mojave with 32GB. Our development team is split evenly between Windows and Mac and the numbers are very repeatable. |
Here's a simple test -
I put it in codesandbox and it runs pretty much instantly - https://codesandbox.io/s/4q8l0q52lw on my Windows machine though it takes 4-5 seconds -
The test itself took 62ms, but the rest of the test harness took 4 seconds. Re-running the test by hitting Enter it takes the same amount of time. My settings -
I tried it with the WSL Ubuntu and got the same results (4-5 secs) - those settings -
I'm just getting started with Jest so have pretty simple tests, and they can take 15-20 seconds to run. I'd love to have them running quickly - I tend to lose my train of thought otherwise! |
@bburns read above issue @kensherman |
I'm on a brand new MacBook Pro. As I have students on both MacOS and Windows 10, I decided to add two more partitions to my drive; one for Windows 10 and one for shared storage using Tuxera NTFS. I ran into this speed issue today preparing a JavaScript lesson that incorporates unit tests. I'm actually running Jest from MacOS but the code and tests are located on the shared NTFS partition. Even with all suites marked as 8 suites I swapped |
Basically you didn't read my last post. You wanted to promote |
@nasreddineskandrani i am trying out jest@24.8.0 but i can still see extremely slow execution when running with watch mode any help would be much appreciated. |
@pachumon the fix is not present in 24.8.0 as far as i understood you need to set one dependency of jest to a specific version to remove the performance issue (theoretically) the fix will be by default present in jest 25 => read here to know how a dev find out this #7963 (comment) to set the dependency (micromatch) to the version where the fix was done => you can check here i did an example in a little project Add to your
Hope this helps! and waiting for feedback |
My test run time has also ballooned from ~2.5 minutes on 23.6.0 to ~15 minutes on 24.7.1 and 24.8.0. Our CI server is running windows and has seen a similarly large increase in build time with this upgrade. I've tried the micromatch dependency resolution override as mentioned above by @nasreddineskandrani to no avail. Please let me know if there's anything I can do to assist with diagnosing this. |
@TomMahle this is a super bad newz :( (the regression we are talking about on top was in 23.6 already) |
Thanks for the suggestion about I did find out one funky thing, though, which might help in diagnosing this problem. I have the ability to run jest either on my native windows system, in a docker container with the main app directory mounted from my windows filesystem. Running in non-watch mode seems to have nearly identical behavior in both systems, which maybe suggests, as @thebearingedge implied, that the core problem has something to do with the NTFS filesystem, since my docker container is ultimately running everything except the filesystem in a linux VM. However, on watch mode, things are slightly different: native windows always works slowly as expected, but the docker container only runs tests slowly on the first run. Once I tell it to run any test suite for the second time (e.g. by pressing p and entering a pattern), it runs the tests in well under one second (doing the same in native windows takes 3-4 seconds). The only downside of using docker is that the file change events don't seem to propagate from my windows volume to docker, so I have to manually press Enter to re-run the test rather than having jest do it automatically, but I guess that's not relevant to the issue at hand. |
@nasreddineskandrani. Unfortunately my project is private. If there's any smaller code samples (the jest config?) Or statistics I could provide I'm happy to do that, though. All the tests seem to be dramatically slower (only on windows) so I don't think it has to do with the specific tests. |
I am finishing a docker stuff i am doing for my personnal websites -> after (in a week) i'll come back on this. @TomMahle
|
I thought enough attention had been given to micromatch's maintainers so that this must've been ironed out already. Running(thus writing) jest tests on windows is a very unpleasant experience at the moment. |
I've moved to mocha/chai since then but i'm surprised this issue is still being worked on.
I tried with both versions at that time of the post. I just created a new project with one test with simple array push tests and it took more than 10 seconds from start to completion. The project is using react/typescript but the test file is not a react component file but a normal file like a .js. Gif below for visual reference if it makes it better to visualize what the issue might be: I noticed that the first time I run the test it shows that the test is estimated to be 9 seconds. Once it completes, it randomly retries the tests a second time to completion. When I took that gif picture above (which was the second time this time), the time estimated cut down a little and it didn't perform a second retry. Not sure if that is the expected jest behavior. Here is a gif of me running micromatch 4 with yarn in a separate project: Using windows 10 and my computer specs are: |
Let me share my profiling here.
Steps:
CPU Profile: Is it expected that 15 seconds are spent only with requring modules for single trivial React component and test? Can someone with more experience on CPU profiling take a look? |
112 tests 85 tests |
Kepro these results are with micromatch 4? I prefer direct chat than having 1 millions message here it's really becoming a hell to follow cross all issues that are related to the same topic. |
Gitter is blocked over my company VPN - if you lovely people could post any meaningful updates here that would be amazing <3 |
you can still connect at home to do some open source :P and check it |
@nasreddineskandrani You got me. I've ordered a new macbook so will be out of open-source action until it arrives. I refuse to actually work on my crappy Windows box in my spare time :D It seems like the issue has moved in to the node/C++ realm, which is a little (extremely) outside my comfort zone - but I will do some digging! |
Hi any news on this? As a workaround you can use --runInBand if you start multiple tests. It will still took long to start the first test but the next tests will be fast. My project took 21.803s for executing all tests. |
so, we all know that issue is stupid NTFS :D |
I have to disagree even if I know you tried to be funny. No other runners suffer from this issue. So even if the issue would come from NTFS behavior it's still a Jest bug. That being said, it might be due to difference in file handles. If Jest holds on to file handles too long it would slow down execution a lot. |
Since 2019 still we don't have fix for this :( |
So help fix it, this is an open source project. If you can't contribute code, help adding more details about the root causes. |
Well i already added it up there. |
Can't figure out how to do this in CRA without ejecting. |
Same for Vue CLI here. |
Any solutions for WSL for super slow runtimes? Tried installing globally, didn't improve it |
Temporary workaround for WSL2 Users: Install jest globally too (in addition to installing it as a dev dependency) and then use its binary's absolute path in the |
tried the npm global install and it didn't improve my issue. |
It's the same slowness for me after upgrading to Windows 11. |
Confirmed: using the same windows i7 laptop got the test running 2.5x to 3.5x faster in one of my contracts project with WSL2 For Windows: use this video to setup wsl2 in vscode. You can also use wsl2 command line directly Important: clone your project in your ubuntu folder (not /mnt) do not keep it in windows partition* and resetup node git in wsl2 vscode ... |
Just mentioning that this will indeed improve test runner performance with WSL when cloning into home folder, but it's not as fast as on native Linux (installed on bare metal, no VM or anything like that) and probably Mac. I ended up switching from Windows 10 to Linux in my client project. If that's allowed in your project, I highly recommend, besides Linux is much faster in most cases and every day usage compared to Windows. |
has anyone tried to migrate to vitest and had much faster tests on windows then? EDIT: Well I have just tried it and it's super fast! And it even has nice vscode plugin. I was struggling with jest for 2 days. But vitest looks like a good solution for my troubles. Migration was easy, as it's reusing the jest API. I only had to create a ridiculously small config file and run it. |
moving everything completely to linux partition sped things up 100x times at least. Cheers for the tip! |
Still a problem |
Is there an answer for actual Windows usage here? I'm not interested in using Linux or a Linux VM. Does anyone know the underlying issue here? Is this a problem with Node's use of filesystem APIs or is it Jest itself doing something wrong? |
@Southclaws issue is slow NTFS so Windows is the issue |
No it is not. If this was the case then all test runners would be as slow. And gazillion other apps. But they are not. But you are partly right: it's a combination of how NTFS works and what Jest wants to do. But saying NTFS is slow is just being ignorant and directs the conversation to wrong direction which isn't in any way productive. |
Yeah I'm not convinced it's "jUsT a WiNdOwS iSsUe" and I've not really seen compelling evidence to back up the whole NTFS claims over the years, unless there are some deep dives I can go read that actually dig into the technical details. I've not had issues with any other language or high-throughput applications I've worked on so it seems to be something specific to Jest - perhaps it's doing more I/O operations than it needs to?
100%, I'm interested in tooling that works for everyone, not just some people's favourite computers. One thing I did check was the 8dot3name status on this system was enabled so I've disabled that which supposedly speeds things up, it seems to have had a positive effect so far. |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
Still active and needs research |
Not sure if related to any of the problems mentioned, from my team's experience: we've seen huge difference in performance on running the tests on CI runners:' m5a.4xlarge (AMD) vs m6a.4xlarge (also AMD), like 2x/3x longer on m5a and much more flaky, they're both 16 virtual cores and not that far away in terms of cpu 🤷♂ |
🐛 Bug Report
Jest is slow on windows machines.
To Reproduce
Anyone with a windows desktop machine.
Expected behavior
It should be lightning fast.
Run
npx envinfo --preset jest
Paste the results here:
I've done a ton of reading around and it seems like 100% of all windows users are being affected by delaying in running tests with jest, while it is blazingly fast for all mac users.
Has there been any research or attempts to find what is causing this? Currently I'm copy and pasting all of my components and unit testing them in codesandbox, (It instantly runs tests blazingly fast) then copy and pasting them back into my project, which isn't the most ideal way to do it but I love the API that jest offers.
The text was updated successfully, but these errors were encountered: