mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
pprof: add goroutine blocking profiling
The profiler collects goroutine blocking information similar to Google Perf Tools. You may see an example of the profile (converted to svg) attached to http://code.google.com/p/go/issues/detail?id=3946 The public API changes are: +pkg runtime, func BlockProfile([]BlockProfileRecord) (int, bool) +pkg runtime, func SetBlockProfileRate(int) +pkg runtime, method (*BlockProfileRecord) Stack() []uintptr +pkg runtime, type BlockProfileRecord struct +pkg runtime, type BlockProfileRecord struct, Count int64 +pkg runtime, type BlockProfileRecord struct, Cycles int64 +pkg runtime, type BlockProfileRecord struct, embedded StackRecord R=rsc, dave, minux.ma, r CC=gobot, golang-dev, r, remyoudompheng https://golang.org/cl/6443115
This commit is contained in:
parent
ebb0e5db75
commit
4cc7bf326a
12 changed files with 350 additions and 52 deletions
|
|
@ -138,6 +138,31 @@ func CPUProfile() []byte
|
|||
// SetCPUProfileRate directly.
|
||||
func SetCPUProfileRate(hz int)
|
||||
|
||||
// SetBlockProfileRate controls the fraction of goroutine blocking events
|
||||
// that are reported in the blocking profile. The profiler aims to sample
|
||||
// an average of one blocking event per rate nanoseconds spent blocked.
|
||||
//
|
||||
// To include every blocking event in the profile, pass rate = 1.
|
||||
// To turn off profiling entirely, pass rate <= 0.
|
||||
func SetBlockProfileRate(rate int)
|
||||
|
||||
// BlockProfileRecord describes blocking events originated
|
||||
// at a particular call sequence (stack trace).
|
||||
type BlockProfileRecord struct {
|
||||
Count int64
|
||||
Cycles int64
|
||||
StackRecord
|
||||
}
|
||||
|
||||
// BlockProfile returns n, the number of records in the current blocking profile.
|
||||
// If len(p) >= n, BlockProfile copies the profile into p and returns n, true.
|
||||
// If len(p) < n, BlockProfile does not change p and returns n, false.
|
||||
//
|
||||
// Most clients should use the runtime/pprof package or
|
||||
// the testing package's -test.blockprofile flag instead
|
||||
// of calling BlockProfile directly.
|
||||
func BlockProfile(p []BlockProfileRecord) (n int, ok bool)
|
||||
|
||||
// Stack formats a stack trace of the calling goroutine into buf
|
||||
// and returns the number of bytes written to buf.
|
||||
// If all is true, Stack formats stack traces of all other goroutines
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue