diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2013-05-22 22:22:57 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2013-05-22 22:22:57 +0400 |
| commit | c075d82ccac5eb6fca481efccc798acac00f7dae (patch) | |
| tree | 60d6fa4f2ba7f7a4055d0477b50966e41f0e893f /src/pkg/runtime/malloc.h | |
| parent | 4c2df76b7dd9439566a71f8bb339295a5ef57be6 (diff) | |
| download | go-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.h')
| -rw-r--r-- | src/pkg/runtime/malloc.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h index cbcc09cdb7..0d31326a22 100644 --- a/src/pkg/runtime/malloc.h +++ b/src/pkg/runtime/malloc.h @@ -285,15 +285,18 @@ struct MCacheList struct MCache { - MCacheList list[NumSizeClasses]; + // The following members are accessed on every malloc, + // so they are grouped here for better caching. + int32 next_sample; // trigger heap sample after allocating this many bytes intptr local_cachealloc; // bytes allocated (or freed) from cache since last lock of heap + // The rest is not accessed on every malloc. + MCacheList list[NumSizeClasses]; intptr local_objects; // objects allocated (or freed) from cache since last lock of heap intptr local_alloc; // bytes allocated (or freed) since last lock of heap uintptr local_total_alloc; // bytes allocated (even if freed) since last lock of heap uintptr local_nmalloc; // number of mallocs since last lock of heap uintptr local_nfree; // number of frees since last lock of heap uintptr local_nlookup; // number of pointer lookups since last lock of heap - int32 next_sample; // trigger heap sample after allocating this many bytes // Statistics about allocation size classes since last lock of heap struct { uintptr nmalloc; |
