talira

Blazing fast concurrent HashMap for Rust

open sourceMITfree

DashMap is a concurrent hash map for Rust, built as a direct replacement for RwLock<HashMap<K, V>> with an API close to std::collections::HashMap. Every method takes &self, so a DashMap can sit in an Arc and be read and changed from many threads at once, and it's designed for speed (its author's conc-map-bench compares it with other concurrent maps). Optional features add serde and rayon support, an unstable raw shard API and arbitrary support.

Problems it solves

  • share a HashMap between threads in Rust without wrapping it in a RwLock
  • a fast concurrent map for a multithreaded Rust server
  • my Rust app is slow because every thread waits on one Mutex<HashMap>

Features

  • drop-in replacement for RwLock<HashMap>
  • methods take &self, so it can be shared in an Arc and modified from many threads
  • HashMap-like API
  • optional serde and rayon support

Alternatives

The same job

These do what DashMap does.

  1. parking_lot Compact, fast mutexes, read-write locks and condition variables for Rust
  2. Crossbeam Tools for concurrent programming in Rust: channels, queues, atomics and scoped threads
  3. Rayon Simple work-stealing data parallelism for Rust

Compare DashMap with the top 3