diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2013-09-06 16:55:40 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2013-09-06 16:55:40 -0400 |
| commit | a33ef8d11b9db6646991bee5732015562fd4efd2 (patch) | |
| tree | a778eda45c6c02b014890cc0e35e6f8c56ee8361 /src/pkg/runtime/mem_linux.c | |
| parent | 52f15df9e2e9fada55c7f132242eb78a8ba4f3ab (diff) | |
| download | go-a33ef8d11b9db6646991bee5732015562fd4efd2.tar.xz | |
runtime: account for all sys memory in MemStats
Currently lots of sys allocations are not accounted in any of XxxSys,
including GC bitmap, spans table, GC roots blocks, GC finalizer blocks,
iface table, netpoll descriptors and more. Up to ~20% can unaccounted.
This change introduces 2 new stats: GCSys and OtherSys for GC metadata
and all other misc allocations, respectively.
Also ensures that all XxxSys indeed sum up to Sys. All sys memory allocation
functions require the stat for accounting, so that it's impossible to miss something.
Also fix updating of mcache_sys/inuse, they were not updated after deallocation.
test/bench/garbage/parser before:
Sys 670064344
HeapSys 610271232
StackSys 65536
MSpanSys 14204928
MCacheSys 16384
BuckHashSys 1439992
after:
Sys 670064344
HeapSys 610271232
StackSys 65536
MSpanSys 14188544
MCacheSys 16384
BuckHashSys 3194304
GCSys 39198688
OtherSys 3129656
Fixes #5799.
R=rsc, dave, alex.brainman
CC=golang-dev
https://golang.org/cl/12946043
Diffstat (limited to 'src/pkg/runtime/mem_linux.c')
| -rw-r--r-- | src/pkg/runtime/mem_linux.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/pkg/runtime/mem_linux.c b/src/pkg/runtime/mem_linux.c index d96eb69e89..b0f2956335 100644 --- a/src/pkg/runtime/mem_linux.c +++ b/src/pkg/runtime/mem_linux.c @@ -50,11 +50,10 @@ mmap_fixed(byte *v, uintptr n, int32 prot, int32 flags, int32 fd, uint32 offset) } void* -runtime·SysAlloc(uintptr n) +runtime·SysAlloc(uintptr n, uint64 *stat) { void *p; - mstats.sys += n; p = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0); if(p < (void*)4096) { if(p == (void*)EACCES) { @@ -68,6 +67,7 @@ runtime·SysAlloc(uintptr n) } return nil; } + runtime·xadd64(stat, n); return p; } @@ -85,9 +85,9 @@ runtime·SysUsed(void *v, uintptr n) } void -runtime·SysFree(void *v, uintptr n) +runtime·SysFree(void *v, uintptr n, uint64 *stat) { - mstats.sys -= n; + runtime·xadd64(stat, -(uint64)n); runtime·munmap(v, n); } @@ -118,11 +118,11 @@ runtime·SysReserve(void *v, uintptr n) } void -runtime·SysMap(void *v, uintptr n) +runtime·SysMap(void *v, uintptr n, uint64 *stat) { void *p; - mstats.sys += n; + runtime·xadd64(stat, n); // On 64-bit, we don't actually have v reserved, so tread carefully. if(sizeof(void*) == 8 && (uintptr)v >= 0xffffffffU) { |
