]> Cypherpunks repositories - gostls13.git/commit
sync: less agressive local caching in Pool
authorDmitriy Vyukov <dvyukov@google.com>
Mon, 14 Apr 2014 17:13:32 +0000 (21:13 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Mon, 14 Apr 2014 17:13:32 +0000 (21:13 +0400)
commit8fc6ed4c8901d13fe1a5aa176b0ba808e2855af5
tree3e8135f1a9deafb7d68a6cb9712bb28742be5815
parent1e1506a2c1f12362ee5015ef23e9cf092ff284e4
sync: less agressive local caching in Pool
Currently Pool can cache up to 15 elements per P, and these elements are not accesible to other Ps.
If a Pool caches large objects, say 2MB, and GOMAXPROCS is set to a large value, say 32,
then the Pool can waste up to 960MB.
The new caching policy caches at most 1 per-P element, the rest is shared between Ps.

Get/Put performance is unchanged. Nested Get/Put performance is 57% worse.
However, overall scalability of nested Get/Put is significantly improved,
so the new policy starts winning under contention.

benchmark                     old ns/op     new ns/op     delta
BenchmarkPool                 27.4          26.7          -2.55%
BenchmarkPool-4               6.63          6.59          -0.60%
BenchmarkPool-16              1.98          1.87          -5.56%
BenchmarkPool-64              1.93          1.86          -3.63%
BenchmarkPoolOverlflow        3970          6235          +57.05%
BenchmarkPoolOverlflow-4      10935         1668          -84.75%
BenchmarkPoolOverlflow-16     13419         520           -96.12%
BenchmarkPoolOverlflow-64     10295         380           -96.31%

LGTM=rsc
R=rsc
CC=golang-codereviews, khr
https://golang.org/cl/86020043
src/pkg/runtime/mgc0.c
src/pkg/sync/pool.go
src/pkg/sync/pool_test.go