mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: replace some memstats with consistent stats
This change replaces stacks_inuse, gcWorkBufInUse and gcProgPtrScalarBitsInUse with their corresponding consistent stats. It also adds checks to make sure the rest of the sharded stats line up with existing stats in updatememstats. Change-Id: I17d0bd181aedb5c55e09c8dff18cef5b2a3a14e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/247038 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
fe7ff71185
commit
f77a9025f1
2 changed files with 62 additions and 29 deletions
|
|
@ -1225,15 +1225,8 @@ HaveSpan:
|
|||
atomic.Xadd64(&memstats.heap_released, -int64(scav))
|
||||
}
|
||||
// Update stats.
|
||||
switch typ {
|
||||
case spanAllocHeap:
|
||||
if typ == spanAllocHeap {
|
||||
atomic.Xadd64(&memstats.heap_inuse, int64(nbytes))
|
||||
case spanAllocStack:
|
||||
atomic.Xadd64(&memstats.stacks_inuse, int64(nbytes))
|
||||
case spanAllocWorkBuf:
|
||||
atomic.Xadd64(&memstats.gcWorkBufInUse, int64(nbytes))
|
||||
case spanAllocPtrScalarBits:
|
||||
atomic.Xadd64(&memstats.gcProgPtrScalarBitsInUse, int64(nbytes))
|
||||
}
|
||||
if typ.manual() {
|
||||
// Manually managed memory doesn't count toward heap_sys.
|
||||
|
|
@ -1421,15 +1414,8 @@ func (h *mheap) freeSpanLocked(s *mspan, typ spanAllocType) {
|
|||
//
|
||||
// Mirrors the code in allocSpan.
|
||||
nbytes := s.npages * pageSize
|
||||
switch typ {
|
||||
case spanAllocHeap:
|
||||
if typ == spanAllocHeap {
|
||||
atomic.Xadd64(&memstats.heap_inuse, -int64(nbytes))
|
||||
case spanAllocStack:
|
||||
atomic.Xadd64(&memstats.stacks_inuse, -int64(nbytes))
|
||||
case spanAllocWorkBuf:
|
||||
atomic.Xadd64(&memstats.gcWorkBufInUse, -int64(nbytes))
|
||||
case spanAllocPtrScalarBits:
|
||||
atomic.Xadd64(&memstats.gcProgPtrScalarBitsInUse, -int64(nbytes))
|
||||
}
|
||||
if typ.manual() {
|
||||
// Manually managed memory doesn't count toward heap_sys, so add it back.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue