Allow customizing the scaling threshold with an environment variable
This commit is contained in:
parent
466ed42568
commit
574dbbc517
9 changed files with 82 additions and 12 deletions
18
lib/util.js
generated
18
lib/util.js
generated
|
|
@ -55,6 +55,10 @@ exports.DEFAULT_DEBUG_ARTIFACT_NAME = "debug-artifacts";
|
|||
* Default name of the database in the debugging artifact.
|
||||
*/
|
||||
exports.DEFAULT_DEBUG_DATABASE_NAME = "db";
|
||||
/**
|
||||
* The default fraction of the total RAM above 8 GB that should be reserved for the system.
|
||||
*/
|
||||
const DEFAULT_RESERVED_RAM_SCALING_FACTOR = 0.05;
|
||||
/**
|
||||
* Get the extra options for the codeql commands.
|
||||
*/
|
||||
|
|
@ -110,15 +114,23 @@ function getSystemReservedMemoryMegaBytes(totalMemoryMegaBytes, platform, isScal
|
|||
// Windows needs more memory for OS processes.
|
||||
const fixedAmount = 1024 * (platform === "win32" ? 1.5 : 1);
|
||||
if (isScalingReservedRamEnabled) {
|
||||
// Reserve an additional 5% of the amount of memory above 8 GB, since the amount used by the
|
||||
// kernel for page tables scales with the size of physical memory.
|
||||
const scaledAmount = 0.05 * Math.max(totalMemoryMegaBytes - 8 * 1024, 0);
|
||||
// Reserve an additional percentage of the amount of memory above 8 GB, since the amount used by
|
||||
// the kernel for page tables scales with the size of physical memory.
|
||||
const scaledAmount = getReservedRamScaleFactor() *
|
||||
Math.max(totalMemoryMegaBytes - 8 * 1024, 0);
|
||||
return fixedAmount + scaledAmount;
|
||||
}
|
||||
else {
|
||||
return fixedAmount;
|
||||
}
|
||||
}
|
||||
function getReservedRamScaleFactor() {
|
||||
const envVar = Number.parseInt(process.env[environment_1.EnvVar.SCALING_RESERVED_RAM_PERCENTAGE] || "", 10);
|
||||
if (envVar < 0 || envVar > 100 || Number.isNaN(envVar)) {
|
||||
return DEFAULT_RESERVED_RAM_SCALING_FACTOR;
|
||||
}
|
||||
return envVar / 100;
|
||||
}
|
||||
/**
|
||||
* Get the value of the codeql `--ram` flag as configured by the `ram` input.
|
||||
* If no value was specified, the total available memory will be used minus a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue