From b0c92ec63ae50f71cee927d759913361bb5969e2 Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Mon, 26 Dec 2022 22:30:19 -0500 Subject: [PATCH] test_runner: use os.availableParallelism() This commit addresses an existing TODO in the code by moving to the new os.availableParallelism() instead of os.cpus().length. PR-URL: https://github.com/nodejs/node/pull/45969 Reviewed-By: Yagiz Nizipli Reviewed-By: Moshe Atlow Reviewed-By: Benjamin Gruenbaum Reviewed-By: Antoine du Hamel --- lib/internal/test_runner/test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/internal/test_runner/test.js b/lib/internal/test_runner/test.js index 14ddb96d1155be..b7267491d50c3f 100644 --- a/lib/internal/test_runner/test.js +++ b/lib/internal/test_runner/test.js @@ -53,7 +53,7 @@ const { } = require('internal/validators'); const { setTimeout } = require('timers/promises'); const { TIMEOUT_MAX } = require('internal/timers'); -const { cpus } = require('os'); +const { availableParallelism } = require('os'); const { bigint: hrtime } = process.hrtime; const kCallbackAndPromisePresent = 'callbackAndPromisePresent'; const kCancelledByParent = 'cancelledByParent'; @@ -216,8 +216,8 @@ class Test extends AsyncResource { case 'boolean': if (concurrency) { - // TODO(cjihrig): Use uv_available_parallelism() once it lands. - this.concurrency = parent === null ? MathMax(cpus().length - 1, 1) : Infinity; + this.concurrency = parent === null ? + MathMax(availableParallelism() - 1, 1) : Infinity; } else { this.concurrency = 1; }