diff options
| author | Nick Ripley <nick.ripley@datadoghq.com> | 2025-11-21 16:01:29 +0000 |
|---|---|---|
| committer | Nick Ripley <nick.ripley@datadoghq.com> | 2025-11-21 13:25:29 -0800 |
| commit | 121bc3e464b901327a5c138d8a992bb85c440862 (patch) | |
| tree | e3fd8bb4869b0033cae4c8be8beef7188d85eddd /src/runtime/pprof/pprof.go | |
| parent | b604148c4e8ad61640d12cde40379bc3c137d8a6 (diff) | |
| download | go-121bc3e464b901327a5c138d8a992bb85c440862.tar.xz | |
runtime/pprof: remove hard-coded sleep in CPU profile reader
The CPU profiler reader goroutine has a hard-coded 100ms sleep between
reads of the CPU profile sample buffer. This is done because waking up
the CPU profile reader is not signal-safe on some platforms. As a
consequence, stopping the profiler takes 200ms (one iteration to read
the last samples and one to see the "eof"), and on many-core systems the
reader does not wake up frequently enought to keep up with incoming
data.
This CL removes the sleep where it is safe to do so, following a
suggestion by Austin Clements in the comments on CL 445375. We let the
reader fully block, and wake up the reader when the buffer is over
half-full.
Fixes #63043
Updates #56029
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-arm64-longtest,gotip-linux-386-longtest
Change-Id: I9f7e7e9918a4a6f16e80f6aaf33103126568a81f
Reviewed-on: https://go-review.googlesource.com/c/go/+/610815
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Diffstat (limited to 'src/runtime/pprof/pprof.go')
| -rw-r--r-- | src/runtime/pprof/pprof.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go index 78d00af6ca..c617a8b26a 100644 --- a/src/runtime/pprof/pprof.go +++ b/src/runtime/pprof/pprof.go @@ -924,7 +924,10 @@ func profileWriter(w io.Writer) { b := newProfileBuilder(w) var err error for { - time.Sleep(100 * time.Millisecond) + if runtime.GOOS == "darwin" || runtime.GOOS == "ios" { + // see runtime_pprof_readProfile + time.Sleep(100 * time.Millisecond) + } data, tags, eof := readProfile() if e := b.addCPUData(data, tags); e != nil && err == nil { err = e |
