use all available threads for analysis

This commit is contained in:
Robert Brignull 2020-08-13 14:25:10 +01:00
parent 2527130a32
commit aaeb9751bb
4 changed files with 22 additions and 8 deletions

14
lib/util.js generated
View file

@ -319,13 +319,15 @@ function getMemoryFlag() {
}
exports.getMemoryFlag = getMemoryFlag;
/**
* Get the codeql `--threads` value specified for the `threads` input. The value
* defaults to 1. The value will be capped to the number of available CPUs.
* Get the codeql `--threads` value specified for the `threads` input.
* If not value was specified, all available threads will be used.
*
* The value will be capped to the number of available CPUs.
*
* @returns string
*/
function getThreadsFlag() {
let numThreads = 1;
let numThreads;
const numThreadsString = core.getInput("threads");
if (numThreadsString) {
numThreads = Number(numThreadsString);
@ -334,13 +336,19 @@ function getThreadsFlag() {
}
const maxThreads = os.cpus().length;
if (numThreads > maxThreads) {
core.info(`Clamping desired number of threads (${numThreads}) to max available (${maxThreads}).`);
numThreads = maxThreads;
}
const minThreads = -maxThreads;
if (numThreads < minThreads) {
core.info(`Clamping desired number of free threads (${numThreads}) to max available (${minThreads}).`);
numThreads = minThreads;
}
}
else {
// Default to using all threads
numThreads = os.cpus().length;
}
return `--threads=${numThreads}`;
}
exports.getThreadsFlag = getThreadsFlag;

File diff suppressed because one or more lines are too long