Descriptionruntime: change map iteration randomization to use intra-bucket offset
Map iteration previously started from a random bucket, but walked each
bucket from the beginning. Now, iteration always starts from the first
bucket and walks each bucket starting at a random offset. For
performance, the random offset is selected at the start of iteration
and reused for each bucket.
Iteration over a map with 8 or fewer elements--a single bucket--will
now be non-deterministic. There will now be only 8 different possible
map iterations.
Significant benchmark changes, on my OS X laptop (rough but consistent):
benchmark old ns/op new ns/op delta
BenchmarkMapIter 128 121 -5.47%
BenchmarkMapIterEmpty 4.26 4.45 +4.46%
BenchmarkNewEmptyMap 114 111 -2.63%
Fixes issue 6719.
Patch Set 1 #Patch Set 2 : code review 47370043: runtime: make map iteration start at a random offset wi... #Patch Set 3 : diff -r 1c86edd196bd https://code.google.com/p/go #
Total comments: 2
Patch Set 4 : diff -r 9d0f388bbe40 https://code.google.com/p/go #Patch Set 5 : diff -r 9d0f388bbe40 https://code.google.com/p/go #Patch Set 6 : diff -r 270e6a19b4ec https://code.google.com/p/go #Patch Set 7 : diff -r 270e6a19b4ec https://code.google.com/p/go #
MessagesTotal messages: 7
|