aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/pprof
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2020-04-29 15:06:21 -0400
committerAustin Clements <austin@google.com>2020-04-29 20:33:31 +0000
commit197a2a3799cebd91ec623616c6b5fac850955b58 (patch)
tree649cc087db59a0557b1db367d73ced96e5adc62c /src/runtime/pprof
parent45cd312394ebbcdce956952f0e269a82d89e6639 (diff)
downloadgo-197a2a3799cebd91ec623616c6b5fac850955b58.tar.gz
go-197a2a3799cebd91ec623616c6b5fac850955b58.zip
runtime/pprof: fix units of MaxRSS on Linux
Rusage.Maxrss is in bytes on Darwin but in KiB on Linux. Fix this discrepancy so it's always in bytes. Change-Id: Ic714abc3276566b8fe5e30565072092212610854 Reviewed-on: https://go-review.googlesource.com/c/go/+/230979 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
Diffstat (limited to 'src/runtime/pprof')
-rw-r--r--src/runtime/pprof/pprof_rusage.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/runtime/pprof/pprof_rusage.go b/src/runtime/pprof/pprof_rusage.go
index 6eaf168444..d42e6ed473 100644
--- a/src/runtime/pprof/pprof_rusage.go
+++ b/src/runtime/pprof/pprof_rusage.go
@@ -9,12 +9,23 @@ package pprof
import (
"fmt"
"io"
+ "runtime"
"syscall"
)
// Adds MaxRSS to platforms that are supported.
func addMaxRSS(w io.Writer) {
+ var rssToBytes uintptr
+ switch runtime.GOOS {
+ case "linux", "android":
+ rssToBytes = 1024
+ case "darwin":
+ rssToBytes = 1
+ default:
+ panic("unsupported OS")
+ }
+
var rusage syscall.Rusage
syscall.Getrusage(0, &rusage)
- fmt.Fprintf(w, "# MaxRSS = %d\n", rusage.Maxrss)
+ fmt.Fprintf(w, "# MaxRSS = %d\n", uintptr(rusage.Maxrss)*rssToBytes)
}