diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2013-06-06 14:56:50 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2013-06-06 14:56:50 +0400 |
| commit | 5d637b83a90cd16ea6badbe716f5e964bd9e06db (patch) | |
| tree | 186ce4f2177e42bd45a13169f19199777aaf1bb5 /src/pkg/runtime/malloc.h | |
| parent | 07ea243d50e5e4c27e0212d45fa4e80d649d179f (diff) | |
| download | go-5d637b83a90cd16ea6badbe716f5e964bd9e06db.tar.xz | |
runtime: speedup malloc stats collection
Count only number of frees, everything else is derivable
and does not need to be counted on every malloc.
benchmark old ns/op new ns/op delta
BenchmarkMalloc8 68 66 -3.07%
BenchmarkMalloc16 75 70 -6.48%
BenchmarkMallocTypeInfo8 102 97 -4.80%
BenchmarkMallocTypeInfo16 108 105 -2.78%
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/9776043
Diffstat (limited to 'src/pkg/runtime/malloc.h')
| -rw-r--r-- | src/pkg/runtime/malloc.h | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h index ba8036ab68..41604501f0 100644 --- a/src/pkg/runtime/malloc.h +++ b/src/pkg/runtime/malloc.h @@ -286,22 +286,15 @@ struct MCache { // 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 + 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 - // Statistics about allocation size classes since last lock of heap - struct { - uintptr nmalloc; - uintptr nfree; - } local_by_size[NumSizeClasses]; - + // Local allocator stats, flushed during GC. + uintptr local_nlookup; // number of pointer lookups + uintptr local_largefree; // bytes freed for large objects (>MaxSmallSize) + uintptr local_nlargefree; // number of frees for large objects (>MaxSmallSize) + uintptr local_nsmallfree[NumSizeClasses]; // number of frees for small objects (<=MaxSmallSize) }; void runtime·MCache_Refill(MCache *c, int32 sizeclass); @@ -431,6 +424,11 @@ struct MHeap FixAlloc spanalloc; // allocator for Span* FixAlloc cachealloc; // allocator for MCache* + + // Malloc stats. + uint64 largefree; // bytes freed for large objects (>MaxSmallSize) + uint64 nlargefree; // number of frees for large objects (>MaxSmallSize) + uint64 nsmallfree[NumSizeClasses]; // number of frees for small objects (<=MaxSmallSize) }; extern MHeap runtime·mheap; |
