]> Cypherpunks repositories - gostls13.git/commit
runtime/pprof: remove hard-coded sleep in CPU profile reader
authorNick Ripley <nick.ripley@datadoghq.com>
Fri, 21 Nov 2025 16:01:29 +0000 (16:01 +0000)
committerNick Ripley <nick.ripley@datadoghq.com>
Fri, 21 Nov 2025 21:25:29 +0000 (13:25 -0800)
commit121bc3e464b901327a5c138d8a992bb85c440862
treee3fd8bb4869b0033cae4c8be8beef7188d85eddd
parentb604148c4e8ad61640d12cde40379bc3c137d8a6
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>
src/runtime/pprof/pprof.go
src/runtime/profbuf.go
src/runtime/profbuf_test.go