Bryan C. Mills
37569ff763
syncmap: add benchmark for Range
...
adjust BenchmarkAdversarialDelete to be somewhat more adversarial.
updates golang/go#18177
Change-Id: Id01ed1077a0447dcfc6ea3929c22baaddbc9d6ee
Reviewed-on: https://go-review.googlesource.com/37151
Reviewed-by: Russ Cox <rsc@golang.org>
2017-02-16 19:20:33 +00:00
Bryan C. Mills
54b13b0b03
syncmap: add a synchronized map implementation.
...
This is a draft for the sync.Map API proposed in golang/go#18177 .
It supports fast-path loads via an atomic variable, falling back to a
Mutex for stores. In order to keep stores amortized to O(1), loads
following a store follow the Mutex path until enough loads have
occurred to offset the cost of a deep copy.
For mostly-read loads, such as the maps in the reflect package in the
standard library, this significantly reduces cache-line contention vs.
a plain RWMutex with a map.
goos: linux
goarch: amd64
pkg: golang.org/x/sync/syncmap
BenchmarkLoadMostlyHits/*syncmap_test.DeepCopyMap 20000000 73.1 ns/op
BenchmarkLoadMostlyHits/*syncmap_test.DeepCopyMap-48 100000000 13.8 ns/op
BenchmarkLoadMostlyHits/*syncmap_test.RWMutexMap 20000000 87.7 ns/op
BenchmarkLoadMostlyHits/*syncmap_test.RWMutexMap-48 10000000 154 ns/op
BenchmarkLoadMostlyHits/*syncmap.Map 20000000 72.1 ns/op
BenchmarkLoadMostlyHits/*syncmap.Map-48 100000000 11.2 ns/op
BenchmarkLoadMostlyMisses/*syncmap_test.DeepCopyMap 20000000 63.2 ns/op
BenchmarkLoadMostlyMisses/*syncmap_test.DeepCopyMap-48 200000000 14.2 ns/op
BenchmarkLoadMostlyMisses/*syncmap_test.RWMutexMap 20000000 72.7 ns/op
BenchmarkLoadMostlyMisses/*syncmap_test.RWMutexMap-48 10000000 150 ns/op
BenchmarkLoadMostlyMisses/*syncmap.Map 30000000 56.4 ns/op
BenchmarkLoadMostlyMisses/*syncmap.Map-48 200000000 9.77 ns/op
BenchmarkLoadOrStoreBalanced/*syncmap_test.RWMutexMap 2000000 683 ns/op
BenchmarkLoadOrStoreBalanced/*syncmap_test.RWMutexMap-48 1000000 1394 ns/op
BenchmarkLoadOrStoreBalanced/*syncmap.Map 2000000 645 ns/op
BenchmarkLoadOrStoreBalanced/*syncmap.Map-48 1000000 1253 ns/op
BenchmarkLoadOrStoreUnique/*syncmap_test.RWMutexMap 1000000 1015 ns/op
BenchmarkLoadOrStoreUnique/*syncmap_test.RWMutexMap-48 1000000 1911 ns/op
BenchmarkLoadOrStoreUnique/*syncmap.Map 1000000 1018 ns/op
BenchmarkLoadOrStoreUnique/*syncmap.Map-48 1000000 1776 ns/op
BenchmarkLoadOrStoreCollision/*syncmap_test.DeepCopyMap 50000000 30.2 ns/op
BenchmarkLoadOrStoreCollision/*syncmap_test.DeepCopyMap-48 2000000000 1.24 ns/op
BenchmarkLoadOrStoreCollision/*syncmap_test.RWMutexMap 30000000 50.1 ns/op
BenchmarkLoadOrStoreCollision/*syncmap_test.RWMutexMap-48 5000000 451 ns/op
BenchmarkLoadOrStoreCollision/*syncmap.Map 30000000 36.8 ns/op
BenchmarkLoadOrStoreCollision/*syncmap.Map-48 2000000000 1.24 ns/op
BenchmarkAdversarialAlloc/*syncmap_test.DeepCopyMap 10000000 213 ns/op
BenchmarkAdversarialAlloc/*syncmap_test.DeepCopyMap-48 1000000 5012 ns/op
BenchmarkAdversarialAlloc/*syncmap_test.RWMutexMap 20000000 68.8 ns/op
BenchmarkAdversarialAlloc/*syncmap_test.RWMutexMap-48 5000000 429 ns/op
BenchmarkAdversarialAlloc/*syncmap.Map 5000000 229 ns/op
BenchmarkAdversarialAlloc/*syncmap.Map-48 2000000 600 ns/op
BenchmarkAdversarialDelete/*syncmap_test.DeepCopyMap 5000000 314 ns/op
BenchmarkAdversarialDelete/*syncmap_test.DeepCopyMap-48 2000000 726 ns/op
BenchmarkAdversarialDelete/*syncmap_test.RWMutexMap 20000000 63.2 ns/op
BenchmarkAdversarialDelete/*syncmap_test.RWMutexMap-48 5000000 469 ns/op
BenchmarkAdversarialDelete/*syncmap.Map 10000000 203 ns/op
BenchmarkAdversarialDelete/*syncmap.Map-48 10000000 253 ns/op
goos: linux
goarch: ppc64le
pkg: golang.org/x/sync/syncmap
BenchmarkLoadMostlyHits/*syncmap_test.DeepCopyMap 5000000 253 ns/op
BenchmarkLoadMostlyHits/*syncmap_test.DeepCopyMap-48 50000000 26.2 ns/op
BenchmarkLoadMostlyHits/*syncmap_test.RWMutexMap 5000000 505 ns/op
BenchmarkLoadMostlyHits/*syncmap_test.RWMutexMap-48 3000000 443 ns/op
BenchmarkLoadMostlyHits/*syncmap.Map 10000000 200 ns/op
BenchmarkLoadMostlyHits/*syncmap.Map-48 100000000 18.1 ns/op
BenchmarkLoadMostlyMisses/*syncmap_test.DeepCopyMap 10000000 162 ns/op
BenchmarkLoadMostlyMisses/*syncmap_test.DeepCopyMap-48 100000000 23.8 ns/op
BenchmarkLoadMostlyMisses/*syncmap_test.RWMutexMap 10000000 195 ns/op
BenchmarkLoadMostlyMisses/*syncmap_test.RWMutexMap-48 3000000 531 ns/op
BenchmarkLoadMostlyMisses/*syncmap.Map 10000000 182 ns/op
BenchmarkLoadMostlyMisses/*syncmap.Map-48 100000000 15.8 ns/op
BenchmarkLoadOrStoreBalanced/*syncmap_test.RWMutexMap 1000000 1664 ns/op
BenchmarkLoadOrStoreBalanced/*syncmap_test.RWMutexMap-48 1000000 1768 ns/op
BenchmarkLoadOrStoreBalanced/*syncmap.Map 1000000 2128 ns/op
BenchmarkLoadOrStoreBalanced/*syncmap.Map-48 1000000 1903 ns/op
BenchmarkLoadOrStoreUnique/*syncmap_test.RWMutexMap 1000000 2657 ns/op
BenchmarkLoadOrStoreUnique/*syncmap_test.RWMutexMap-48 1000000 2577 ns/op
BenchmarkLoadOrStoreUnique/*syncmap.Map 1000000 1714 ns/op
BenchmarkLoadOrStoreUnique/*syncmap.Map-48 1000000 2484 ns/op
BenchmarkLoadOrStoreCollision/*syncmap_test.DeepCopyMap 10000000 130 ns/op
BenchmarkLoadOrStoreCollision/*syncmap_test.DeepCopyMap-48 100000000 11.3 ns/op
BenchmarkLoadOrStoreCollision/*syncmap_test.RWMutexMap 3000000 426 ns/op
BenchmarkLoadOrStoreCollision/*syncmap_test.RWMutexMap-48 2000000 930 ns/op
BenchmarkLoadOrStoreCollision/*syncmap.Map 10000000 131 ns/op
BenchmarkLoadOrStoreCollision/*syncmap.Map-48 300000000 4.07 ns/op
BenchmarkAdversarialAlloc/*syncmap_test.DeepCopyMap 3000000 447 ns/op
BenchmarkAdversarialAlloc/*syncmap_test.DeepCopyMap-48 300000 4159 ns/op
BenchmarkAdversarialAlloc/*syncmap_test.RWMutexMap 10000000 191 ns/op
BenchmarkAdversarialAlloc/*syncmap_test.RWMutexMap-48 3000000 535 ns/op
BenchmarkAdversarialAlloc/*syncmap.Map 2000000 525 ns/op
BenchmarkAdversarialAlloc/*syncmap.Map-48 1000000 1000 ns/op
BenchmarkAdversarialDelete/*syncmap_test.DeepCopyMap 2000000 711 ns/op
BenchmarkAdversarialDelete/*syncmap_test.DeepCopyMap-48 2000000 900 ns/op
BenchmarkAdversarialDelete/*syncmap_test.RWMutexMap 3000000 354 ns/op
BenchmarkAdversarialDelete/*syncmap_test.RWMutexMap-48 3000000 473 ns/op
BenchmarkAdversarialDelete/*syncmap.Map 2000000 1357 ns/op
BenchmarkAdversarialDelete/*syncmap.Map-48 5000000 334 ns/op
Updates golang/go#18177
Change-Id: I8d561b617b1cd2ca03a8e68a5d5a28a519a0ce38
Reviewed-on: https://go-review.googlesource.com/33912
Reviewed-by: Russ Cox <rsc@golang.org>
2017-02-15 17:32:38 +00:00
Josh Bleecher Snyder
450f422ab2
.: add codereview.cfg
...
This makes git-codereview review issue references
to refer to the main Go repo.
Change-Id: I17003885f15358f776a475a76a31dac179de9676
Reviewed-on: https://go-review.googlesource.com/33908
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-06 01:46:32 +00:00
Bryan C. Mills
81567d9de7
errgroup: fix misleading comment in MD5All example
...
Change-Id: I0c2f0ce9b6006dac13c5f5faed752a2475992805
Reviewed-on: https://go-review.googlesource.com/33851
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-12-01 22:51:26 +00:00
Matt Layher
1ae7c7b29e
singleflight: copy from internal/singleflight in standard library
...
Updates golang/go#17338
Change-Id: Icf1972cdec0bbc9b3142141d9e706c07f312efc0
Reviewed-on: https://go-review.googlesource.com/30292
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-04 23:36:20 +00:00
Bryan C. Mills
316e794f7b
sync: delete dummy builders_test file
...
The builders should be happy building errgroup instead now.
Change-Id: I99f549032f771e067b5f7780eba1cc6e91bbdfa5
Reviewed-on: https://go-review.googlesource.com/24962
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-15 19:05:49 +00:00
Bryan C. Mills
53cf14c8d7
errgroup: fix build errors in errgroup_test
...
Change-Id: Ie5ebfa26b6234f833139784da859d32cc1416b26
Reviewed-on: https://go-review.googlesource.com/24961
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-15 18:40:41 +00:00
Bryan C. Mills
457c582840
errgroup: add package
...
Package errgroup provides synchronization, error propagation, and
Context cancellation for groups of goroutines working on subtasks of a
common task.
Change-Id: Ic9e51f6f846124076bbff9d53b0f09dc7fc5f2f0
Reviewed-on: https://go-review.googlesource.com/24894
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-15 18:28:34 +00:00
Brad Fitzpatrick
c6cf2573d3
sync: add a Go file to make the builders happy
...
Change-Id: I6e4fbebee02076b8c9d43318c3f7260f2339c1a3
Reviewed-on: https://go-review.googlesource.com/24907
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-07-13 20:16:11 +00:00
Andrew Gerrand
b62d5b6cb4
initial commit
2015-10-30 14:31:46 +11:00