aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/debug.go
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2012-10-06 12:56:04 +0400
committerDmitriy Vyukov <dvyukov@google.com>2012-10-06 12:56:04 +0400
commit4cc7bf326a26d3cc18f049424729784812fe16b6 (patch)
treeb99cc48fdbedb23bd355dc8ce1a1d0a11debe873 /src/pkg/runtime/debug.go
parentebb0e5db758791966a1afb193ddb021d4250d5d6 (diff)
downloadgo-4cc7bf326a26d3cc18f049424729784812fe16b6.tar.xz
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
Diffstat (limited to 'src/pkg/runtime/debug.go')
-rw-r--r--src/pkg/runtime/debug.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/pkg/runtime/debug.go b/src/pkg/runtime/debug.go
index b802fc63f7..e9d7601710 100644
--- a/src/pkg/runtime/debug.go
+++ b/src/pkg/runtime/debug.go
@@ -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