From 632d9b3622040a4b25d5f97d72d2222496987f16 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 13 Feb 2022 16:29:46 +0100 Subject: [PATCH] cli: set default worker queue thread count to cpus/2 Signed-off-by: Patrik Oldsberg --- packages/cli/src/lib/parallel.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/lib/parallel.ts b/packages/cli/src/lib/parallel.ts index 246020fcc3..15946bd70d 100644 --- a/packages/cli/src/lib/parallel.ts +++ b/packages/cli/src/lib/parallel.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import os from 'os'; import { ErrorLike } from '@backstage/errors'; import { Worker } from 'worker_threads'; @@ -137,7 +138,7 @@ export type WorkerQueueThreadsOptions = { workerFactory: (data: TData) => (item: TItem) => Promise; /** Data supplied to each worker factory */ workerData?: TData; - /** Number of threads, defaults to the environment parallelism */ + /** Number of threads, defaults to half of the number of available CPUs */ threadCount?: number; }; @@ -151,7 +152,7 @@ export async function runWorkerQueueThreads( const { workerFactory, workerData, - threadCount = getEnvironmentParallelism(), + threadCount = os.cpus().length / 2, } = options; const iterator = options.items[Symbol.iterator]();