Skip to content

Commit aaeb975

Browse files
use all available threads for analysis
1 parent 2527130 commit aaeb975

4 files changed

Lines changed: 22 additions & 8 deletions

File tree

analyze/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ inputs:
1919
threads:
2020
description: The number of threads to be used by CodeQL.
2121
required: false
22-
default: "1"
2322
checkout_path:
2423
description: "The path at which the analyzed repository was checked out. Used to relativeize any absolute paths in the uploaded SARIF file."
2524
required: false

lib/util.js

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/util.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/util.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,15 @@ export function getMemoryFlag(): string {
375375
}
376376

377377
/**
378-
* Get the codeql `--threads` value specified for the `threads` input. The value
379-
* defaults to 1. The value will be capped to the number of available CPUs.
378+
* Get the codeql `--threads` value specified for the `threads` input.
379+
* If not value was specified, all available threads will be used.
380+
*
381+
* The value will be capped to the number of available CPUs.
380382
*
381383
* @returns string
382384
*/
383385
export function getThreadsFlag(): string {
384-
let numThreads = 1;
386+
let numThreads: number;
385387
const numThreadsString = core.getInput("threads");
386388
if (numThreadsString) {
387389
numThreads = Number(numThreadsString);
@@ -390,12 +392,17 @@ export function getThreadsFlag(): string {
390392
}
391393
const maxThreads = os.cpus().length;
392394
if (numThreads > maxThreads) {
395+
core.info(`Clamping desired number of threads (${numThreads}) to max available (${maxThreads}).`);
393396
numThreads = maxThreads;
394397
}
395398
const minThreads = -maxThreads;
396399
if (numThreads < minThreads) {
400+
core.info(`Clamping desired number of free threads (${numThreads}) to max available (${minThreads}).`);
397401
numThreads = minThreads;
398402
}
403+
} else {
404+
// Default to using all threads
405+
numThreads = os.cpus().length;
399406
}
400407
return `--threads=${numThreads}`;
401408
}

0 commit comments

Comments
 (0)