go sync.Map

April 10, 2025

My thoughts

Amazing deep dive into go’s sync.Map

I was expecting a similar approach to https://github.com/xacrimon/dashmap / https://docs.rs/dashmap/latest/dashmap/ which does sharding to reduce lock contention.

sync.Map is pretty interesting, it offers CAS-like functions and has a whole state machine for entries in order to reduce lock contention.

I wonder which are the tradeoffs in the two approaches.

Read the article: go sync.Map