mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
pprof: improve sampling for heap profiling
The current heap sampling introduces some bias that interferes with unsampling, producing unexpected heap profiles. The solution is to use a Poisson process to generate the sampling points, using the formulas described at https://en.wikipedia.org/wiki/Poisson_process This fixes #12620 Change-Id: If2400809ed3c41de504dd6cff06be14e476ff96c Reviewed-on: https://go-review.googlesource.com/14590 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Minux Ma <minux@golang.org> Run-TryBot: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
0357c38adf
commit
27ee719fb3
9 changed files with 361 additions and 28 deletions
|
|
@ -69,16 +69,7 @@ func allocmcache() *mcache {
|
|||
for i := 0; i < _NumSizeClasses; i++ {
|
||||
c.alloc[i] = &emptymspan
|
||||
}
|
||||
|
||||
// Set first allocation sample size.
|
||||
rate := MemProfileRate
|
||||
if rate > 0x3fffffff { // make 2*rate not overflow
|
||||
rate = 0x3fffffff
|
||||
}
|
||||
if rate != 0 {
|
||||
c.next_sample = int32(int(fastrand1()) % (2 * rate))
|
||||
}
|
||||
|
||||
c.next_sample = nextSample()
|
||||
return c
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue