From 164c0d805d48718e8888636323bf206d2ef579cf Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 1 Jul 2024 09:39:58 +0000 Subject: [PATCH] fix(@angular-devkit/build-angular): reduce the number of max workers to available CPUs 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. --- .../build_angular/src/utils/environment-options.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/angular_devkit/build_angular/src/utils/environment-options.ts b/packages/angular_devkit/build_angular/src/utils/environment-options.ts index c1e330b37963..9d53be82ce79 100644 --- a/packages/angular_devkit/build_angular/src/utils/environment-options.ts +++ b/packages/angular_devkit/build_angular/src/utils/environment-options.ts @@ -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);