1
0
mirror of https://github.com/golang/go synced 2024-11-23 21:00:06 -07:00

runtime/pprof: compute memory profile block size using sampled values

Fixes #26638.

Change-Id: I3c18d1298d99af8ea8c00916303efd2b5a5effc7
Reviewed-on: https://go-review.googlesource.com/126336
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Alexey Alexandrov 2018-07-27 00:05:50 -07:00 committed by Hyang-Ah Hana Kim
parent c64006ab5d
commit f9a4ae018d
2 changed files with 4 additions and 4 deletions

View File

@ -56,8 +56,8 @@ func writeHeapProto(w io.Writer, p []runtime.MemProfileRecord, rate int64, defau
values[0], values[1] = scaleHeapSample(r.AllocObjects, r.AllocBytes, rate)
values[2], values[3] = scaleHeapSample(r.InUseObjects(), r.InUseBytes(), rate)
var blockSize int64
if values[0] > 0 {
blockSize = values[1] / values[0]
if r.AllocObjects > 0 {
blockSize = r.AllocBytes / r.AllocObjects
}
b.pbSample(values, locs, func() {
if blockSize != 0 {

View File

@ -48,7 +48,7 @@ func TestConvertMemProfile(t *testing.T) {
{ID: 3, Mapping: map2, Address: addr2 + 1},
{ID: 4, Mapping: map2, Address: addr2 + 2},
},
NumLabel: map[string][]int64{"bytes": {829411}},
NumLabel: map[string][]int64{"bytes": {512 * 1024}},
},
{
Value: []int64{1, 829411, 0, 0},
@ -57,7 +57,7 @@ func TestConvertMemProfile(t *testing.T) {
{ID: 6, Mapping: map1, Address: addr1 + 2},
{ID: 7, Mapping: map2, Address: addr2 + 3},
},
NumLabel: map[string][]int64{"bytes": {829411}},
NumLabel: map[string][]int64{"bytes": {512 * 1024}},
},
}
for _, tc := range []struct {