diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2013-05-15 11:02:33 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2013-05-15 11:02:33 +0400 |
| commit | 5a89b35bca720d1ba296f5d7f22376b440486faf (patch) | |
| tree | e98091150689c45c24c079e9cbeb5e52d214c181 /src/pkg/runtime/malloc.goc | |
| parent | 3de593d94bd7c9c1e75afcc45f5ca89b629d5e64 (diff) | |
| download | go-5a89b35bca720d1ba296f5d7f22376b440486faf.tar.xz | |
runtime: inline size to class conversion in malloc()
Also change table type from int32[] to int8[] to save space in L1$.
benchmark old ns/op new ns/op delta
BenchmarkMalloc 42 40 -4.68%
R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/9199044
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
| -rw-r--r-- | src/pkg/runtime/malloc.goc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index f1d25a793f..5326551fee 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -50,7 +50,11 @@ runtime·mallocgc(uintptr size, uint32 flag, int32 dogc, int32 zeroed) c->local_nmalloc++; if(size <= MaxSmallSize) { // Allocate from mcache free lists. - sizeclass = runtime·SizeToClass(size); + // Inlined version of SizeToClass(). + if(size <= 1024-8) + sizeclass = runtime·size_to_class8[(size+7)>>3]; + else + sizeclass = runtime·size_to_class128[(size-1024+127) >> 7]; size = runtime·class_to_size[sizeclass]; v = runtime·MCache_Alloc(c, sizeclass, size, zeroed); if(v == nil) |
