-
Notifications
You must be signed in to change notification settings - Fork 1k
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 Web Test Run Initialization is Slow O(10x) Slower than it Should Be #5231
Comments
Looping in @dac09 and @callingmedic911 Related to #4569 #4360 — not necessarily duplicate but we definitely want to keep this topic linked/consolidated as much as possible. |
Thanks for working on it @MichaelrMentele! I will defer to @dac09 on how/if we can configure this. Meanwhile, would it be possible to share the difference in the benchmark with and without the sourcemap? |
Let me take a poke at it. |
Should get to it this week |
Feeling a bit blocking profiling this by #5425 |
I did toggle the source map in a generated webpack config -- I need to run several trials to see if it made a reasonable difference. |
I noted that the actual subtests take O(ms) while the net runtime takes O(10s) this implies that the bottleneck is at transpilation or loading or some other setup / initialization step. I had a vague idea that it might have to do with building source maps. However, it looks like source maps was NOT the bottleneck:
Another idea is to use It's difficult to actually profile the jest test -- other than simply using a node profiler which is awkward to actually pass down through the redwood CLI (not quite sure how to do it) I started looking at how things were cached. My understanding is that jest relies on babel directly to transpile code and doesn't use webpack for bundling at all (other than for transforming assets perhaps which we don't care about for headless jest tests anyway). A few areas that are promising:
Interesting reference for ideas: |
are there plans to use swc/jest? they could significantly increase the speed of the test itself |
Hey @MichaelrMentele - I wonder if you've had a chance to try out your project on Redwood V3? Hoping that this improves the performance for you.
Hey @finalight - thanks for the suggestion here - but I'm not super sure we would see much benefit from swc - see this issue here: swc-project/swc#1172 and in particular a comment that really resonated
We would love to move in that direction in general, but we'd have to move the custom babel plugins (see this) we use to SWC plugins (which are in Rust). Would be great to start in that direction, but its outside of my comfort zone - maybe something you would be interested in? SWC also currently has a big limitation right now (AFAIK) - the polyfill process swc-project/swc#5584 - which means internally its not something we can use to build Redwood packages right now. |
I do believe the initialization is much improved to your optimizations 🎉 🎉 @dac09 Still more startup time than I would expect. On the API side it still takes several seconds to start a test e.g.
|
Hey Michael, thanks for getting back and confirming things are better for you! I'll close this down, but know that we do have an initiative to see if we can further improve the performance of scenarios! |
Problem When running jest tests the runtime seems to be 12-14 seconds just to spin up a test and mount a component. The actual tests are fast. That implies 99% of the wall time is due to setup -- possibly because we have several chained yarn calls but most likely due to source maps (usual suspect for this).
As evidence, API tests are MUCH faster.
Resolution
We should probably add an option to ignore source maps / use an ugly version by default and then use a full fidelity one when useing a debugger launch config -- something like that.
I have a PR cooking that adds the debugging config for jest in vscode. I may be able to address this as well with a bit of advice on where to stick an option -- perhaps just as an ENV variable.
The text was updated successfully, but these errors were encountered: