-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Transpile in the main process #945
Conversation
Wahoo! Thanks for working on this. I'll give it a look in an hour or two and report back. |
So, some anecdotal numbers from a small project with just seven test files (23 tests):
Total execution time is a smidge faster, but CPU time is much reduced (looks to be by about 50%). |
Wrote a copy script to turn my 7 test files into 70 (230 tests):
|
Scratch that. Works for me either way. |
Make sure to clear the cache:
|
clearing the cache didn't help |
Mine was interesting... So I just remembered that one of my tests has dynamic requires (so we instrument all our code for coverage), so I noticed the output indicating that which was cool. The tests went from 41 seconds to 19 seconds which is awesome. But I ended up with 5 test failures due to "Unexpected reserved word" and another test failure that's kind of interesting:
I did clear the cache (note, with no cache it actually takes 26 seconds, but subsequent runs are 19ish seconds). I do have the concurrency option enabled. So far these results are promising though! |
so, it appears that some test files do run correctly, though not all, so it looks like you're finding the dependencies of some test files and missing the dependencies of others |
For dynamic requires, we probably need to give you a Try with higher concurrency. You should be able to handle more now that I will look into that other error later tonight |
Are any of these open source projects? |
Sorry, not mine |
mine isn't either |
if any part of the ava or babel config or the file structure helps just ask |
Probably file structure and the list of imports for each. |
deps.json.zip |
var entry = this._cache[filename] = {}; | ||
|
||
var result = babelCore().transformFileSync(filename, { | ||
plugins: [detective] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you don't merge this with the babelConfig already defined, this will implicitly be merged with the .babelrc
.
Which is totally cool if the babel option is set to "inherit". Otherwise, metadata generation might fail.
var config = objectAssign({}, this.babelConfig, {
plugins: this.babelConfig.plugins.concat(detective)
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this repo failing with this config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will implicitly be merged with the .babelrc.
Yes. That's the idea. That is only precompiling your sources. We already precompile your tests in caching-precompiler
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geowarin - see https://github.com/geowarin/repro-ava-precompile/issues/1 to fix yours.
@nfcampos - What's up with importing |
@jamestalmage it's for using You would still need to use that |
So |
prior to this PR I had this array in the "require": [
"babel-register",
"babel-polyfill",
"css-modules-require-hook/preset"
] to try out this PR I removed |
@nfcampos - do you know which files? |
@nfcampos |
@jamestalmage because it's linked with |
Ah. I see. |
|
||
## Caveats | ||
|
||
Use of `test.only` does not work correctly when concurrency is limited. We think this is a solvable problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you linkify the text here to the relevant issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's linked below, but would be useful to linkify it here too.
I've commented on some nitpick, but generally looks great! |
I think that I've found why some of my tests are broken. This apparently doesn't transpile files that are required with |
@jamestalmage Does it work with basic setup of E.g.:
And w/o Because with |
@jamestalmage nvm. Decided to remove |
Hi all! Great work on the project. My team seeing really slow test times along with thrashed cpus when testing > 30 test files in a React app. This is especially the case for those using a VM (Ubuntu on PC). Any updates on this feature or ideas how to mitigate this issue? Thanks!! |
Was going to pop in here too. I've run comparisons between @michaelgilley Have you tried the experimental |
@jfairbank Yes, have tried that but as noted in #966 it appears to affect the process differently based on what's available including what other things are running in the background. @nickjvm has had issues running ava in his VM. It's even caused active Chrome tabs to crash! It seems like the sort of thing that ought to be baked into ava - to programmatically check what concurrency level it should be running. When running ava in npm scripts and often behind nyc for coverage it becomes awkward for a team to figure out how to individually configure ava to run correctly on their machines. |
What's the status on this PR? It seems pretty stale. We really need something like this to be done. With > 100 test files this really becomes essential. Any idea when Ava will be updated to support transpiling once, in the main process before tests are run? For now we are setting concurrency to 6 but that means that 400 tests are taking at least several minutes to run. |
Agreed with above but IIRC James is quite busy right now and probably not able to work on this. @avajs/core This is the most needed open PR in my opinion, but it's not an easy problem to solve right? Anything we can do to help? |
@sindresorhus would it be possible to get the documentation fixes merged in a separate PR so the |
I need to write up my thoughts but I'm doing some experiments with speeding up how we bootstrap Babel. That may make it feasible to load Babel in the test workers again, and even allow us to build in source compilation. |
Might I suggest taking a look at how Jest does this? We ended up switching and it's much, much faster. It may be prudent to take a page from their book. 😄 |
@michaelgilley I believe Jest does isolation via |
4bc021e
to
476c653
Compare
8610723
to
4acb78f
Compare
Closing in favor of RFC001. |
Fixes #577
Use the
--precompile
flag to apply transpilation to all file dependencies.The idea would be to drop
--require babel-register
and use the--precompile
flag instead.It's pretty naive right now:
shouldTranspile
method just prevents transpilingnode_modules
, there's probably more logic that needs to be incorporated from Babelsonly
andignore
options.babel-core
gets loaded every time). We could speed things up more by trying to create a cache key from the input and the babel config, but that means resolving and parsing said config.babel-register
that does not load upbabel-core
except for dynamic requires (so you only pay the price when you actually use a dynamic require).node_modules
, and circular dependencies. It could also stand to have some true unit tests instead of just integration tests.I would like it if a few people gave it a try to see if it improved performance at all. Especially people with lots of test files that are using
--require babel-register
. (paging @kentcdodds).