-
-
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
fix: limit number of workers when creating haste maps in projects #9259
Conversation
@@ -5,9 +5,7 @@ | |||
"**/node_modules": true, | |||
"**/build": true | |||
}, | |||
"editor.formatOnSave": true, |
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.
sure? 😀
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.
Format on save may conflict with eslint fix, if editor settings for prettier differ
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.
seems silly to me to have editor specific config files checked in, but I'm not losing sleep over it 🤷♂
@@ -122,7 +122,10 @@ const buildContextsAndHasteMaps = async ( | |||
createDirectory(config.cacheDirectory); | |||
const hasteMapInstance = Runtime.createHasteMap(config, { | |||
console: new CustomConsole(outputStream, outputStream), | |||
maxWorkers: globalConfig.maxWorkers, | |||
maxWorkers: Math.max( |
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.
there's not meaningful test we can write, right?
@scotthovestadt FYI whenever you get back. Not sure how this fits into your refactor |
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
Partially addresses #9236.
When creating haste contexts and maps, Jest currently spawns
maxWorkers
per "project". While it doesn't make a difference in a single-project workspace, it's a big deal for those using multiple projects.A quick-and-dirty-but-works solution is to limit the number of workers based on the projects number. It's sub-optimal, because we may have smaller and larger projects which we assign the same number of workers. However a proper solution would require more work. E.g. we could delegate
createHasteMap
of each project to a worker pool created injest-core
, instead of deferring parallelization tocreateHasteMap
itself. Feel free to implement this solution. However, I'm not pursuing this, as @scotthovestadt has likely far more meaningful changes to haste map performance.In Jest own test suite, this diff result in haste map creation time drop from 3.1s to 0.8s on my machine, which is noticeable.