-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
Fix as in "keeping it fixed". As in, "not changing".
Random iteration order for maps is a serious drawback in some contexts. It would be desirable to have a hash map container that has unpredictable but fixed iteration order. Al least, in the same golang version, and between calls to the same underlying map.
Randomisation was introduced for performance reasons (see commit 55c458e0).
It would be good to have the option, by example during iteration, to define which behaviour we want: either the more performant but random, or the fixed order. And, given that iteration performance isn't necessarily the main concern for a hash map, perhaps the default iteration behaviour should be the fixed order one.
Also, it would be good to have a map impl that doesn't depend on randomisation to achieve better iteration performance. What about other map impls? Can / will run a benchmark in Rust and C++ (which AFAIK have fixed iteration order), to compare the iteration performance of their stock maps with that of Go.
Also, browsing through open issues, noticed that on 2022-03-01, in Go compiler and runtime meeting notes it was mentioned by austin that "our map is pretty old; at what point do we rewrite the map using the latest and greatest techniques?"
Comments?