Apply scaling reserved RAM to large runners only
This commit is contained in:
parent
18ae9813bf
commit
fda93d8ef5
6 changed files with 16 additions and 16 deletions
4
lib/util.js
generated
4
lib/util.js
generated
|
|
@ -109,9 +109,9 @@ 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 2% of the total memory, since the amount used by
|
||||
// Reserve an additional 2.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.02 * totalMemoryMegaBytes;
|
||||
const scaledAmount = 0.025 * Math.max(totalMemoryMegaBytes - 8 * 1024, 0);
|
||||
return fixedAmount + scaledAmount;
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
10
lib/util.test.js
generated
10
lib/util.test.js
generated
|
|
@ -45,21 +45,21 @@ const GET_MEMORY_FLAG_TESTS = [
|
|||
totalMemoryMb: 8 * 1024,
|
||||
platform: "linux",
|
||||
expectedMemoryValue: 7 * 1024,
|
||||
expectedMemoryValueWithScaling: 7004, // Math.floor(1024 * (8*0.98 - 1))
|
||||
expectedMemoryValueWithScaling: 7 * 1024,
|
||||
},
|
||||
{
|
||||
input: undefined,
|
||||
totalMemoryMb: 8 * 1024,
|
||||
platform: "win32",
|
||||
expectedMemoryValue: 6.5 * 1024,
|
||||
expectedMemoryValueWithScaling: 6492, // Math.floor(1024 * (8*0.98 - 1.5))
|
||||
expectedMemoryValueWithScaling: 6.5 * 1024,
|
||||
},
|
||||
{
|
||||
input: "",
|
||||
totalMemoryMb: 8 * 1024,
|
||||
platform: "linux",
|
||||
expectedMemoryValue: 7 * 1024,
|
||||
expectedMemoryValueWithScaling: 7004, // Math.floor(1024 * (8*0.98 - 1))
|
||||
expectedMemoryValueWithScaling: 7 * 1024,
|
||||
},
|
||||
{
|
||||
input: "512",
|
||||
|
|
@ -73,14 +73,14 @@ const GET_MEMORY_FLAG_TESTS = [
|
|||
totalMemoryMb: 64 * 1024,
|
||||
platform: "linux",
|
||||
expectedMemoryValue: 63 * 1024,
|
||||
expectedMemoryValueWithScaling: 63201, // Math.floor(1024 * (64*0.98 - 1))
|
||||
expectedMemoryValueWithScaling: 63078, // Math.floor(1024 * (64 - 1 - 0.025 * (64 - 8)))
|
||||
},
|
||||
{
|
||||
input: undefined,
|
||||
totalMemoryMb: 64 * 1024,
|
||||
platform: "win32",
|
||||
expectedMemoryValue: 62.5 * 1024,
|
||||
expectedMemoryValueWithScaling: 62689, // Math.floor(1024 * (64*0.98 - 1.5))
|
||||
expectedMemoryValueWithScaling: 62566, // Math.floor(1024 * (64 - 1.5 - 0.025 * (64 - 8)))
|
||||
},
|
||||
];
|
||||
for (const { input, totalMemoryMb, platform, expectedMemoryValue, expectedMemoryValueWithScaling, } of GET_MEMORY_FLAG_TESTS) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -25,21 +25,21 @@ const GET_MEMORY_FLAG_TESTS = [
|
|||
totalMemoryMb: 8 * 1024,
|
||||
platform: "linux",
|
||||
expectedMemoryValue: 7 * 1024,
|
||||
expectedMemoryValueWithScaling: 7004, // Math.floor(1024 * (8*0.98 - 1))
|
||||
expectedMemoryValueWithScaling: 7 * 1024,
|
||||
},
|
||||
{
|
||||
input: undefined,
|
||||
totalMemoryMb: 8 * 1024,
|
||||
platform: "win32",
|
||||
expectedMemoryValue: 6.5 * 1024,
|
||||
expectedMemoryValueWithScaling: 6492, // Math.floor(1024 * (8*0.98 - 1.5))
|
||||
expectedMemoryValueWithScaling: 6.5 * 1024,
|
||||
},
|
||||
{
|
||||
input: "",
|
||||
totalMemoryMb: 8 * 1024,
|
||||
platform: "linux",
|
||||
expectedMemoryValue: 7 * 1024,
|
||||
expectedMemoryValueWithScaling: 7004, // Math.floor(1024 * (8*0.98 - 1))
|
||||
expectedMemoryValueWithScaling: 7 * 1024,
|
||||
},
|
||||
{
|
||||
input: "512",
|
||||
|
|
@ -53,14 +53,14 @@ const GET_MEMORY_FLAG_TESTS = [
|
|||
totalMemoryMb: 64 * 1024,
|
||||
platform: "linux",
|
||||
expectedMemoryValue: 63 * 1024,
|
||||
expectedMemoryValueWithScaling: 63201, // Math.floor(1024 * (64*0.98 - 1))
|
||||
expectedMemoryValueWithScaling: 63078, // Math.floor(1024 * (64 - 1 - 0.025 * (64 - 8)))
|
||||
},
|
||||
{
|
||||
input: undefined,
|
||||
totalMemoryMb: 64 * 1024,
|
||||
platform: "win32",
|
||||
expectedMemoryValue: 62.5 * 1024,
|
||||
expectedMemoryValueWithScaling: 62689, // Math.floor(1024 * (64*0.98 - 1.5))
|
||||
expectedMemoryValueWithScaling: 62566, // Math.floor(1024 * (64 - 1.5 - 0.025 * (64 - 8)))
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -160,9 +160,9 @@ function getSystemReservedMemoryMegaBytes(
|
|||
const fixedAmount = 1024 * (platform === "win32" ? 1.5 : 1);
|
||||
|
||||
if (isScalingReservedRamEnabled) {
|
||||
// Reserve an additional 2% of the total memory, since the amount used by
|
||||
// Reserve an additional 2.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.02 * totalMemoryMegaBytes;
|
||||
const scaledAmount = 0.025 * Math.max(totalMemoryMegaBytes - 8 * 1024, 0);
|
||||
return fixedAmount + scaledAmount;
|
||||
} else {
|
||||
return fixedAmount;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue