Re:Dashmap: Fast concurrent HashMap for Rust
by xacrimon on Friday March 27, 2020 @10:53AM
(#22703269)
Hi! I am the author of dashmap. CHashMap is essentially a table behind an rwlock where each slot is also behind its own rwlock. This is great in theory since it allows decently concurrent operations providing they don't need to lock the whole table for resizing. In practice this falls short quickly because of the contention on the outer lock and the large amount of locks and unlocks when traversing the map.
dashmap works by splitting into an array of shards, each shard behind its own rwlock. The shard is decided from the keys hash. This will only lock and unlock once for any one shard and allows concurrent table locking operations provided they are on different shards. Further, there is no central rwlock each thread must go thru which improves performance significantly.
Re:Dashmap: Fast concurrent HashMap for Rust
by Jonhoo on Friday March 27, 2020 @08:24AM
(#22702286)
I can't speak to the implementation differences between the two, but I know the author of dashmap is relatively active in responding online, so they may show up shortly to explain. In terms of performance comparisons, we're actually working on building a shared benchmarking tool for all of Rust's concurrent maps that you may find interesting: https://github.com/jonhoo/bustle.
https://gitlab.redox-os.org/redox-os/chashmap
They provide benchmarks, but I would be more interested to know how the implementation differs.