aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/pprof/pprof.go
diff options
context:
space:
mode:
authorNick Ripley <nick.ripley@datadoghq.com>2026-03-27 09:35:51 -0400
committerNick Ripley <nick.ripley@datadoghq.com>2026-03-28 13:07:33 -0700
commitd247ed00e498e9717fb7c80d126bee5a8afdb4e8 (patch)
tree07641e62bb021d5cd34a0ad0a2fc9ea30fbb9c47 /src/runtime/pprof/pprof.go
parent1fd68799c39bd4a3f7e16a1ee24fcaca3efe5357 (diff)
downloadgo-d247ed00e498e9717fb7c80d126bee5a8afdb4e8.tar.xz
runtime: remove redundant fields from memory profile records
The memProfCycle struct holds allocation counts and bytes allocated, and frees and bytes freed. But the memory profile records are already aggregated by allocation size, which is stored in the "size" field of the bucket struct. We can derive the bytes allocated/freed using the counts and the size we already store. Thus we can delete the bytes fields from memProfCycle, saving 64 bytes per memRecord. We can do something similar for the profilerecord.MemProfileRecord type. We just need to know the object size and we can derive the allocated and freed bytes accordingly. Change-Id: I103885c2f29471b25283e330674fc16d6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/760140 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/pprof/pprof.go')
-rw-r--r--src/runtime/pprof/pprof.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go
index d560eeade1..6708d2dfa3 100644
--- a/src/runtime/pprof/pprof.go
+++ b/src/runtime/pprof/pprof.go
@@ -674,9 +674,9 @@ func writeHeapInternal(w io.Writer, debug int, defaultSampleType string) error {
var total runtime.MemProfileRecord
for i := range p {
r := &p[i]
- total.AllocBytes += r.AllocBytes
+ total.AllocBytes += r.AllocObjects * r.ObjectSize
total.AllocObjects += r.AllocObjects
- total.FreeBytes += r.FreeBytes
+ total.FreeBytes += r.FreeObjects * r.ObjectSize
total.FreeObjects += r.FreeObjects
}
@@ -706,7 +706,7 @@ func writeHeapInternal(w io.Writer, debug int, defaultSampleType string) error {
r := &p[i]
fmt.Fprintf(w, "%d: %d [%d: %d] @",
r.InUseObjects(), r.InUseBytes(),
- r.AllocObjects, r.AllocBytes)
+ r.AllocObjects, r.AllocObjects*r.ObjectSize)
for _, pc := range r.Stack {
fmt.Fprintf(w, " %#x", pc)
}