aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorJeremy Faller <jeremy@golang.org>2019-06-25 15:43:33 -0400
committerJeremy Faller <jeremy@golang.org>2020-03-17 15:29:08 +0000
commitfb1cd942225f66a6a8506d28bf317063efe50979 (patch)
tree2e34d9c6c756bb261dcb2e14a21a82add2ea9540 /src/runtime
parent2e918c3aab6cc944380da672b93fb92c67b35de1 (diff)
downloadgo-fb1cd942225f66a6a8506d28bf317063efe50979.tar.xz
runtime/pprof: export max rss when saving memory profiles.
NB: Adds syscall to deps on runtime/pprof. Change-Id: I5dd14c2b25eb9c3c446832f5818de45fafd48a27 Reviewed-on: https://go-review.googlesource.com/c/go/+/183844 Run-TryBot: Jeremy Faller <jeremy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/pprof/pprof.go3
-rw-r--r--src/runtime/pprof/pprof_norusage.go15
-rw-r--r--src/runtime/pprof/pprof_rusage.go20
3 files changed, 38 insertions, 0 deletions
diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go
index bbdc432eec..b4f9ab8f7a 100644
--- a/src/runtime/pprof/pprof.go
+++ b/src/runtime/pprof/pprof.go
@@ -630,6 +630,9 @@ func writeHeapInternal(w io.Writer, debug int, defaultSampleType string) error {
fmt.Fprintf(w, "# GCCPUFraction = %v\n", s.GCCPUFraction)
fmt.Fprintf(w, "# DebugGC = %v\n", s.DebugGC)
+ // Also flush out MaxRSS on supported platforms.
+ addMaxRSS(w)
+
tw.Flush()
return b.Flush()
}
diff --git a/src/runtime/pprof/pprof_norusage.go b/src/runtime/pprof/pprof_norusage.go
new file mode 100644
index 0000000000..6fdcc6cc38
--- /dev/null
+++ b/src/runtime/pprof/pprof_norusage.go
@@ -0,0 +1,15 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !darwin,!linux
+
+package pprof
+
+import (
+ "io"
+)
+
+// Stub call for platforms that don't support rusage.
+func addMaxRSS(w io.Writer) {
+}
diff --git a/src/runtime/pprof/pprof_rusage.go b/src/runtime/pprof/pprof_rusage.go
new file mode 100644
index 0000000000..6eaf168444
--- /dev/null
+++ b/src/runtime/pprof/pprof_rusage.go
@@ -0,0 +1,20 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin linux
+
+package pprof
+
+import (
+ "fmt"
+ "io"
+ "syscall"
+)
+
+// Adds MaxRSS to platforms that are supported.
+func addMaxRSS(w io.Writer) {
+ var rusage syscall.Rusage
+ syscall.Getrusage(0, &rusage)
+ fmt.Fprintf(w, "# MaxRSS = %d\n", rusage.Maxrss)
+}