-
-
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
Add node worker-thread support to jest-worker #7408
Add node worker-thread support to jest-worker #7408
Conversation
Clean up types, create missing interfaes and make Flow and Jest happy
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.
Woo! Would be awesome to land before 24, although I guess it could go into a minor
…reads # Conflicts: # CHANGELOG.md
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 looks good to me. I addressed minor stuff (mostly the documentation), but the rest looks good!
Woooooo! 🎉 |
* master: (24 commits) Add `jest.isolateModules` for scoped module initialization (jestjs#6701) Migrate to Babel 7 (jestjs#7016) docs: changed "Great Scott!" link (jestjs#7524) Use reduce instead of filter+map in dependency_resolver (jestjs#7522) Update Configuration.md (jestjs#7455) Support dashed args (jestjs#7497) Allow % based configuration of max workers (jestjs#7494) chore: Standardize filenames: jest-runner pkg (jestjs#7464) allow `bail` setting to control when to bail out of a failing test run (jestjs#7335) Add issue template labels (jestjs#7470) chore: standardize filenames in e2e/babel-plugin-jest-hoist (jestjs#7467) Add node worker-thread support to jest-worker (jestjs#7408) Add `testPathIgnorePatterns` to CLI documentation (jestjs#7440) pretty-format: Omit non-enumerable symbol properties (jestjs#7448) Add Jest Architecture overview to docs. (jestjs#7449) chore: run appveyor tests on node 10 chore: fix failures e2e test for node 8 (jestjs#7446) chore: update docusaurus to v1.6.0 (jestjs#7445) Enhancement/expect-to-be-close-to-with-infinity (jestjs#7444) Update CHANGELOG formatting (jestjs#7429) ...
* Restructure workers (create a base class and inherit from it) Clean up types, create missing interfaes and make Flow and Jest happy * Move child.js to workers folder * Restructure base classes and make a working POC * Remove BaseWorker * Remove MessageChannel and cleanup super() calls * Use worker threads implementation if possible * Restructure queues * Support experimental modules in jest-resolver * Rename child.js to processChild.js * Remove private properties from WorkerPoolInterface * Move common line outside of if-else * Unify interface (use workerId) and remove recursion * Remove opt-out option for worker_threads in node 10.5+ * Alphabetical import sorting * Unlock worker after onEnd * Cache queue head in the getNextJob loop * Elegant while loop * Remove redundand .binds * Clean up interfaces and responsibilites * Update jest-worker * Add changelog and update jest-worker readme * Fix lint lol * Fixes from review * Update Changelog * rm function * rm [] * Make imports alphabetical 🤮 * Go back to any * Fix lint * \n * Fix formatting * Add docs * Revert canUseWorkerThreads * Fix lint * Fix pathing on windows
* Restructure workers (create a base class and inherit from it) Clean up types, create missing interfaes and make Flow and Jest happy * Move child.js to workers folder * Restructure base classes and make a working POC * Remove BaseWorker * Remove MessageChannel and cleanup super() calls * Use worker threads implementation if possible * Restructure queues * Support experimental modules in jest-resolver * Rename child.js to processChild.js * Remove private properties from WorkerPoolInterface * Move common line outside of if-else * Unify interface (use workerId) and remove recursion * Remove opt-out option for worker_threads in node 10.5+ * Alphabetical import sorting * Unlock worker after onEnd * Cache queue head in the getNextJob loop * Elegant while loop * Remove redundand .binds * Clean up interfaces and responsibilites * Update jest-worker * Add changelog and update jest-worker readme * Fix lint lol * Fixes from review * Update Changelog * rm function * rm [] * Make imports alphabetical 🤮 * Go back to any * Fix lint * \n * Fix formatting * Add docs * Revert canUseWorkerThreads * Fix lint * Fix pathing on windows
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
This PR is a continuation of #6676
Node 10 shipped with a "threading API" that uses SharedBuffers to communicate between the main process and its child threads. Being jest-worker a parallelization library, we can take advantage of this API when available. At the same time, we'll decouple our scheduling logic from our communication logic for better re-usability.
Here are some key things:
Test plan
Add unit and integration tests, near 100% coverage
I also tried as much as possible to move existing tests rather than writing new ones. In a few places where the refactoring broke the test irrecoverably I wrote new tests
Performance
Without experimental worker
With experimental worker