Re:How We Built Uber’s Highest Query per Second Service Usin...
by spyspy on Tuesday March 01, 2016 @06:23PM
(#11206969)
I believe that's exactly what they were doing with the StorePointer/LoadPointer primitives. However it is generally agreed in the Go community that the sync/atomic is to be avoided in favor of the sync/mutex for this type of problem. The RWMutex is designed for a 1 writer/N readers scenario. The code is more readable and you don't offload any work to the GC.
[ Parent
| on HN ]
Re:How We Built Uber’s Highest Query per Second Service Usin...
by pcwalton on Wednesday March 02, 2016 @03:46AM
(#11208806)
> However it is generally agreed in the Go community that the sync/atomic is to be avoided in favor of the sync/mutex for this type of problem.
Why? Concurrent data structures are extremely useful.
> The code is more readable and you don't offload any work to the GC.
You shouldn't write concurrent data structures yourself; you should use a library. And the amount of time spent in the GC for this is going to be negligible assuming writes are infrequent compared to reads. It's rare in a GC'd language that your write operation won't be creating garbage somewhere along the way, so it ends up being amortized.