cli: set default worker queue thread count to cpus/2

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-02-13 16:29:46 +01:00
parent 828a3e339c
commit 632d9b3622
+3 -2
View File
@@ -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<TItem, TResult, TData> = {
workerFactory: (data: TData) => (item: TItem) => Promise<TResult>;
/** 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<TItem, TResult, TData>(
const {
workerFactory,
workerData,
threadCount = getEnvironmentParallelism(),
threadCount = os.cpus().length / 2,
} = options;
const iterator = options.items[Symbol.iterator]();