From 00cf797ac6f3c90972dab90c8b3a881acbb16525 Mon Sep 17 00:00:00 2001 From: Sergey Chernyshev Date: Thu, 25 Apr 2024 01:51:38 +0200 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 --- graal-nodejs/lib/internal/test_runner/test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/graal-nodejs/lib/internal/test_runner/test.js b/graal-nodejs/lib/internal/test_runner/test.js index 9d05202a44c..becb4c07d7c 100644 --- a/graal-nodejs/lib/internal/test_runner/test.js +++ b/graal-nodejs/lib/internal/test_runner/test.js @@ -54,7 +54,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'; @@ -231,8 +231,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; }