Skip to content
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

Proof of concept: Transpile in workers #1082

Closed
wants to merge 11 commits into from

Conversation

novemberborn
Copy link
Member

This is a proof of concept for #1052.

The code is terrible! Let's not talk about that!

What it does:

  • Transpiles tests in the workers
  • Integrates babel-core/register-like behavior into AVA itself
  • Generates a bundle which the workers use to gain quicker access to Babel

Caveats:

Here's some unscientific comparisons comparing x690@master and x690@test-against-src (which requires the babel-core/register-like behavior) with AVA master (6165a23). Does not include bundle generation time.

Command used is time ./node_modules/.bin/ava --verbose with Node.js v6.8.1. For the master no cache tests, BABEL_DISABLE_CACHE=true is set. master cache tests are run twice with Babel's cache enabled, capturing the second result.

x690@master x690@test-against-src
master no cache 5.11s 10.01s
master cache 2.58s 5.04s
poc no cache 9.91s 9.78s
poc cache 2.49s 2.55s

Observations:

  • This poc is slower when sources do not need to be transpiled. Presumably that's due to the remaining overhead of loading Babel in each worker, and the cost of transpilation itself
  • However there is no extra cost when transpiling sources, and it seems on par with if not faster than master (except that there is no cache validation in the poc…)
  • Performance improves dramatically with the native source transpilation, presumably due to better caching
  • When the concurrency option is not set, we only start the next worker when we've received tests from the previous worker! We should probably spawn more workers concurrently, except that if caches are missing each workers starts fighting for CPU time and the test run ends up being slower (in the x690@test-against-src case 18.94s versus 13.50s)

Takeaways:

  • Integrating source transpilation seems promising. It's faster once cached and on par when there is no cache
  • Uncached performance without source transpilation seems too slow, this needs more investigation. Perhaps we could stick to transpiling test files in the main thread, but still add source transpilation in the workers
  • We may need to do this together with changes to the worker pool allocation to get the best performance balance

Thoughts?

Move the actual implementation into lib/cli.js to avoid top-level
returns. xo@^0.17.0 cannot parse the file with those returns present.

Throw errors from lib/cli.js and write them to stderr in cli.js before
exiting. XO doesn't appreciate process.exit() calls in modules.

Note that the error for invalid Babel config is now written to stderr,
which seems like an improvement to me.
Extract plugins into their own modules. Build a generic config object
that can be sent to the workers. Include more dependencies in the
pluginPackages export.
Requires a cached-module-loader bump, which also makes the
rewrite-runtime work.
@novemberborn
Copy link
Member Author

This will be fleshed out further when implementing RFC001.

@novemberborn novemberborn deleted the poc-transpile-in-workers branch January 17, 2017 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant