From f764c5be249e76b4da1e3f340bc02ecc9fdd9219 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 24 Dec 2022 22:21:53 -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. --- 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; }