Skip to content

Commit

Permalink
Apply scaling reserved RAM to large runners only
Browse files Browse the repository at this point in the history
  • Loading branch information
henrymercer committed Jul 21, 2023
1 parent 18ae981 commit fda93d8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions lib/util.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.test.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)))
},
];

Expand Down
4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fda93d8

Please sign in to comment.