From e8a6d6bc41edcdb0cd58f4c62ddf0199f8c643d2 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 1 Jul 2024 09:39:30 +0000 Subject: [PATCH] fix(@angular/build): 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. (cherry picked from commit 0a22e05dd2009090cebdc0d2ecceec21ba155793) --- packages/angular/build/src/utils/environment-options.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/angular/build/src/utils/environment-options.ts b/packages/angular/build/src/utils/environment-options.ts index 26d211b3a77d..cad94ce76129 100644 --- a/packages/angular/build/src/utils/environment-options.ts +++ b/packages/angular/build/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);