From e19d8a47d1803a19446c658712c4bdff84d0da31 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 17 Sep 2014 14:49:32 -0400 Subject: runtime: account for tiny allocs, for testing.AllocsPerRun Fixes #8734. LGTM=r, bradfitz, dvyukov R=bradfitz, r, dvyukov CC=golang-codereviews, iant, khr https://golang.org/cl/143150043 --- src/runtime/malloc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/runtime/malloc.c') diff --git a/src/runtime/malloc.c b/src/runtime/malloc.c index cfb698ac21..d5f2b9ab80 100644 --- a/src/runtime/malloc.c +++ b/src/runtime/malloc.c @@ -79,6 +79,8 @@ runtime·purgecachedstats(MCache *c) h = &runtime·mheap; mstats.heap_alloc += c->local_cachealloc; c->local_cachealloc = 0; + mstats.tinyallocs += c->local_tinyallocs; + c->local_tinyallocs = 0; mstats.nlookup += c->local_nlookup; c->local_nlookup = 0; h->largefree += c->local_largefree; @@ -92,9 +94,10 @@ runtime·purgecachedstats(MCache *c) } // Size of the trailing by_size array differs between Go and C, +// and all data after by_size is local to C, not exported to Go. // NumSizeClasses was changed, but we can not change Go struct because of backward compatibility. // sizeof_C_MStats is what C thinks about size of Go struct. -uintptr runtime·sizeof_C_MStats = sizeof(MStats) - (NumSizeClasses - 61) * sizeof(mstats.by_size[0]); +uintptr runtime·sizeof_C_MStats = offsetof(MStats, by_size[61]); #define MaxArena32 (2U<<30) -- cgit v1.3