diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2014-01-28 22:38:39 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2014-01-28 22:38:39 +0400 |
| commit | d176e3d7c5bb50685c95aaf1e0e3133bea0ea57f (patch) | |
| tree | 1806934e42ee941aa77526e4c8b0ee896d812549 /src/pkg/runtime/malloc.goc | |
| parent | d409e44cfb7b2a323658f4b6fd6d5bb3a9104889 (diff) | |
| download | go-d176e3d7c5bb50685c95aaf1e0e3133bea0ea57f.tar.xz | |
runtime: prefetch next block in mallocgc
json-1
cputime 99600000 98600000 -1.00%
time 100005493 98859693 -1.15%
garbage-1
cputime 15760000 15440000 -2.03%
time 15791759 15471701 -2.03%
LGTM=khr
R=golang-codereviews, gobot, khr, dave
CC=bradfitz, golang-codereviews, iant
https://golang.org/cl/57310043
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
| -rw-r--r-- | src/pkg/runtime/malloc.goc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index 3dfa63dbec..b00d690aad 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -40,7 +40,7 @@ runtime·mallocgc(uintptr size, uintptr typ, uint32 flag) intgo rate; MCache *c; MCacheList *l; - MLink *v; + MLink *v, *next; byte *tiny; if(size == 0) { @@ -120,7 +120,10 @@ runtime·mallocgc(uintptr size, uintptr typ, uint32 flag) if(l->list == nil) runtime·MCache_Refill(c, TinySizeClass); v = l->list; - l->list = v->next; + next = v->next; + if(next != nil) // prefetching nil leads to a DTLB miss + PREFETCH(next); + l->list = next; l->nlist--; ((uint64*)v)[0] = 0; ((uint64*)v)[1] = 0; @@ -144,7 +147,10 @@ runtime·mallocgc(uintptr size, uintptr typ, uint32 flag) if(l->list == nil) runtime·MCache_Refill(c, sizeclass); v = l->list; - l->list = v->next; + next = v->next; + if(next != nil) // prefetching nil leads to a DTLB miss + PREFETCH(next); + l->list = next; l->nlist--; if(!(flag & FlagNoZero)) { v->next = nil; |
