mirror of
https://github.com/golang/go
synced 2024-11-17 15:14:42 -07:00
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>
This commit is contained in:
parent
2e918c3aab
commit
fb1cd94222
@ -195,7 +195,7 @@ var pkgDeps = map[string][]string{
|
||||
"regexp": {"L2", "regexp/syntax"},
|
||||
"regexp/syntax": {"L2"},
|
||||
"runtime/debug": {"L2", "fmt", "io/ioutil", "os", "time"},
|
||||
"runtime/pprof": {"L2", "compress/gzip", "context", "encoding/binary", "fmt", "io/ioutil", "os", "text/tabwriter", "time"},
|
||||
"runtime/pprof": {"L2", "compress/gzip", "context", "encoding/binary", "fmt", "io/ioutil", "os", "syscall", "text/tabwriter", "time"},
|
||||
"runtime/trace": {"L0", "context", "fmt"},
|
||||
"text/tabwriter": {"L2"},
|
||||
|
||||
|
@ -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()
|
||||
}
|
||||
|
15
src/runtime/pprof/pprof_norusage.go
Normal file
15
src/runtime/pprof/pprof_norusage.go
Normal file
@ -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) {
|
||||
}
|
20
src/runtime/pprof/pprof_rusage.go
Normal file
20
src/runtime/pprof/pprof_rusage.go
Normal file
@ -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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user