Browse Source

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 <[email protected]>
Jakob Borg 1 month ago
parent
commit
01e2426a56
1 changed files with 7 additions and 1 deletions
  1. 7 1
      cmd/syncthing/perfstats_unix.go

+ 7 - 1
cmd/syncthing/perfstats_unix.go

@@ -16,6 +16,7 @@ import (
 	"syscall"
 	"syscall"
 	"time"
 	"time"
 
 
+	"github.com/syncthing/syncthing/lib/build"
 	"github.com/syncthing/syncthing/lib/locations"
 	"github.com/syncthing/syncthing/lib/locations"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"golang.org/x/exp/constraints"
 	"golang.org/x/exp/constraints"
@@ -48,11 +49,16 @@ func savePerfStats(file string) {
 		in, out := protocol.TotalInOut()
 		in, out := protocol.TotalInOut()
 		timeDiff := t.Sub(prevTime)
 		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",
 		fmt.Fprintf(fd, "%.03f\t%f\t%d\t%d\t%.0f\t%.0f\t%d\n",
 			t.Sub(t0).Seconds(),
 			t.Sub(t0).Seconds(),
 			rate(cpusec(&prevRus), cpusec(&curRus), timeDiff, 1),
 			rate(cpusec(&prevRus), cpusec(&curRus), timeDiff, 1),
 			(curMem.Sys-curMem.HeapReleased)/1024,
 			(curMem.Sys-curMem.HeapReleased)/1024,
-			curRus.Maxrss/1024,
+			rss,
 			rate(prevIn, in, timeDiff, 1e3),
 			rate(prevIn, in, timeDiff, 1e3),
 			rate(prevOut, out, timeDiff, 1e3),
 			rate(prevOut, out, timeDiff, 1e3),
 			dirsize(locations.Get(locations.Database))/1024,
 			dirsize(locations.Get(locations.Database))/1024,