aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/pprof
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2022-02-03 14:12:08 -0500
committerRuss Cox <rsc@golang.org>2022-04-11 16:34:30 +0000
commit19309779ac5e2f5a2fd3cbb34421dafb2855ac21 (patch)
tree67dfd3e5d96250325e383183f95b6f5fe1968514 /src/runtime/pprof
parent017933163ab6a2b254f0310c61b57db65cded92e (diff)
downloadgo-19309779ac5e2f5a2fd3cbb34421dafb2855ac21.tar.xz
all: gofmt main repo
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/pprof')
-rw-r--r--src/runtime/pprof/pprof.go64
-rw-r--r--src/runtime/pprof/proto.go14
2 files changed, 40 insertions, 38 deletions
diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go
index e3cd6b9d2a..f0b25c131f 100644
--- a/src/runtime/pprof/pprof.go
+++ b/src/runtime/pprof/pprof.go
@@ -5,7 +5,7 @@
// Package pprof writes runtime profiling data in the format expected
// by the pprof visualization tool.
//
-// Profiling a Go program
+// # Profiling a Go program
//
// The first step to profiling a Go program is to enable profiling.
// Support for profiling benchmarks built with the standard testing
@@ -13,54 +13,54 @@
// runs benchmarks in the current directory and writes the CPU and
// memory profiles to cpu.prof and mem.prof:
//
-// go test -cpuprofile cpu.prof -memprofile mem.prof -bench .
+// go test -cpuprofile cpu.prof -memprofile mem.prof -bench .
//
// To add equivalent profiling support to a standalone program, add
// code like the following to your main function:
//
-// var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`")
-// var memprofile = flag.String("memprofile", "", "write memory profile to `file`")
+// var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`")
+// var memprofile = flag.String("memprofile", "", "write memory profile to `file`")
//
-// func main() {
-// flag.Parse()
-// if *cpuprofile != "" {
-// f, err := os.Create(*cpuprofile)
-// if err != nil {
-// log.Fatal("could not create CPU profile: ", err)
-// }
-// defer f.Close() // error handling omitted for example
-// if err := pprof.StartCPUProfile(f); err != nil {
-// log.Fatal("could not start CPU profile: ", err)
-// }
-// defer pprof.StopCPUProfile()
-// }
+// func main() {
+// flag.Parse()
+// if *cpuprofile != "" {
+// f, err := os.Create(*cpuprofile)
+// if err != nil {
+// log.Fatal("could not create CPU profile: ", err)
+// }
+// defer f.Close() // error handling omitted for example
+// if err := pprof.StartCPUProfile(f); err != nil {
+// log.Fatal("could not start CPU profile: ", err)
+// }
+// defer pprof.StopCPUProfile()
+// }
//
-// // ... rest of the program ...
+// // ... rest of the program ...
//
-// if *memprofile != "" {
-// f, err := os.Create(*memprofile)
-// if err != nil {
-// log.Fatal("could not create memory profile: ", err)
-// }
-// defer f.Close() // error handling omitted for example
-// runtime.GC() // get up-to-date statistics
-// if err := pprof.WriteHeapProfile(f); err != nil {
-// log.Fatal("could not write memory profile: ", err)
-// }
-// }
-// }
+// if *memprofile != "" {
+// f, err := os.Create(*memprofile)
+// if err != nil {
+// log.Fatal("could not create memory profile: ", err)
+// }
+// defer f.Close() // error handling omitted for example
+// runtime.GC() // get up-to-date statistics
+// if err := pprof.WriteHeapProfile(f); err != nil {
+// log.Fatal("could not write memory profile: ", err)
+// }
+// }
+// }
//
// There is also a standard HTTP interface to profiling data. Adding
// the following line will install handlers under the /debug/pprof/
// URL to download live profiles:
//
-// import _ "net/http/pprof"
+// import _ "net/http/pprof"
//
// See the net/http/pprof package for more details.
//
// Profiles can then be visualized with the pprof tool:
//
-// go tool pprof cpu.prof
+// go tool pprof cpu.prof
//
// There are many commands available from the pprof command line.
// Commonly used commands include "top", which prints a summary of the
diff --git a/src/runtime/pprof/proto.go b/src/runtime/pprof/proto.go
index 68dac42d20..f0769935ae 100644
--- a/src/runtime/pprof/proto.go
+++ b/src/runtime/pprof/proto.go
@@ -56,9 +56,10 @@ type memMap struct {
}
// symbolizeFlag keeps track of symbolization result.
-// 0 : no symbol lookup was performed
-// 1<<0 (lookupTried) : symbol lookup was performed
-// 1<<1 (lookupFailed): symbol lookup was performed but failed
+//
+// 0 : no symbol lookup was performed
+// 1<<0 (lookupTried) : symbol lookup was performed
+// 1<<1 (lookupFailed): symbol lookup was performed but failed
type symbolizeFlag uint8
const (
@@ -507,9 +508,10 @@ func (b *profileBuilder) appendLocsForStack(locs []uint64, stk []uintptr) (newLo
// and looking up debug info is not ideal, so we use a heuristic to filter
// the fake pcs and restore the inlined and entry functions. Inlined functions
// have the following properties:
-// Frame's Func is nil (note: also true for non-Go functions), and
-// Frame's Entry matches its entry function frame's Entry (note: could also be true for recursive calls and non-Go functions), and
-// Frame's Name does not match its entry function frame's name (note: inlined functions cannot be directly recursive).
+//
+// Frame's Func is nil (note: also true for non-Go functions), and
+// Frame's Entry matches its entry function frame's Entry (note: could also be true for recursive calls and non-Go functions), and
+// Frame's Name does not match its entry function frame's name (note: inlined functions cannot be directly recursive).
//
// As reading and processing the pcs in a stack trace one by one (from leaf to the root),
// we use pcDeck to temporarily hold the observed pcs and their expanded frames