mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: break down memstats.gc_sys
This change breaks apart gc_sys into three distinct pieces. Two of those pieces are pieces which come from heap_sys since they're allocated from the page heap. The rest comes from memory mapped from e.g. persistentalloc which better fits the purpose of a sysMemStat. Also, rename gc_sys to gcMiscSys. Change-Id: I098789170052511e7b31edbcdc9a53e5c24573f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/246973 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
39e335ac06
commit
ad863ba32a
7 changed files with 39 additions and 27 deletions
|
|
@ -713,7 +713,7 @@ func (h *mheap) init() {
|
|||
h.central[i].mcentral.init(spanClass(i))
|
||||
}
|
||||
|
||||
h.pages.init(&h.lock, &memstats.gc_sys)
|
||||
h.pages.init(&h.lock, &memstats.gcMiscSys)
|
||||
}
|
||||
|
||||
// reclaim sweeps and reclaims at least npage pages into the heap.
|
||||
|
|
@ -1230,8 +1230,10 @@ HaveSpan:
|
|||
atomic.Xadd64(&memstats.heap_inuse, int64(nbytes))
|
||||
case spanAllocStack:
|
||||
atomic.Xadd64(&memstats.stacks_inuse, int64(nbytes))
|
||||
case spanAllocPtrScalarBits, spanAllocWorkBuf:
|
||||
memstats.gc_sys.add(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.
|
||||
|
|
@ -1406,8 +1408,10 @@ func (h *mheap) freeSpanLocked(s *mspan, typ spanAllocType) {
|
|||
atomic.Xadd64(&memstats.heap_inuse, -int64(nbytes))
|
||||
case spanAllocStack:
|
||||
atomic.Xadd64(&memstats.stacks_inuse, -int64(nbytes))
|
||||
case spanAllocPtrScalarBits, spanAllocWorkBuf:
|
||||
memstats.gc_sys.add(-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.
|
||||
|
|
@ -1956,7 +1960,7 @@ func newArenaMayUnlock() *gcBitsArena {
|
|||
var result *gcBitsArena
|
||||
if gcBitsArenas.free == nil {
|
||||
unlock(&gcBitsArenas.lock)
|
||||
result = (*gcBitsArena)(sysAlloc(gcBitsChunkBytes, &memstats.gc_sys))
|
||||
result = (*gcBitsArena)(sysAlloc(gcBitsChunkBytes, &memstats.gcMiscSys))
|
||||
if result == nil {
|
||||
throw("runtime: cannot allocate memory")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue