Account for existing but empty cpus file

If a CPU file exists but is empty, previously we reported this file with a CPU count of 1, which resulted in a single-threaded run.
This commit is contained in:
Angela P Wen
2024-02-15 14:31:37 +00:00
parent 65b0987dbe
commit ef0a773901
4 changed files with 10 additions and 4 deletions

View File

@@ -453,7 +453,10 @@ function getCgroupCpuCountFromCpus(
let cpuCount = 0;
// Comma-separated numbers and ranges, for eg. 0-1,3
const cpusString = fs.readFileSync(cpusFile, "utf-8");
const cpusString = fs.readFileSync(cpusFile, "utf-8").trim();
if (cpusString.length === 0) {
return undefined;
}
for (const token of cpusString.split(",")) {
if (!token.includes("-")) {
// Not a range