Skip to content

Commit

Permalink
Implement memory.oom.group cgroup setting (#7944)
Browse files Browse the repository at this point in the history
Missed this one.
  • Loading branch information
bduffany authored Nov 25, 2024
1 parent 47471a9 commit 40e3d5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions enterprise/server/remote_execution/cgroup/cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ func settingsMap(s *scpb.CgroupSettings, blockDevice *block_io.Device) (map[stri
if s.MemoryMinimumBytes != nil {
m["memory.min"] = strconv.Itoa(int(s.GetMemoryMinimumBytes()))
}
if s.MemoryOomGroup != nil {
m["memory.oom.group"] = fmtBool(s.GetMemoryOomGroup())
}
if s.SwapThrottleLimitBytes != nil {
m["memory.swap.high"] = strconv.Itoa(int(s.GetSwapThrottleLimitBytes()))
}
Expand Down Expand Up @@ -193,6 +196,13 @@ func settingsMap(s *scpb.CgroupSettings, blockDevice *block_io.Device) (map[stri
return m, nil
}

func fmtBool(v bool) string {
if v {
return "1"
}
return "0"
}

func fmtPercent(v float32) string {
return fmt.Sprintf("%.2f", v)
}
Expand Down
2 changes: 2 additions & 0 deletions enterprise/server/remote_execution/cgroup/cgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestSettingsMap(t *testing.T) {
MemoryLimitBytes: proto.Int64(800e6),
MemorySoftGuaranteeBytes: proto.Int64(100e6),
MemoryMinimumBytes: proto.Int64(50e6),
MemoryOomGroup: proto.Bool(true),
SwapThrottleLimitBytes: proto.Int64(800e6),
SwapLimitBytes: proto.Int64(1e9),
BlockIoLatencyTargetUsec: proto.Int64(100e3),
Expand All @@ -74,6 +75,7 @@ func TestSettingsMap(t *testing.T) {
"memory.max": "800000000",
"memory.low": "100000000",
"memory.min": "50000000",
"memory.oom.group": "1",
"memory.swap.high": "800000000",
"memory.swap.max": "1000000000",
"io.latency": "279:8 target=100000",
Expand Down

0 comments on commit 40e3d5f

Please sign in to comment.