]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: remove memstats.heap_alloc
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 3 Aug 2020 19:31:23 +0000 (19:31 +0000)
committerMichael Knyszek <mknyszek@google.com>
Mon, 26 Oct 2020 18:20:05 +0000 (18:20 +0000)
memstats.heap_alloc is 100% a duplicate and unnecessary copy of
memstats.alloc which exists because MemStats used to be populated from
memstats via a memmove.

Change-Id: I995489f61be39786e573b8494a8ab6d4ea8bed9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/246975
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>
src/runtime/heapdump.go
src/runtime/mstats.go

index f96475e8486b257bfa783cf280823c3bcab6371f..6fcd9746af9b56dde053614c398506f3c3954592 100644 (file)
@@ -550,7 +550,7 @@ func dumpmemstats() {
        dumpint(memstats.nlookup)
        dumpint(memstats.nmalloc)
        dumpint(memstats.nfree)
-       dumpint(memstats.heap_alloc)
+       dumpint(memstats.alloc)
        dumpint(memstats.heap_sys.load())
        dumpint(memstats.heap_sys.load() - memstats.heap_inuse)
        dumpint(memstats.heap_inuse)
index 43f74273f7c24bc76a479cba48c63ca03e2964a7..a6e38d1c1b5d981843ce43e6ce91969e439b3843 100644 (file)
@@ -32,7 +32,6 @@ type mstats struct {
        //
        // Like MemStats, heap_sys and heap_inuse do not count memory
        // in manually-managed spans.
-       heap_alloc    uint64     // bytes allocated and not yet freed (same as alloc above)
        heap_sys      sysMemStat // virtual address space obtained from system for GC'd heap
        heap_inuse    uint64     // bytes in mSpanInUse spans
        heap_released uint64     // bytes released to the os
@@ -112,11 +111,10 @@ type mstats struct {
 
        // heap_live is the number of bytes considered live by the GC.
        // That is: retained by the most recent GC plus allocated
-       // since then. heap_live <= heap_alloc, since heap_alloc
-       // includes unmarked objects that have not yet been swept (and
-       // hence goes up as we allocate and down as we sweep) while
-       // heap_live excludes these objects (and hence only goes up
-       // between GCs).
+       // since then. heap_live <= alloc, since alloc includes unmarked
+       // objects that have not yet been swept (and hence goes up as we
+       // allocate and down as we sweep) while heap_live excludes these
+       // objects (and hence only goes up between GCs).
        //
        // This is updated atomically without locking. To reduce
        // contention, this is updated only when obtaining a span from
@@ -458,7 +456,7 @@ func readmemstats_m(stats *MemStats) {
        stats.Sys = memstats.sys
        stats.Mallocs = memstats.nmalloc
        stats.Frees = memstats.nfree
-       stats.HeapAlloc = memstats.heap_alloc
+       stats.HeapAlloc = memstats.alloc
        stats.HeapSys = memstats.heap_sys.load()
        // By definition, HeapIdle is memory that was mapped
        // for the heap but is not currently used to hold heap
@@ -639,7 +637,6 @@ func updatememstats() {
        // Calculate derived stats.
        memstats.total_alloc = totalAlloc
        memstats.alloc = totalAlloc - totalFree
-       memstats.heap_alloc = memstats.alloc
        memstats.heap_objects = memstats.nmalloc - memstats.nfree
 }