Map/MapOf.Range iteration order
Opened this issue · 1 comments
Map in the standard Go library (afaik even sync.Map) has an indeterministic iteration order. On each iteration a random point is chosen. They have various reasons for that, performance (golang/go#8412) or preventing bad codes relying on fixed iteration order.
Currently Map/MapOf.Range
methods have a fixed iteration order for a stable map. Would you consider applying some randomness similar to standard library? For example starting from a random bucket instead of the first bucket.
In case of xsync, such randomization won't improve performance, but preventing bad code relying on fixed iteration order may be valuable for someone. Let me keep this issue around and see if anyone else requests it.
The implementation could be as simple as starting the iteration with a randomly selected bucket.