diff options
| author | Nick Ripley <nick.ripley@datadoghq.com> | 2026-03-27 09:35:51 -0400 |
|---|---|---|
| committer | Nick Ripley <nick.ripley@datadoghq.com> | 2026-03-28 13:07:33 -0700 |
| commit | d247ed00e498e9717fb7c80d126bee5a8afdb4e8 (patch) | |
| tree | 07641e62bb021d5cd34a0ad0a2fc9ea30fbb9c47 /src/internal | |
| parent | 1fd68799c39bd4a3f7e16a1ee24fcaca3efe5357 (diff) | |
| download | go-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/internal')
| -rw-r--r-- | src/internal/profilerecord/profilerecord.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/internal/profilerecord/profilerecord.go b/src/internal/profilerecord/profilerecord.go index a5efdced8f..95581867e1 100644 --- a/src/internal/profilerecord/profilerecord.go +++ b/src/internal/profilerecord/profilerecord.go @@ -13,12 +13,12 @@ type StackRecord struct { } type MemProfileRecord struct { - AllocBytes, FreeBytes int64 + ObjectSize int64 AllocObjects, FreeObjects int64 Stack []uintptr } -func (r *MemProfileRecord) InUseBytes() int64 { return r.AllocBytes - r.FreeBytes } +func (r *MemProfileRecord) InUseBytes() int64 { return r.InUseObjects() * r.ObjectSize } func (r *MemProfileRecord) InUseObjects() int64 { return r.AllocObjects - r.FreeObjects } type BlockProfileRecord struct { |
