Re-run test in v23 is slower than v22 on Windows
💥 Regression Report
Re-run test in version 23 is significantly slower than version 22 on Windows
Last working version
Worked up to version: 22.4.4
Stopped working in version: 23.0.0
To Reproduce
repo: testjest22 repo: testjest23
These two repos only contains a test file jest.test.js and install different jest version.
test('foo', () => {
expect('foo').toBe('foo')
})
run yarn test --watchAll --env=node
then, press Enter to trigger a test run
In v22, it takes about 0.05s, but over 2s in v23
When editing test file to trigger re-run,
v22 can finish in 0.5s but v23 usually takes close to 3s
Run npx envinfo --preset jest
System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz
Binaries:
Yarn: 1.7.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
Update: It is an issue only on Windows, test it on Linux, just a little bit slower but acceptable.
Anyone would like to help finding which commit might be responsible for the slowdown?
yes, I experienced this as well. Also console.log messages are not showing up consistently compared to v22. I suspect it is being overwritten by jest messages.
I can confirm the problem.. on this test suite,, though not as pronounced.
The problem seems to be down to startup ;- for me, on a large test suite I didn't notice a significant change.
Jest 23 - 1.6s (real 3.7s), 1.25s (real 3.074s), 1.24s (real 3.06s) Jest 22 - 1.1s (real 3.0s), 0.52s (real 2.12s), 0.52s (real 2.12s)
I wasn't running in watch mode. with watch all after already warmed up
jest 23 - 0.5s pre-warmed first run, 0.8 after changing file jest 22 - 1.8s pre-warmed first run, 2.3s after changing file
I did a bisect and it looks like the problem was introduced with a deps upgrade in https://github.com/facebook/jest/commit/d1ce3cd0135b5a8b64f84998fd5f36be4afb2bef. The upgrade to micromatch was reverted later but it's still slow in master so it must be something else.
Are you sure? Besides micromatch, the only deps that changed were dev ones
Actually I think there might be something else involved too. The deps upgrade definitely increased the watch mode runs on file change from ~0.46s to ~1-1.1s. However, reverting micromatch (e930c705d6d1b77f762fa65ad24eaf80d68c7b3f) didn't resolve the problem. In fact it's actually slower than when micromatch was upgraded. I think some other change in between is contributing to the problem. I'll do another bisect to see if I can find it.
Ah, it looks like a significant contributor is 664681a57e4e034bfb80bd34218625cd0cceed08. I don't think it's the only issue but it certainly hurts this particular repo, as it only has one test. There's overhead spinning up a worker. Reverting that commit on master brings it down from 2.5-3.3s to 0.7-0.8s. That's still more than 0.46s, but it's better. Not sure what the impact would be on a larger battery of tests.
I tested on a larger (but by no means large) codebase and found that a6aa304d505c0688456a323f587a81e6f4363479 decreased performance measurably on my machine as well.
- Watch: 21.2s
- Non-watch: 12.5s
For reference:
22.4.2
- Watch: 17.5s
- Non-watch: 11.2s
master
- Watch: 24.4s
- Non-watch: 14.6s
I haven't been able to determine what else is slowing down test runs between 22.4.2 and master. Performance goes up and down between the two revisions so it's hard to really find a cause. I don't think it's any single commit, but rather the cumulative effect of multiple changes.
Can confirm 23 is much slower than 22 on re-running tests on Windows using Typescript and ts-jest.
23.4.1 adds ~3 seconds to a 3ms noop test
22.4.4 runs test re-runs as fast as expected
I confirm --watch problems on Windows using Typescript and ts-jest:
v23: >13s
v22: >8s
v21: >2s
test('------1------', () => {
expect(1).toEqual(1);
});
It is actual for MacOS too "jest 23.4.2" is slower than "jest 22.1.4" at most 80%
Is there any update with this? It seems like the slowness is also on Linux as well. My team has been experiencing the same issues with slowness to the point where a dev is looking into porting back to mocha? Would love to not have to switch from Jest :heart: if this is something that may be addressed in a later release.
This may help https://github.com/facebook/jest/pull/6925.
I tested 23.6.0 and run times are identical to 23.5.0.
We noticed a significant slow down (~12s to ~19s) in our test suite when upgrading from jest 22.4.4 to 23.5.0. The latest version as of this post, 23.6.0, did not improve the speed.
We're using node 8.2, yarn 1.9.4, and macOS Sierra 10.12.6.
There are 371 test suites and 1790 tests. While doing a git bisect to identify when the slowdown happened, I noted how long jest took to finish. The following table lists the median duration of the runs for each jest version.
| jest version | median duration in seconds |
|---|---|
| 23.6.0 | 19.1 |
| 23.5.0 | 18.7 |
| 22.4.4 | 12.2 |
Edit: The fast version of jest was 22.4.4.
It would be awesome if someone would take the time to bisect Jest itself; building it and test against a repo showing the slowdown. I don't have Windows readily available (would have to be through virtualbox, which I think might give misleading results)
@SimenB The slowdown happens on OS X too.
This issue is for windows, if you can put together a reproduction that reproduces on more OS-es that would be great as a separate issue! 🙂
It would be awesome if someone would take the time to bisect Jest itself; building it and test against a repo showing the slowdown.
I did that earlier with a private repo and attributed most of the performance impact to a6aa304. I have not bisected with a public repo other than the one in the issue description, which was also impacted by 664681a, as the overhead of spinning up a worker is significantly longer than the time to run the tests.