-
-
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
Performance Issue - 50% of time spent inside statSync
#3597
Comments
Can you check roughly which files are called and if there are duplicate calls? A repo where we could dive in would also be helpful. I'm curious on how it performs on clean project. |
Yes, this is bad. We'd like to address this by building a high-performance version of resolve: #2925. |
@cpojer great to hear you are on it :-) @thymikee I have investigated further, it seems like every I created a small repo that reproduces it - it uses default jest config and no typescript, but you can still see that a single https://github.com/urish/jest-perf/blob/master/md5-stat-sync.txt p.s. jest is great, I really enjoy using it so far (it's been my second day) so thanks! |
Yeah this is definitely odd. Node's resolution algorithm is inherently slow because it goes to the filesystem a lot, but this seems excessive. We gotta replace |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Running jest with about 100 tests take around 10-14 seconds on my machine. After doing some profiling, I figured out it calls
fs.statSync()
about 150,000 times (so about 1,500 times per single test), and spends there about 6.5 seconds, which is roughly half of the run time. All these calls are initiated byjest-resolve
(which eventually uses theresolve
package).Using jest v20.0.1, jest-resolve 20.0.1.
Here are my benchmark results:
How did I perform the benchmark?
node_modules/jest-resolve/node_modules/resolve/lib/sync.js
with this instrumented version. I instrumented theisFile()
method to figure out how many times it is called and time spent inside.jest --runInBand
Also tried to disable cache, but the method was still called ~ 150,000 times.
finally, here is my jest configuration:
If needed, I would love to provide more feedback or dig into it further - but please provide me some pointers where to dig.
The text was updated successfully, but these errors were encountered: