aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/malloc.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-09-17 14:49:32 -0400
committerRuss Cox <rsc@golang.org>2014-09-17 14:49:32 -0400
commite19d8a47d1803a19446c658712c4bdff84d0da31 (patch)
tree2e7903e0a12d21606597ecc82c38546e11506101 /src/runtime/malloc.c
parenta883f117a9dda5f218bb08dc1c4e181ab1679e11 (diff)
downloadgo-e19d8a47d1803a19446c658712c4bdff84d0da31.tar.xz
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
Diffstat (limited to 'src/runtime/malloc.c')
-rw-r--r--src/runtime/malloc.c5
1 files changed, 4 insertions, 1 deletions
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)