summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-03-29 17:30:07 -0700
committerRuss Cox <rsc@golang.org>2010-03-29 17:30:07 -0700
commit218421ebcdaee59bac41af0fbdf50a525d5b5f52 (patch)
treec8b2e90bb30a9a9749c06f3e03980cbd4467ebd5 /src
parent7f29727c0c5c3e6f12cadbfe988a3edade1d4e2a (diff)
downloadgolang-218421ebcdaee59bac41af0fbdf50a525d5b5f52.tar.gz
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 http://codereview.appspot.com/843041
Diffstat (limited to 'src')
-rw-r--r--src/pkg/runtime/extern.go2
-rw-r--r--src/pkg/runtime/malloc.h2
-rw-r--r--src/pkg/runtime/mheap.c1
-rw-r--r--src/pkg/runtime/mheapmap32.c1
-rw-r--r--src/pkg/runtime/mheapmap64.c2
-rw-r--r--src/pkg/runtime/mprof.cgo4
-rw-r--r--src/pkg/runtime/pprof/pprof.go3
7 files changed, 14 insertions, 1 deletions
diff --git a/src/pkg/runtime/extern.go b/src/pkg/runtime/extern.go
index bcef7244a..6d98e50db 100644
--- a/src/pkg/runtime/extern.go
+++ b/src/pkg/runtime/extern.go
@@ -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
diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h
index ff869cacb..caed4d3fc 100644
--- a/src/pkg/runtime/malloc.h
+++ b/src/pkg/runtime/malloc.h
@@ -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.
diff --git a/src/pkg/runtime/mheap.c b/src/pkg/runtime/mheap.c
index 1b47b3fe2..44817ddd5 100644
--- a/src/pkg/runtime/mheap.c
+++ b/src/pkg/runtime/mheap.c
@@ -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;
diff --git a/src/pkg/runtime/mheapmap32.c b/src/pkg/runtime/mheapmap32.c
index 1e3598cbe..4481e11f6 100644
--- a/src/pkg/runtime/mheapmap32.c
+++ b/src/pkg/runtime/mheapmap32.c
@@ -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;
}
diff --git a/src/pkg/runtime/mheapmap64.c b/src/pkg/runtime/mheapmap64.c
index 2f856ee17..d5590a2d8 100644
--- a/src/pkg/runtime/mheapmap64.c
+++ b/src/pkg/runtime/mheapmap64.c
@@ -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;
}
diff --git a/src/pkg/runtime/mprof.cgo b/src/pkg/runtime/mprof.cgo
index 50bcaec3c..0cddb243d 100644
--- a/src/pkg/runtime/mprof.cgo
+++ b/src/pkg/runtime/mprof.cgo
@@ -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;
diff --git a/src/pkg/runtime/pprof/pprof.go b/src/pkg/runtime/pprof/pprof.go
index 3a6055128..d0cc73089 100644
--- a/src/pkg/runtime/pprof/pprof.go
+++ b/src/pkg/runtime/pprof/pprof.go
@@ -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)