Skip to content

Commit

Permalink
test_runner: use os.availableParallelism()
Browse files Browse the repository at this point in the history
This commit addresses an existing TODO in the code by moving
to the new os.availableParallelism() instead of os.cpus().length.

PR-URL: #45969
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
cjihrig authored and targos committed Nov 10, 2023
1 parent dfa4444 commit 0bd9704
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/internal/test_runner/test.js
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 0bd9704

Please sign in to comment.