Commit f9a4ae01 authored by Alexey Alexandrov's avatar Alexey Alexandrov Committed by Hyang-Ah Hana Kim

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

Fixes #26638.

Change-Id: I3c18d1298d99af8ea8c00916303efd2b5a5effc7
Reviewed-on: https://go-review.googlesource.com/126336Reviewed-by: default avatarHyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent c64006ab
...@@ -56,8 +56,8 @@ func writeHeapProto(w io.Writer, p []runtime.MemProfileRecord, rate int64, defau ...@@ -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[0], values[1] = scaleHeapSample(r.AllocObjects, r.AllocBytes, rate)
values[2], values[3] = scaleHeapSample(r.InUseObjects(), r.InUseBytes(), rate) values[2], values[3] = scaleHeapSample(r.InUseObjects(), r.InUseBytes(), rate)
var blockSize int64 var blockSize int64
if values[0] > 0 { if r.AllocObjects > 0 {
blockSize = values[1] / values[0] blockSize = r.AllocBytes / r.AllocObjects
} }
b.pbSample(values, locs, func() { b.pbSample(values, locs, func() {
if blockSize != 0 { if blockSize != 0 {
......
...@@ -48,7 +48,7 @@ func TestConvertMemProfile(t *testing.T) { ...@@ -48,7 +48,7 @@ func TestConvertMemProfile(t *testing.T) {
{ID: 3, Mapping: map2, Address: addr2 + 1}, {ID: 3, Mapping: map2, Address: addr2 + 1},
{ID: 4, Mapping: map2, Address: addr2 + 2}, {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}, Value: []int64{1, 829411, 0, 0},
...@@ -57,7 +57,7 @@ func TestConvertMemProfile(t *testing.T) { ...@@ -57,7 +57,7 @@ func TestConvertMemProfile(t *testing.T) {
{ID: 6, Mapping: map1, Address: addr1 + 2}, {ID: 6, Mapping: map1, Address: addr1 + 2},
{ID: 7, Mapping: map2, Address: addr2 + 3}, {ID: 7, Mapping: map2, Address: addr2 + 3},
}, },
NumLabel: map[string][]int64{"bytes": {829411}}, NumLabel: map[string][]int64{"bytes": {512 * 1024}},
}, },
} }
for _, tc := range []struct { for _, tc := range []struct {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment