Skip to content

Commit

Permalink
fix(@angular/build): reduce the number of max workers to available CP…
Browse files Browse the repository at this point in the history
…Us minus one

This commit reduces the maximum number of workers to the available CPUs minus 1. This adjustment ensures that some resources are left for the main thread, preventing it from being starved of CPU cycles.

(cherry picked from commit 0a22e05)
  • Loading branch information
alan-agius4 committed Jul 1, 2024
1 parent 2d51e86 commit 16f1c1e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/angular/build/src/utils/environment-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const allowMinify = debugOptimize.minify;
const maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];
export const maxWorkers = isPresent(maxWorkersVariable)
? +maxWorkersVariable
: Math.min(4, availableParallelism());
: Math.min(4, Math.max(availableParallelism() - 1, 1));

const parallelTsVariable = process.env['NG_BUILD_PARALLEL_TS'];
export const useParallelTs = !isPresent(parallelTsVariable) || !isDisabled(parallelTsVariable);
Expand Down

0 comments on commit 16f1c1e

Please sign in to comment.