Remove scaling reserved RAM feature flag
This commit is contained in:
parent
574dbbc517
commit
10389f671b
15 changed files with 58 additions and 123 deletions
28
lib/util.js
generated
28
lib/util.js
generated
|
|
@ -110,19 +110,13 @@ exports.withTmpDir = withTmpDir;
|
|||
* from committing too much of the available memory to CodeQL.
|
||||
* @returns number
|
||||
*/
|
||||
function getSystemReservedMemoryMegaBytes(totalMemoryMegaBytes, platform, isScalingReservedRamEnabled) {
|
||||
function getSystemReservedMemoryMegaBytes(totalMemoryMegaBytes, platform) {
|
||||
// Windows needs more memory for OS processes.
|
||||
const fixedAmount = 1024 * (platform === "win32" ? 1.5 : 1);
|
||||
if (isScalingReservedRamEnabled) {
|
||||
// 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;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
function getReservedRamScaleFactor() {
|
||||
const envVar = Number.parseInt(process.env[environment_1.EnvVar.SCALING_RESERVED_RAM_PERCENTAGE] || "", 10);
|
||||
|
|
@ -138,7 +132,7 @@ function getReservedRamScaleFactor() {
|
|||
*
|
||||
* @returns {number} the amount of RAM to use, in megabytes
|
||||
*/
|
||||
function getMemoryFlagValueForPlatform(userInput, totalMemoryBytes, platform, isScalingReservedRamEnabled) {
|
||||
function getMemoryFlagValueForPlatform(userInput, totalMemoryBytes, platform) {
|
||||
let memoryToUseMegaBytes;
|
||||
if (userInput) {
|
||||
memoryToUseMegaBytes = Number(userInput);
|
||||
|
|
@ -148,7 +142,7 @@ function getMemoryFlagValueForPlatform(userInput, totalMemoryBytes, platform, is
|
|||
}
|
||||
else {
|
||||
const totalMemoryMegaBytes = totalMemoryBytes / (1024 * 1024);
|
||||
const reservedMemoryMegaBytes = getSystemReservedMemoryMegaBytes(totalMemoryMegaBytes, platform, isScalingReservedRamEnabled);
|
||||
const reservedMemoryMegaBytes = getSystemReservedMemoryMegaBytes(totalMemoryMegaBytes, platform);
|
||||
memoryToUseMegaBytes = totalMemoryMegaBytes - reservedMemoryMegaBytes;
|
||||
}
|
||||
return Math.floor(memoryToUseMegaBytes);
|
||||
|
|
@ -161,8 +155,8 @@ exports.getMemoryFlagValueForPlatform = getMemoryFlagValueForPlatform;
|
|||
*
|
||||
* @returns {number} the amount of RAM to use, in megabytes
|
||||
*/
|
||||
function getMemoryFlagValue(userInput, isScalingReservedRamEnabled) {
|
||||
return getMemoryFlagValueForPlatform(userInput, os.totalmem(), process.platform, isScalingReservedRamEnabled);
|
||||
function getMemoryFlagValue(userInput) {
|
||||
return getMemoryFlagValueForPlatform(userInput, os.totalmem(), process.platform);
|
||||
}
|
||||
exports.getMemoryFlagValue = getMemoryFlagValue;
|
||||
/**
|
||||
|
|
@ -172,8 +166,8 @@ exports.getMemoryFlagValue = getMemoryFlagValue;
|
|||
*
|
||||
* @returns string
|
||||
*/
|
||||
function getMemoryFlag(userInput, isScalingReservedRamEnabled) {
|
||||
const megabytes = getMemoryFlagValue(userInput, isScalingReservedRamEnabled);
|
||||
function getMemoryFlag(userInput) {
|
||||
const megabytes = getMemoryFlagValue(userInput);
|
||||
return `--ram=${megabytes}`;
|
||||
}
|
||||
exports.getMemoryFlag = getMemoryFlag;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue