diff options
| author | Aliaksandr Valialkin <valyala@gmail.com> | 2017-04-17 15:09:10 +0300 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2017-04-18 14:17:48 +0000 |
| commit | af5c95117b26e22d942a12e15bdc8e25607f738c (patch) | |
| tree | 529c9fe8c2fe3726e15bbbda2be523d3ce16218f /src/sync | |
| parent | c239fbb893b202e2fce141449215f802eefb6b9f (diff) | |
| download | go-af5c95117b26e22d942a12e15bdc8e25607f738c.tar.xz | |
sync: improve Pool performance
Rewrite indexLocal to achieve higher performance.
Performance results on linux/amd64:
name old time/op new time/op delta
Pool-4 19.1ns ± 2% 10.1ns ± 1% -47.15% (p=0.000 n=10+8)
PoolOverflow-4 3.11µs ± 1% 2.10µs ± 2% -32.66% (p=0.000 n=10+10)
Performance results on linux/386:
name old time/op new time/op delta
Pool-4 20.0ns ± 2% 13.1ns ± 1% -34.59% (p=0.000 n=10+9)
PoolOverflow-4 3.51µs ± 1% 2.49µs ± 0% -28.99% (p=0.000 n=10+8)
Change-Id: I7d57a2d4cd47ec43d09ca1267bde2e3f05a9faa9
Reviewed-on: https://go-review.googlesource.com/40913
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/sync')
| -rw-r--r-- | src/sync/pool.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/sync/pool.go b/src/sync/pool.go index 0acdbde096..b3fd9d397c 100644 --- a/src/sync/pool.go +++ b/src/sync/pool.go @@ -241,7 +241,8 @@ func init() { } func indexLocal(l unsafe.Pointer, i int) *poolLocal { - return &(*[1000000]poolLocal)(l)[i] + lp := unsafe.Pointer(uintptr(l) + uintptr(i)*unsafe.Sizeof(poolLocal{})) + return (*poolLocal)(lp) } // Implemented in runtime. |
