aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/malloc.goc
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2013-05-22 22:22:57 +0400
committerDmitriy Vyukov <dvyukov@google.com>2013-05-22 22:22:57 +0400
commitc075d82ccac5eb6fca481efccc798acac00f7dae (patch)
tree60d6fa4f2ba7f7a4055d0477b50966e41f0e893f /src/pkg/runtime/malloc.goc
parent4c2df76b7dd9439566a71f8bb339295a5ef57be6 (diff)
downloadgo-c075d82ccac5eb6fca481efccc798acac00f7dae.tar.xz
runtime: fix and speedup malloc stats
Currently per-sizeclass stats are lost for destroyed MCache's. This patch fixes this. Also, only update mstats.heap_alloc on heap operations, because that's the only stat that needs to be promptly updated. Everything else needs to be up-to-date only in ReadMemStats(). R=golang-dev, remyoudompheng, dave, iant CC=golang-dev https://golang.org/cl/9207047
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
-rw-r--r--src/pkg/runtime/malloc.goc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc
index 5326551fee..7e691fe9c8 100644
--- a/src/pkg/runtime/malloc.goc
+++ b/src/pkg/runtime/malloc.goc
@@ -278,6 +278,8 @@ runtime·freemcache(MCache *c)
void
runtime·purgecachedstats(MCache *c)
{
+ int32 i;
+
// Protected by either heap or GC lock.
mstats.heap_alloc += c->local_cachealloc;
c->local_cachealloc = 0;
@@ -293,6 +295,12 @@ runtime·purgecachedstats(MCache *c)
c->local_alloc= 0;
mstats.total_alloc += c->local_total_alloc;
c->local_total_alloc= 0;
+ for(i=0; i<nelem(c->local_by_size); i++) {
+ mstats.by_size[i].nmalloc += c->local_by_size[i].nmalloc;
+ c->local_by_size[i].nmalloc = 0;
+ mstats.by_size[i].nfree += c->local_by_size[i].nfree;
+ c->local_by_size[i].nfree = 0;
+ }
}
uintptr runtime·sizeof_C_MStats = sizeof(MStats);