]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/pprof: compute memory profile block size using sampled values
authorAlexey Alexandrov <aalexand@google.com>
Fri, 27 Jul 2018 07:05:50 +0000 (00:05 -0700)
committerHyang-Ah Hana Kim <hyangah@gmail.com>
Wed, 29 Aug 2018 22:57:14 +0000 (22:57 +0000)
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>

src/runtime/pprof/protomem.go
src/runtime/pprof/protomem_test.go

index 82565d5245bfef1e85f74d53affd214678226f3f..1c88aae43a0aa2da185a012e5b24062b02323b6e 100644 (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 {
index 315d5f0b4d8001da6d69c24e9580cfc0dca4ecfb..471b1ae9c3291c949fdf48c97fba53b8b6ea08c6 100644 (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 {