]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: clean up inconsistent heap stats
authorMichael Anthony Knyszek <mknyszek@google.com>
Fri, 1 Apr 2022 18:15:24 +0000 (18:15 +0000)
committerMichael Knyszek <mknyszek@google.com>
Tue, 3 May 2022 15:12:31 +0000 (15:12 +0000)
commitd36d5bd3c1906d3581ac4ac0d8a1a0eb4b5b16c4
treeff8470fcd1eded1c8380663c15275f37b4249a23
parent4649a439035a0634109f11f7ac25e4e7184b5598
runtime: clean up inconsistent heap stats

The inconsistent heaps stats in memstats are a bit messy. Primarily,
heap_sys is non-orthogonal with heap_released and heap_inuse. In later
CLs, we're going to want heap_sys-heap_released-heap_inuse, so clean
this up by replacing heap_sys with an orthogonal metric: heapFree.
heapFree represents page heap memory that is free but not released.

I think this change also simplifies a lot of reasoning about these
stats; it's much clearer what they mean, and to obtain HeapSys for
memstats, we no longer need to do the strange subtraction from heap_sys
when allocating specifically non-heap memory from the page heap.

Because we're removing heap_sys, we need to replace it with a sysMemStat
for mem.go functions. In this case, heap_released is the most
appropriate because we increase it anyway (again, non-orthogonality). In
which case, it makes sense for heap_inuse, heap_released, and heapFree
to become more uniform, and to just represent them all as sysMemStats.

While we're here and messing with the types of heap_inuse and
heap_released, let's also fix their names (and last_heap_inuse's name)
up to the more modern Go convention of camelCase.

For #48409.

Change-Id: I87fcbf143b3e36b065c7faf9aa888d86bd11710b
Reviewed-on: https://go-review.googlesource.com/c/go/+/397677
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/runtime/malloc.go
src/runtime/mgc.go
src/runtime/mgcscavenge.go
src/runtime/mheap.go
src/runtime/mstats.go