test: fix test-worker-memory.js for large cpu #s

This test consistently failed on a system with a
large number of cores (~120). Cap the number of
concurrent workers so we'll stay consistently within
the "slack" allowed with respect to rss.

PR-URL: https://github.com/nodejs/node/pull/27090
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
Michael Dawson 2019-04-04 13:03:48 -04:00
parent 93df085386
commit f96a6608eb

View File

@ -4,7 +4,13 @@ const assert = require('assert');
const util = require('util');
const { Worker } = require('worker_threads');
const numWorkers = +process.env.JOBS || require('os').cpus().length;
let numWorkers = +process.env.JOBS || require('os').cpus().length;
if (numWorkers > 20) {
// Cap the number of workers at 20 (as an even divisor of 60 used as
// the total number of workers started) otherwise the test fails on
// machines with high core counts.
numWorkers = 20;
}
// Verify that a Worker's memory isn't kept in memory after the thread finishes.