]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: a couple more memory stats.
authorRuss Cox <rsc@golang.org>
Tue, 30 Mar 2010 00:30:07 +0000 (17:30 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 30 Mar 2010 00:30:07 +0000 (17:30 -0700)
now runtime.MemStats.Sys really is the sum of all the other Sys fields.

R=r
CC=golang-dev
https://golang.org/cl/843041

src/pkg/runtime/extern.go
src/pkg/runtime/malloc.h
src/pkg/runtime/mheap.c
src/pkg/runtime/mheapmap32.c
src/pkg/runtime/mheapmap64.c
src/pkg/runtime/mprof.cgo
src/pkg/runtime/pprof/pprof.go

index bcef7244aa2d95007056a893f442687589021e85..6d98e50db423eaae8517bb920dae62179595a500 100644 (file)
@@ -157,6 +157,8 @@ type MemStatsType struct {
        MSpanSys    uint64
        MCacheInuse uint64 // mcache structures
        MCacheSys   uint64
+       MHeapMapSys uint64 // heap map
+       BuckHashSys uint64 // profiling bucket hash table
 
        // Garbage collector statistics.
        NextGC   uint64
index ff869cacbd5d9dbe2a00cffac14268058b94134b..caed4d3fc4e57ca274d2061876c68b39434f3a4b 100644 (file)
@@ -192,6 +192,8 @@ struct MStats
        uint64  mspan_sys;
        uint64  mcache_inuse;   // MCache structures
        uint64  mcache_sys;
+       uint64  heapmap_sys;    // heap map
+       uint64  buckhash_sys;   // profiling bucket hash table
        
        // Statistics about garbage collector.
        // Protected by stopping the world during GC.
index 1b47b3fe275631e12dd40afa3f69ceb948afd026..44817ddd5abc0c72717ee9f7813c96a157ef01a5 100644 (file)
@@ -176,6 +176,7 @@ MHeap_Grow(MHeap *h, uintptr npage)
                if(v == nil)
                        return false;
        }
+       mstats.heap_sys += ask;
 
        if((byte*)v < h->min || h->min == nil)
                h->min = v;
index 1e3598cbea05a795e1f5181bbce506baa4799914..4481e11f6536ec31771621f1cf66ed00a11355b0 100644 (file)
@@ -84,6 +84,7 @@ MHeapMap_Preallocate(MHeapMap *m, PageID k, uintptr len)
                        p2 = m->allocator(sizeof *p2);
                        if(p2 == nil)
                                return false;
+                       mstats.heapmap_sys += sizeof *p2;
                        m->p[i1] = p2;
                }
 
index 2f856ee179f4484be863fe14a3d55b8b7edd1c99..d5590a2d8430a951aa368fd9b541a0b35e6c7fc2 100644 (file)
@@ -96,6 +96,7 @@ MHeapMap_Preallocate(MHeapMap *m, PageID k, uintptr len)
                        p2 = m->allocator(sizeof *p2);
                        if(p2 == nil)
                                return false;
+                       mstats.heapmap_sys += sizeof *p2;
                        m->p[i1] = p2;
                }
 
@@ -104,6 +105,7 @@ MHeapMap_Preallocate(MHeapMap *m, PageID k, uintptr len)
                        p3 = m->allocator(sizeof *p3);
                        if(p3 == nil)
                                return false;
+                       mstats.heapmap_sys += sizeof *p3;
                        p2->p[i2] = p3;
                }
 
index 50bcaec3c33ee7f7d0001914aa15982f12176a96..0cddb243d290082c2eac0f03f3f6eee9c8a00a91 100644 (file)
@@ -44,8 +44,10 @@ stkbucket(uintptr *stk, int32 nstk)
        uintptr h;
        Bucket *b;
 
-       if(buckhash == nil)
+       if(buckhash == nil) {
                buckhash = SysAlloc(BuckHashSize*sizeof buckhash[0]);
+               mstats.buckhash_sys += BuckHashSize*sizeof buckhash[0];
+       }
 
        // Hash stack.
        h = 0;
index 3a60551283f14cc2d50d2121d902e30ec8834c8a..d0cc730899d3ea22fb3d4ca3522934f5a6d5b580 100644 (file)
@@ -88,6 +88,8 @@ func WriteHeapProfile(w io.Writer) os.Error {
        fmt.Fprintf(b, "# Stack = %d / %d\n", s.StackInuse, s.StackSys)
        fmt.Fprintf(b, "# MSpan = %d / %d\n", s.MSpanInuse, s.MSpanSys)
        fmt.Fprintf(b, "# MCache = %d / %d\n", s.MCacheInuse, s.MCacheSys)
+       fmt.Fprintf(b, "# MHeapMapSys = %d\n", s.MHeapMapSys)
+       fmt.Fprintf(b, "# BuckHashSys = %d\n", s.BuckHashSys)
 
        fmt.Fprintf(b, "# NextGC = %d\n", s.NextGC)
        fmt.Fprintf(b, "# PauseNs = %d\n", s.PauseNs)
@@ -96,6 +98,7 @@ func WriteHeapProfile(w io.Writer) os.Error {
        fmt.Fprintf(b, "# DebugGC = %v\n", s.DebugGC)
 
        fmt.Fprintf(b, "# BySize = Size * (Active = Mallocs - Frees)\n")
+       fmt.Fprintf(b, "# (Excluding large blocks.)\n")
        for _, t := range s.BySize {
                if t.Mallocs > 0 {
                        fmt.Fprintf(b, "#   %d * (%d = %d - %d)\n", t.Size, t.Mallocs-t.Frees, t.Mallocs, t.Frees)