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 <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
cjihrig authored Dec 27, 2022
1 parent 248679b commit fe5710e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit fe5710e

Please sign in to comment.