I have a HashMap
that’s concurrently read by many threads and needs to be occasionally replaced in-place with a new instance.
I know I can use RwLock<HashMap>
and replace the hash map after obtaining a write lock but I’m worried about performance because I need it to be highly optimized for reads and using RwLock
will surely somewhat degrade the performance.
What is the proper way to do this? Maybe using ArcSwap
? Also, would using ArcSwap
+ DashMap
instead ArcSwap
+ HashMap
be better (I suspect not because I believe DashMap
uses RwLock
internally)?