Skip to content

Commit 1dbc64d

Browse files
smirashanduur
authored andcommitted
fix: simplify OOM expression
Remove denominator that was supposed to scale based on difference between peak and current memory usage, and score simply based on current memory usage. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> (cherry picked from commit 2f42202)
1 parent 0ffb1d8 commit 1dbc64d

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

internal/app/machined/pkg/controllers/runtime/internal/oom/oom_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestCalculateScore(t *testing.T) {
4141
MemoryPeak: cgroups.Value{Val: 50, IsSet: true},
4242
MemoryMax: cgroups.Value{IsSet: true, IsMax: true},
4343
},
44-
expect: 2.625,
44+
expect: 21,
4545
},
4646
} {
4747
t.Run(test.name, func(t *testing.T) {
@@ -79,14 +79,14 @@ func TestRankCgroups(t *testing.T) {
7979
MemoryCurrent: cgroups.Value{Val: 222593024, IsSet: true},
8080
MemoryPeak: cgroups.Value{Val: 371011584, IsSet: true},
8181
MemoryMax: cgroups.Value{IsMax: true, IsSet: true},
82-
}: 1.499765420173865,
82+
}: 2.22593024e+08,
8383
{
8484
Class: runtime.QoSCgroupClassBurstable,
8585
Path: "testdata/rank1/kubepods/burstable/podABC",
8686
MemoryCurrent: cgroups.Value{Val: 42, IsSet: true},
8787
MemoryPeak: cgroups.Value{Val: 50, IsSet: true},
8888
MemoryMax: cgroups.Value{IsSet: true, IsMax: true},
89-
}: 2.625,
89+
}: 21,
9090
},
9191
},
9292
} {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v1alpha1
22
kind: OOMConfig
33
triggerExpression: memory_full_avg10 > 12.0 && d_memory_full_avg10 > 0.0 && time_since_trigger > duration("500ms")
4-
cgroupRankingExpression: 'memory_max.hasValue() ? 0.0 : ({Besteffort: 1.0, Burstable: 0.5, Guaranteed: 0.0, Podruntime: 0.0, System: 0.0}[class] * double(memory_current.orValue(0u)) / double(memory_peak.orValue(0u) - memory_current.orValue(0u)))'
4+
cgroupRankingExpression: 'memory_max.hasValue() ? 0.0 : ({Besteffort: 1.0, Burstable: 0.5, Guaranteed: 0.0, Podruntime: 0.0, System: 0.0}[class] * double(memory_current.orValue(0u)))'
55
sampleInterval: 100ms

pkg/machinery/constants/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ const (
13221322
// DefaultOOMCgroupRankingExpression is the default CEL expression used to rank cgroups for OOM killer.
13231323
DefaultOOMCgroupRankingExpression = `memory_max.hasValue() ? 0.0 :
13241324
{Besteffort: 1.0, Burstable: 0.5, Guaranteed: 0.0, Podruntime: 0.0, System: 0.0}[class] *
1325-
double(memory_current.orValue(0u)) / double(memory_peak.orValue(0u) - memory_current.orValue(0u))`
1325+
double(memory_current.orValue(0u))`
13261326

13271327
// SDStubCmdlineExtraOEMVar is the name of the SMBIOS OEM variable that can be used to pass extra kernel command line parameters to systemd-stub.
13281328
SDStubCmdlineExtraOEMVar = "io.systemd.stub.kernel-cmdline-extra"

website/content/v1.12/reference/configuration/runtime/oomconfig.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ title: OOMConfig
1717
apiVersion: v1alpha1
1818
kind: OOMConfig
1919
triggerExpression: memory_full_avg10 > 12.0 && d_memory_full_avg10 > 0.0 && time_since_trigger > duration("500ms") # This expression defines when to trigger OOM action.
20-
cgroupRankingExpression: 'memory_max.hasValue() ? 0.0 : ({Besteffort: 1.0, Burstable: 0.5, Guaranteed: 0.0, Podruntime: 0.0, System: 0.0}[class] * double(memory_current.orValue(0u)) / double(memory_peak.orValue(0u) - memory_current.orValue(0u)))' # This expression defines how to rank cgroups for OOM handler.
20+
cgroupRankingExpression: 'memory_max.hasValue() ? 0.0 : ({Besteffort: 1.0, Burstable: 0.5, Guaranteed: 0.0, Podruntime: 0.0, System: 0.0}[class] * double(memory_current.orValue(0u)))' # This expression defines how to rank cgroups for OOM handler.
2121
sampleInterval: 100ms # How often should the trigger expression be evaluated.
2222
{{< /highlight >}}
2323

0 commit comments

Comments
 (0)