]> Cypherpunks repositories - gostls13.git/commit
runtime: use span.elemsize for accounting in mallocgc
authorMichael Anthony Knyszek <mknyszek@google.com>
Fri, 17 Nov 2023 16:45:45 +0000 (16:45 +0000)
committerMichael Knyszek <mknyszek@google.com>
Fri, 17 Nov 2023 23:15:20 +0000 (23:15 +0000)
commitf67b2d8f0bcadb59461b7a33bc1c23649ce8eb85
tree3b01b755b98676c2c1c5133aefd092d92ac0cefa
parent0b31a46f1fd89b1ede02be9fae920dca6172ffaf
runtime: use span.elemsize for accounting in mallocgc

Currently the final size computed for an object in mallocgc excludes the
allocation header. This is correct in a number of cases, but definitely
wrong for memory profiling because the "free" side accounts for the full
allocation slot.

This change makes an explicit distinction between the parts of mallocgc
that care about the full allocation slot size ("the GC's accounting")
and those that don't (pointer+len should always be valid). It then
applies the appropriate size to the different forms of accounting in
mallocgc.

For #64153.

Change-Id: I481b34b2bb9ff923b59e8408ab2b8fb9025ba944
Reviewed-on: https://go-review.googlesource.com/c/go/+/542735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/arena.go
src/runtime/malloc.go
src/runtime/mgcmark.go