-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular-devkit/build-angular): limit the amount of CPUs used by …
…workers See: #16860 (comment) (cherry picked from commit 94c753c)
- Loading branch information
1 parent
9907542
commit 7f6703c
Showing
4 changed files
with
31 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/angular_devkit/build_angular/src/utils/workers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { cpus } from 'os'; | ||
/** | ||
* Use CPU count -1 with limit to 7 for workers not to clog the system. | ||
* Some environments, like CircleCI which use Docker report a number of CPUs by the host and not the count of available. | ||
* This cause `Error: Call retries were exceeded` errors when trying to use them. | ||
* | ||
* See: | ||
* | ||
* https://github.com/nodejs/node/issues/28762 | ||
* | ||
* https://github.com/webpack-contrib/terser-webpack-plugin/issues/143 | ||
* | ||
* https://github.com/angular/angular-cli/issues/16860#issuecomment-588828079 | ||
* | ||
*/ | ||
export const maxWorkers = Math.max(Math.min(cpus().length, 8) - 1, 1); |