-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Context
Go's atomic.Value type can perform a lot better than using a sync.RWMutex to guard values, especially when the use case is read-heavy and has a lot of concurrent contention. See some benchmarks here. We should use atomic.Value instead of a snc.RWMutex in those cases.
Definition of done
- Replace all uses of sync.RWMutex to guard values that are read frequently and written infrequently with atomic.Value.
Pitfalls
atomic.Value is not as useful for write-heavy or read-write balanced use cases. We should only use it for read-heavy use cases.
Note that we can't use most of the new types in the atomic package because they were added with Go 1.19.
- related to
-
GODRIVER-3162 Don't call "RTTMonitor.Stats" on every operation
- Closed