-
Notifications
You must be signed in to change notification settings - Fork 12
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
How can I help to get this faster? #20
Comments
Hey @Andarist, To be honest I just threw this together to see if it could be done, and didn't spend a lot of time trying to optimize it. I've since moved back to running tsc separately to Jest so don't really dogfeed this package. I'd be interested to see if the tactics used by that webpack plugin will work in the Jest ecosystem. |
I think it's either this or creating a language service as If you have any insights about jest runners that would be very helpful as well. From my quick tests I've noticed that, for example, |
Would be awesome to make it a viable option, yeah! 👏 Runners are generally a better fit for files that a processed in isolation (like tests, linting, and babel's transpilation) rather than something that needs the whole thing in memory and operate on it in one go. But transfomers are instantiated for each run (config might change, which invalidates caches), but as long as |
Right, I've noticed that 😅 Is there any other API that would be better suited for this? Or maybe it could be considered to introduce one? Fork TS Checker Webpack Plugin works by spawning a separate process for type checking and using RPC to communicate between the main process (webpack-aware) and the type checking one. So to reuse this technique it would be great if jest could provide a "runId" or something, so we could only call the type checking service once for a particular run.
From what I know (but I might be wrong) this just transpiles stuff (hence the name), it doesnt actually do any type checking.
It's probably not needed at all to use worker_threads in this scenario - because as mentioned above, ideally we should just be able to request diagnostics once for the whole project, so splitting this into threads doesnt make much sense.
Thanks for this info! Wouldnt it be possible to skip that when you know that a config hasnt changed? Or is it just considered to be so low-cost that it's not worth optimizing this? |
We have a
Possibly! But the whole runtime is instantiated for every single test file for every run (which further instantiates the transformers), so I think any change would be rather large. Feel free to explore it though! There's bound to be some low-hanging fruit performance wise here anyways |
Possibly yes - although, when thinking about it more, the ideal solution would be to bail out of worker pool for this use case. Is it possible on per runner basis? Using an ID to emulate a single run would certainly work, but in a long run sounds like a workaround. Are those hooks etc documented somewhere or do I have to do some code-spelunking? 😉 Or are you simply referring to those mentioned here?
I would love to, but unfortunately, there are low chances I get to it. Too much of other OSS work ahead of me right now. |
To be precise, in ts-jest, the first ts file will create language service once and cache it. The next files will use that cached instance of language service. What I can think of now is use node worker to separate emit diagnostics into another process, that might speed up emit process, see https://github.com/microsoft/TypeScript/wiki/Performance#concurrent-type-checking In https://github.com/TypeStrong/fork-ts-checker-webpack-plugin they use worker-rpc to offload that emit diagnostics into another process. I’m not so experienced with nodejs so I came to this thread to share my thoughts and probably learn something from you guys. |
I'm really interested in seeing the speed of this runner improve - would you be willing to share with me what you have tried in the past? Is there an interest in improving this?
From what I understand a new compiler is being created per test file right now, so probably the best improvement would be trying to reuse a single compiler instance and using TS's incremental API - I think is the strategy used by Fork TS Checker Webpack Plugin which I found to be pretty fast. Not 100% sure how this would play out with jest worker farm and how this is even utilized here, but this is something that could be explored.
The text was updated successfully, but these errors were encountered: