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

Build: Limit the numbers of cores used by the build #26059

Merged
merged 3 commits into from
Jul 16, 2018

Conversation

blowery
Copy link
Contributor

@blowery blowery commented Jul 13, 2018

Limit to half of the available cores. This seems to give the best performance across machines.

Limit to half of the available cores. This seems to give the best performance across machines.
@matticbot
Copy link
Contributor

@blowery
Copy link
Contributor Author

blowery commented Jul 13, 2018

Prior art #25456

@blowery blowery requested review from sirreal, DanReyLop and a team July 13, 2018 20:04
@blowery blowery self-assigned this Jul 13, 2018
@blowery blowery added the Build label Jul 13, 2018
@blowery
Copy link
Contributor Author

blowery commented Jul 13, 2018

On my MacBook Pro, Core i7 (4 cores, 8 threads), no babel cache present.
Time to build modules:

Workers Time
1 80s
2 55s
3 44s
4 42s
6 43s
8 45s

@blowery blowery added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 13, 2018
@@ -72,8 +72,6 @@ const babelLoader = {
},
};

threadLoader.warmup( {}, [ 'babel-loader' ] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this? Or why was it here in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was an attempt to warmup the workers before they would be used. However, it has no apparent speed impact and can make the build hang, waiting for the workers to terminate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to repro the hang, add back the prewarm statement and the thread loader require, then configure the thread loader in the server build to use 4 workers. For me, npm run build-server would run, apparently complete, but then hang waiting for something complete.

Removing the warmup killed the hang.

{
loader: 'thread-loader',
options: {
workers: Math.max( Math.floor( os.cpus().length / 2 ), 1 ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's bump the minimum to 2. Even in a hypothetical single core machine, 2 threads would be better than 1 thread (plus the overhead of using thread-loader for a single thread)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I was thinking about conditionally ditching the thread-loader based on the number of cores, but defaulting to 2 is fine too.

Copy link
Contributor

@DanReyLop DanReyLop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't time it, but these commands still work:

  • npm start
  • CALYPSO_ENV=production npm run build

:shipit:

@sirreal sirreal added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jul 16, 2018
@blowery blowery merged commit 9c0ad37 into master Jul 16, 2018
@blowery blowery deleted the update/limit-cores-used-for-build branch July 16, 2018 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants