mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-09-11 14:46:37 +03:00
Fix os.cpus() and worker count in prepack test runner
Summary: Turns out os.cpus() can return [] and undefined. Additionally, it seems to me like any number below 4 could lead to an empty pool so I tried to address that too. Reviewed By: NTillmann Differential Revision: D8332896 fbshipit-source-id: 60e082a4f0d18e72f95b76732a50adeccb2d333d
This commit is contained in:
parent
3706b936c3
commit
485ea766fa
@ -33,7 +33,8 @@ import minimist from "minimist";
|
||||
import process from "process";
|
||||
|
||||
const EOL = os.EOL;
|
||||
const numCPUs = os.cpus().length;
|
||||
const cpus = os.cpus();
|
||||
const numCPUs = cpus ? cpus.length : 1;
|
||||
require("source-map-support").install();
|
||||
|
||||
type HarnessMap = { [key: string]: string };
|
||||
@ -464,7 +465,7 @@ function masterRunMultiProcess(
|
||||
const granularity = Math.floor(tests.length / 10);
|
||||
const originalTestLength = tests.length;
|
||||
// Fork workers.
|
||||
const numWorkers = Math.floor(numCPUs * args.cpuScale);
|
||||
const numWorkers = Math.max(1, Math.floor(numCPUs * args.cpuScale));
|
||||
console.log(`Master starting up, forking ${numWorkers} workers`);
|
||||
for (let i = 0; i < numWorkers; i++) {
|
||||
cluster.fork();
|
||||
|
Loading…
Reference in New Issue
Block a user