Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the way memory RSS is calculated for cgroupv2 #40

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion collector/cgroupv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (e *Exporter) getMetricsv2(name string, pids []int, opts cgroup2.InitOpts)
return metric, err
}
if stats.Memory != nil {
metric.memoryRSS = float64(stats.Memory.Anon) + swapcached + float64(stats.Memory.AnonThp)
metric.memoryRSS = float64(stats.Memory.Anon) + swapcached + float64(stats.Memory.File)
metric.memoryUsed = float64(stats.Memory.Usage)
metric.memoryTotal = float64(stats.Memory.UsageLimit)
metric.memoryCache = float64(stats.Memory.File)
Expand Down
4 changes: 2 additions & 2 deletions collector/cgroupv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestCollectv2UserSlice(t *testing.T) {
if val := metrics[0].cpus; val != 0 {
t.Errorf("Unexpected value for cpus, got %v", val)
}
if val := metrics[0].memoryRSS; val != 22048768 {
if val := metrics[0].memoryRSS; val != 22626304 {
t.Errorf("Unexpected value for memoryRSS, got %v", val)
}
if val := metrics[0].memoryUsed; val != 27115520 {
Expand Down Expand Up @@ -184,7 +184,7 @@ func TestCollectv2SLURM(t *testing.T) {
if val := m.cpus; val != 1 {
t.Errorf("Unexpected value for cpus, got %v", val)
}
if val := m.memoryRSS; val != 2260992 {
if val := m.memoryRSS; val != 2777088 {
t.Errorf("Unexpected value for memoryRSS, got %v", val)
}
if val := m.memoryUsed; val != 5660672 {
Expand Down
Loading