aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-01-19 13:41:42 -0500
committerRuss Cox <rsc@golang.org>2011-01-19 13:41:42 -0500
commitbcd910cfe28eb237741e3bf25fc2c454206a1c30 (patch)
tree89b320ff96ebf2138354f9c4f75323a0a3dadecd /src/pkg/runtime
parent61a4e9812e11efe3ea41142fc49e331c333a333e (diff)
downloadgo-bcd910cfe28eb237741e3bf25fc2c454206a1c30.tar.xz
runtime: add per-pause gc stats
R=r, r2 CC=golang-dev https://golang.org/cl/3980042
Diffstat (limited to 'src/pkg/runtime')
-rw-r--r--src/pkg/runtime/debug.go12
-rw-r--r--src/pkg/runtime/malloc.h4
-rw-r--r--src/pkg/runtime/mgc0.c5
3 files changed, 14 insertions, 7 deletions
diff --git a/src/pkg/runtime/debug.go b/src/pkg/runtime/debug.go
index 3ce35cc5ba..cf30374f09 100644
--- a/src/pkg/runtime/debug.go
+++ b/src/pkg/runtime/debug.go
@@ -39,6 +39,7 @@ type MemStatsType struct {
Sys uint64 // bytes obtained from system (should be sum of XxxSys below)
Lookups uint64 // number of pointer lookups
Mallocs uint64 // number of mallocs
+ Frees uint64 // number of frees
// Main allocation heap statistics.
HeapAlloc uint64 // bytes allocated and still in use
@@ -60,11 +61,12 @@ type MemStatsType struct {
BuckHashSys uint64 // profiling bucket hash table
// Garbage collector statistics.
- NextGC uint64
- PauseNs uint64
- NumGC uint32
- EnableGC bool
- DebugGC bool
+ NextGC uint64
+ PauseTotalNs uint64
+ PauseNs [256]uint64 // most recent GC pause times
+ NumGC uint32
+ EnableGC bool
+ DebugGC bool
// Per-size allocation statistics.
// Not locked during update; approximate.
diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h
index 0cee6c0ddb..7e750b9170 100644
--- a/src/pkg/runtime/malloc.h
+++ b/src/pkg/runtime/malloc.h
@@ -176,6 +176,7 @@ struct MStats
uint64 sys; // bytes obtained from system (should be sum of xxx_sys below)
uint64 nlookup; // number of pointer lookups
uint64 nmalloc; // number of mallocs
+ uint64 nfree; // number of frees
// Statistics about malloc heap.
// protected by mheap.Lock
@@ -199,7 +200,8 @@ struct MStats
// Statistics about garbage collector.
// Protected by stopping the world during GC.
uint64 next_gc; // next GC (in heap_alloc time)
- uint64 pause_ns;
+ uint64 pause_total_ns;
+ uint64 pause_ns[256];
uint32 numgc;
bool enablegc;
bool debuggc;
diff --git a/src/pkg/runtime/mgc0.c b/src/pkg/runtime/mgc0.c
index 6dcb61091d..4eace9f831 100644
--- a/src/pkg/runtime/mgc0.c
+++ b/src/pkg/runtime/mgc0.c
@@ -210,6 +210,7 @@ sweepspan(MSpan *s)
case RefNone:
// Free large object.
mstats.alloc -= s->npages<<PageShift;
+ mstats.nfree++;
runtime·memclr(p, s->npages<<PageShift);
if(ref & RefProfiled)
runtime·MProf_Free(p, s->npages<<PageShift);
@@ -251,6 +252,7 @@ sweepspan(MSpan *s)
if(size > sizeof(uintptr))
((uintptr*)p)[1] = 1; // mark as "needs to be zeroed"
mstats.alloc -= size;
+ mstats.nfree++;
mstats.by_size[s->sizeclass].nfree++;
runtime·MCache_Free(c, p, s->sizeclass, size);
break;
@@ -381,7 +383,8 @@ runtime·gc(int32 force)
t1 = runtime·nanotime();
mstats.numgc++;
- mstats.pause_ns += t1 - t0;
+ mstats.pause_ns[mstats.numgc%nelem(mstats.pause_ns)] = t1 - t0;
+ mstats.pause_total_ns += t1 - t0;
if(mstats.debuggc)
runtime·printf("pause %D\n", t1-t0);
runtime·semrelease(&gcsema);