Skip to content

Commit

Permalink
runtime/pprof: compute memory profile block size using sampled values
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
aalexand authored and hyangah committed Aug 29, 2018
1 parent c64006a commit f9a4ae0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/runtime/pprof/protomem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/pprof/protomem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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 {
Expand Down

0 comments on commit f9a4ae0

Please sign in to comment.