From 6eef4e5824b940c7aaef4e855ec48b6e73056a3c Mon Sep 17 00:00:00 2001 From: Chris Austin Date: Mon, 26 Jun 2023 10:04:04 -0700 Subject: [PATCH 1/3] Average RSS and VMS memory metrics --- src/core/metrics/metrics_util.go | 4 ++-- src/core/metrics/sources/nginx_worker.go | 14 ++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/core/metrics/metrics_util.go b/src/core/metrics/metrics_util.go index fef2ecd38..02f46655e 100644 --- a/src/core/metrics/metrics_util.go +++ b/src/core/metrics/metrics_util.go @@ -242,8 +242,8 @@ func GetCalculationMap() map[string]string { "nginx.workers.cpu.system": "sum", "nginx.workers.cpu.total": "sum", "nginx.workers.fds_count": "avg", - "nginx.workers.mem.vms": "sum", - "nginx.workers.mem.rss": "sum", + "nginx.workers.mem.vms": "avg", + "nginx.workers.mem.rss": "avg", "nginx.workers.mem.rss_pct": "avg", "nginx.workers.io.kbs_r": "sum", "nginx.workers.io.kbs_w": "sum", diff --git a/src/core/metrics/sources/nginx_worker.go b/src/core/metrics/sources/nginx_worker.go index ff619e2c4..99b0d0882 100644 --- a/src/core/metrics/sources/nginx_worker.go +++ b/src/core/metrics/sources/nginx_worker.go @@ -86,16 +86,6 @@ func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- cpuSystem = stats.Workers.CPUSystem } - memRss := stats.Workers.MemRss - c.prevStats[pid].Workers.MemRss - if stats.Workers.MemRss < c.prevStats[pid].Workers.MemRss { - memRss = stats.Workers.MemRss - } - - memVms := stats.Workers.MemVms - c.prevStats[pid].Workers.MemVms - if stats.Workers.MemVms < c.prevStats[pid].Workers.MemVms { - memVms = stats.Workers.MemVms - } - KbsR := stats.Workers.KbsR - c.prevStats[pid].Workers.KbsR if stats.Workers.KbsR < c.prevStats[pid].Workers.KbsR { KbsR = stats.Workers.KbsR @@ -113,8 +103,8 @@ func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- "cpu.system": float64(cpuSystem), "cpu.total": float64(cpuSystem + cpuUser), "fds_count": float64(stats.Workers.FdsCount), - "mem.vms": float64(memVms), - "mem.rss": float64(memRss), + "mem.vms": float64(stats.Workers.MemVms), + "mem.rss": float64(stats.Workers.MemRss), "mem.rss_pct": float64(stats.Workers.MemRssPct), "io.kbs_r": float64(KbsR), "io.kbs_w": float64(KbsW), From b4fc85e455acdeedf2269c85f4ce8c9ff45a5ae5 Mon Sep 17 00:00:00 2001 From: Oliver O'Mahony Date: Tue, 27 Jun 2023 16:56:42 +0100 Subject: [PATCH 2/3] deps on vendoring --- .../agent/v2/src/core/metrics/metrics_util.go | 4 ++-- .../v2/src/core/metrics/sources/nginx_worker.go | 14 ++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go index fef2ecd38..02f46655e 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go @@ -242,8 +242,8 @@ func GetCalculationMap() map[string]string { "nginx.workers.cpu.system": "sum", "nginx.workers.cpu.total": "sum", "nginx.workers.fds_count": "avg", - "nginx.workers.mem.vms": "sum", - "nginx.workers.mem.rss": "sum", + "nginx.workers.mem.vms": "avg", + "nginx.workers.mem.rss": "avg", "nginx.workers.mem.rss_pct": "avg", "nginx.workers.io.kbs_r": "sum", "nginx.workers.io.kbs_w": "sum", diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go index ff619e2c4..99b0d0882 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go @@ -86,16 +86,6 @@ func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- cpuSystem = stats.Workers.CPUSystem } - memRss := stats.Workers.MemRss - c.prevStats[pid].Workers.MemRss - if stats.Workers.MemRss < c.prevStats[pid].Workers.MemRss { - memRss = stats.Workers.MemRss - } - - memVms := stats.Workers.MemVms - c.prevStats[pid].Workers.MemVms - if stats.Workers.MemVms < c.prevStats[pid].Workers.MemVms { - memVms = stats.Workers.MemVms - } - KbsR := stats.Workers.KbsR - c.prevStats[pid].Workers.KbsR if stats.Workers.KbsR < c.prevStats[pid].Workers.KbsR { KbsR = stats.Workers.KbsR @@ -113,8 +103,8 @@ func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- "cpu.system": float64(cpuSystem), "cpu.total": float64(cpuSystem + cpuUser), "fds_count": float64(stats.Workers.FdsCount), - "mem.vms": float64(memVms), - "mem.rss": float64(memRss), + "mem.vms": float64(stats.Workers.MemVms), + "mem.rss": float64(stats.Workers.MemRss), "mem.rss_pct": float64(stats.Workers.MemRssPct), "io.kbs_r": float64(KbsR), "io.kbs_w": float64(KbsW), From 732ff236fd9a7eb834d2e76b5d80438d81365871 Mon Sep 17 00:00:00 2001 From: Chris Austin Date: Fri, 30 Jun 2023 08:01:53 -0700 Subject: [PATCH 3/3] Update unit tests for average mem metrics --- src/core/metrics/sources/nginx_worker_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/metrics/sources/nginx_worker_test.go b/src/core/metrics/sources/nginx_worker_test.go index 1f9959a87..119377df2 100644 --- a/src/core/metrics/sources/nginx_worker_test.go +++ b/src/core/metrics/sources/nginx_worker_test.go @@ -108,7 +108,7 @@ func TestNginxWorkerCollector(t *testing.T) { case "nginx.workers.io.kbs_r": assert.Equal(t, float64(0), metric.Value) case "nginx.workers.mem.rss": - assert.Equal(t, float64(0), metric.Value) + assert.Equal(t, float64(1), metric.Value) case "nginx.workers.mem.rss_pct": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.rlimit_nofile": @@ -116,7 +116,7 @@ func TestNginxWorkerCollector(t *testing.T) { case "nginx.workers.count": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.mem.vms": - assert.Equal(t, float64(0), metric.Value) + assert.Equal(t, float64(1), metric.Value) case "nginx.workers.fds_count": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.cpu.user": @@ -148,7 +148,7 @@ func TestNginxWorkerCollector(t *testing.T) { case "nginx.workers.io.kbs_r": assert.Equal(t, float64(0), metric.Value) case "nginx.workers.mem.rss": - assert.Equal(t, float64(0), metric.Value) + assert.Equal(t, float64(1), metric.Value) case "nginx.workers.mem.rss_pct": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.rlimit_nofile": @@ -156,7 +156,7 @@ func TestNginxWorkerCollector(t *testing.T) { case "nginx.workers.count": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.mem.vms": - assert.Equal(t, float64(0), metric.Value) + assert.Equal(t, float64(1), metric.Value) case "nginx.workers.fds_count": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.cpu.user":