Re:Are Go maps sensitive to data races?
by grabcocque on Monday December 07, 2015 @07:33AM
(#10689005)
They're really not though. Java has ConcurrentHashMap and isn't slow. Clojure has its persistent HashMap and it isn't slow. Scala has, TWO (?) concurrent hash maps in its core and neither is slow.
You know, two thirds of the way through the second decade of the 21st century, it's okay to spend a few cycles not corrupting your data structures.
Re:Are Go maps sensitive to data races?
by alkonaut on Monday December 07, 2015 @07:41AM
(#10689045)
There are both memory and performance considerations. For a server/db web application this may not be a problem, but for e.g. some logic in a game engine that runs every frame on a mobile device, then using 16 extra locks per map for example isn't a good idea. Nor is having 5% performance overhead.
I can agree with an argument that thread-safe should be default and specialized/fast collections should be optional though.
Re:Are Go maps sensitive to data races?
by astrafoo on Monday December 07, 2015 @12:25PM
(#10690889)
People who care about 5% performance overhead will never use Go in the first place.
Re:Are Go maps sensitive to data races?
by alkonaut on Monday December 07, 2015 @02:05PM
(#10691783)
That's just not true. Regardless of language there is always a portion of the code where you need to be careful with performance. I have spent endless hours tweaking map performance in .NET, for example.
You could argue that if most Go code is concurrent then the regular collections should be the thread safe ones, and for code that is known to be single threaded there would be simpler/faster non-concurrent collections. That is a completely valid argument to make, but I think that design would be too confusing for new Go developers, since in most other languages the standard collections are the non-concurrent ones, and the concurrent ones are special, and it's an explicit design goal of Go to be easy to adopt coming from another language.