From 01e2426a5646530d3aed647f8195064f1e6bb704 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 3 Sep 2025 07:52:01 +0200 Subject: [PATCH] fix(syncthing): properly report kibibytes RSS in Linux perfstats The value from getrusage is already in KiB, while on macOS it's in bytes. Signed-off-by: Jakob Borg --- cmd/syncthing/perfstats_unix.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/syncthing/perfstats_unix.go b/cmd/syncthing/perfstats_unix.go index 81cf2fe7a..890320b94 100644 --- a/cmd/syncthing/perfstats_unix.go +++ b/cmd/syncthing/perfstats_unix.go @@ -16,6 +16,7 @@ import ( "syscall" "time" + "github.com/syncthing/syncthing/lib/build" "github.com/syncthing/syncthing/lib/locations" "github.com/syncthing/syncthing/lib/protocol" "golang.org/x/exp/constraints" @@ -48,11 +49,16 @@ func savePerfStats(file string) { in, out := protocol.TotalInOut() timeDiff := t.Sub(prevTime) + rss := curRus.Maxrss + if build.IsDarwin { + rss /= 1024 + } + fmt.Fprintf(fd, "%.03f\t%f\t%d\t%d\t%.0f\t%.0f\t%d\n", t.Sub(t0).Seconds(), rate(cpusec(&prevRus), cpusec(&curRus), timeDiff, 1), (curMem.Sys-curMem.HeapReleased)/1024, - curRus.Maxrss/1024, + rss, rate(prevIn, in, timeDiff, 1e3), rate(prevOut, out, timeDiff, 1e3), dirsize(locations.Get(locations.Database))/1024,