Commit d99a3da7 authored by Russ Cox's avatar Russ Cox

runtime: a couple more memory stats.

now runtime.MemStats.Sys really is the sum of all the other Sys fields.

R=r
CC=golang-dev
https://golang.org/cl/843041
parent 3908c16f
...@@ -157,6 +157,8 @@ type MemStatsType struct { ...@@ -157,6 +157,8 @@ type MemStatsType struct {
MSpanSys uint64 MSpanSys uint64
MCacheInuse uint64 // mcache structures MCacheInuse uint64 // mcache structures
MCacheSys uint64 MCacheSys uint64
MHeapMapSys uint64 // heap map
BuckHashSys uint64 // profiling bucket hash table
// Garbage collector statistics. // Garbage collector statistics.
NextGC uint64 NextGC uint64
......
...@@ -192,6 +192,8 @@ struct MStats ...@@ -192,6 +192,8 @@ struct MStats
uint64 mspan_sys; uint64 mspan_sys;
uint64 mcache_inuse; // MCache structures uint64 mcache_inuse; // MCache structures
uint64 mcache_sys; uint64 mcache_sys;
uint64 heapmap_sys; // heap map
uint64 buckhash_sys; // profiling bucket hash table
// Statistics about garbage collector. // Statistics about garbage collector.
// Protected by stopping the world during GC. // Protected by stopping the world during GC.
......
...@@ -176,6 +176,7 @@ MHeap_Grow(MHeap *h, uintptr npage) ...@@ -176,6 +176,7 @@ MHeap_Grow(MHeap *h, uintptr npage)
if(v == nil) if(v == nil)
return false; return false;
} }
mstats.heap_sys += ask;
if((byte*)v < h->min || h->min == nil) if((byte*)v < h->min || h->min == nil)
h->min = v; h->min = v;
......
...@@ -84,6 +84,7 @@ MHeapMap_Preallocate(MHeapMap *m, PageID k, uintptr len) ...@@ -84,6 +84,7 @@ MHeapMap_Preallocate(MHeapMap *m, PageID k, uintptr len)
p2 = m->allocator(sizeof *p2); p2 = m->allocator(sizeof *p2);
if(p2 == nil) if(p2 == nil)
return false; return false;
mstats.heapmap_sys += sizeof *p2;
m->p[i1] = p2; m->p[i1] = p2;
} }
......
...@@ -96,6 +96,7 @@ MHeapMap_Preallocate(MHeapMap *m, PageID k, uintptr len) ...@@ -96,6 +96,7 @@ MHeapMap_Preallocate(MHeapMap *m, PageID k, uintptr len)
p2 = m->allocator(sizeof *p2); p2 = m->allocator(sizeof *p2);
if(p2 == nil) if(p2 == nil)
return false; return false;
mstats.heapmap_sys += sizeof *p2;
m->p[i1] = p2; m->p[i1] = p2;
} }
...@@ -104,6 +105,7 @@ MHeapMap_Preallocate(MHeapMap *m, PageID k, uintptr len) ...@@ -104,6 +105,7 @@ MHeapMap_Preallocate(MHeapMap *m, PageID k, uintptr len)
p3 = m->allocator(sizeof *p3); p3 = m->allocator(sizeof *p3);
if(p3 == nil) if(p3 == nil)
return false; return false;
mstats.heapmap_sys += sizeof *p3;
p2->p[i2] = p3; p2->p[i2] = p3;
} }
......
...@@ -44,8 +44,10 @@ stkbucket(uintptr *stk, int32 nstk) ...@@ -44,8 +44,10 @@ stkbucket(uintptr *stk, int32 nstk)
uintptr h; uintptr h;
Bucket *b; Bucket *b;
if(buckhash == nil) if(buckhash == nil) {
buckhash = SysAlloc(BuckHashSize*sizeof buckhash[0]); buckhash = SysAlloc(BuckHashSize*sizeof buckhash[0]);
mstats.buckhash_sys += BuckHashSize*sizeof buckhash[0];
}
// Hash stack. // Hash stack.
h = 0; h = 0;
......
...@@ -88,6 +88,8 @@ func WriteHeapProfile(w io.Writer) os.Error { ...@@ -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, "# Stack = %d / %d\n", s.StackInuse, s.StackSys)
fmt.Fprintf(b, "# MSpan = %d / %d\n", s.MSpanInuse, s.MSpanSys) 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, "# 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, "# NextGC = %d\n", s.NextGC)
fmt.Fprintf(b, "# PauseNs = %d\n", s.PauseNs) fmt.Fprintf(b, "# PauseNs = %d\n", s.PauseNs)
...@@ -96,6 +98,7 @@ func WriteHeapProfile(w io.Writer) os.Error { ...@@ -96,6 +98,7 @@ func WriteHeapProfile(w io.Writer) os.Error {
fmt.Fprintf(b, "# DebugGC = %v\n", s.DebugGC) fmt.Fprintf(b, "# DebugGC = %v\n", s.DebugGC)
fmt.Fprintf(b, "# BySize = Size * (Active = Mallocs - Frees)\n") fmt.Fprintf(b, "# BySize = Size * (Active = Mallocs - Frees)\n")
fmt.Fprintf(b, "# (Excluding large blocks.)\n")
for _, t := range s.BySize { for _, t := range s.BySize {
if t.Mallocs > 0 { if t.Mallocs > 0 {
fmt.Fprintf(b, "# %d * (%d = %d - %d)\n", t.Size, t.Mallocs-t.Frees, t.Mallocs, t.Frees) fmt.Fprintf(b, "# %d * (%d = %d - %d)\n", t.Size, t.Mallocs-t.Frees, t.Mallocs, t.Frees)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment