]> Cypherpunks repositories - gostls13.git/commit
runtime/pprof: scale mutex profile samples when they are recorded
authorNick Ripley <nick.ripley@datadoghq.com>
Wed, 12 Oct 2022 14:05:51 +0000 (10:05 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 15 Nov 2022 17:33:07 +0000 (17:33 +0000)
commit30b1af00ff142a3f1a5e2a0f32cf04a649bd5e65
treef1cd79e353098fcfa04ff83e13e34b3ff646eb2b
parent8cca427d17d56cfa7bdf63386bc78cf946ecb5bf
runtime/pprof: scale mutex profile samples when they are recorded

Samples in the mutex profile have their count and duration scaled
according to the probability they were sampled. This is done when the
profile is actually requested. The adjustment is done using to the
current configured sampling rate. However, if the sample rate is changed
after a specific sample is recorded, then the sample will be scaled
incorrectly. In particular, if the sampling rate is changed to 0, all of
the samples in the encoded profile will have 0 count and duration. This
means the profile will be "empty", even if it should have had samples.

This CL scales the samples in the profile when they are recorded, rather
than when the profile is requested. This matches what is currently done
for the block profile.

With this change, neither the block profile nor mutex profile are scaled
when they are encoded, so the logic for scaling the samples can be
removed.

Change-Id: If228cf39284385aa8fb9a2d62492d839e02f027f
Reviewed-on: https://go-review.googlesource.com/c/go/+/443056
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/mprof.go
src/runtime/pprof/pprof.go
src/runtime/pprof/pprof_test.go