Re:Cmapv2: A high performance, concurrent map
by sapiogram on Tuesday June 17, 2025 @03:17PM
(#44302802)
Thank you for debunking it so I didn't have to. I don't think I've ever seen someone post a low-level/concurrent data structure in Go that wasn't wildly unsound, so I assumed this was too.
[ Parent
| on HN ]
Re:Cmapv2: A high performance, concurrent map
by diagraphic on Tuesday June 17, 2025 @03:43PM
(#44303073)
There are many good implementations.
Re:Cmapv2: A high performance, concurrent map
by ecshafer on Tuesday June 17, 2025 @04:46PM
(#44303761)
Go is made by Google. Do they not have someone writing an equivalent of Java.util.concurrent.ConcurrentHashMap?
Re:Cmapv2: A high performance, concurrent map
by sapiogram on Tuesday June 17, 2025 @04:47PM
(#44303777)
They do, there's a concurrent hashmap in the standard library. It doesn't get posted here or on Reddit, though.
or a port of the lock-free hash map from https://preshing.com/20130605/the-worlds-simplest-lock-free-...
But really, the premise of using a shared map with concurrent readers and writers seems like a good generator of hard-to-reproduce bugs. IMHO shared-nothing (when feasible) is much easier to reason about, and possibly do periodic merging of thread-local updates, but I would avoid concurrent updates entirely (in particular if 2 threads race to update the same key... that goes to deeper design issues in the application).