mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: remove useless heap_objects accounting
This change removes useless additional heap_objects accounting for large objects. heap_objects is computed from scratch at ReadMemStats time (which stops the world) by using nlargealloc and nlargefree, so mutating heap_objects turns out to be pointless. As a result, the "large" parameter on "mheap_.freeSpan" is no longer necessary and so this change cleans that up too. Change-Id: I7d6b486d9b57c018e3db46221d81b55fe4c1b021 Reviewed-on: https://go-review.googlesource.com/c/go/+/196637 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
4208dbef16
commit
814c5058bb
4 changed files with 7 additions and 12 deletions
|
|
@ -926,7 +926,6 @@ func (h *mheap) alloc_m(npage uintptr, spanclass spanClass, large bool) *mspan {
|
|||
// update stats, sweep lists
|
||||
h.pagesInUse += uint64(npage)
|
||||
if large {
|
||||
memstats.heap_objects++
|
||||
mheap_.largealloc += uint64(s.elemsize)
|
||||
mheap_.nlargealloc++
|
||||
atomic.Xadd64(&memstats.heap_live, int64(npage<<_PageShift))
|
||||
|
|
@ -1201,10 +1200,7 @@ func (h *mheap) grow(npage uintptr) bool {
|
|||
}
|
||||
|
||||
// Free the span back into the heap.
|
||||
//
|
||||
// large must match the value of large passed to mheap.alloc. This is
|
||||
// used for accounting.
|
||||
func (h *mheap) freeSpan(s *mspan, large bool) {
|
||||
func (h *mheap) freeSpan(s *mspan) {
|
||||
systemstack(func() {
|
||||
mp := getg().m
|
||||
lock(&h.lock)
|
||||
|
|
@ -1218,10 +1214,6 @@ func (h *mheap) freeSpan(s *mspan, large bool) {
|
|||
bytes := s.npages << _PageShift
|
||||
msanfree(base, bytes)
|
||||
}
|
||||
if large {
|
||||
// Match accounting done in mheap.alloc.
|
||||
memstats.heap_objects--
|
||||
}
|
||||
if gcBlackenEnabled != 0 {
|
||||
// heap_scan changed.
|
||||
gcController.revise()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue