1
0
mirror of https://github.com/golang/go synced 2024-11-22 03:04:41 -07:00

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
This commit is contained in:
Russ Cox 2010-03-29 17:30:07 -07:00
parent 3908c16ffe
commit d99a3da7b2
7 changed files with 14 additions and 1 deletions

View 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

View 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.

View 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;

View 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;
}

View 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;
}

View 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;

View 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)