Concurrent Data Structures
Recipe | Crates | Categories |
---|---|---|
Bounded Multi-producer Multi-consumer Queue | ||
dashmap | ||
flurry | ||
papaya |
Refer to the comparative benchmarks of concurrent HashMaps⮳.
dashmap
dashmap
⮳ is a fast concurrent HashMap
i.e. a concurrent associative array.
dashmap
⮳ tries to be a direct replacement for RwLock<HashMap<K, V>>
.
It allows multiple threads to concurrently read and write to the map with minimal contention, using a technique called "shard-based" or "bucket-based" concurrency. This makes dashmap
⮳ a good choice when you need a hash map that can be accessed frequently by multiple threads without significant performance bottlenecks.
Bounded Multi-producer Multi-consumer Queue
crossbeam-queue
⮳ provides various concurrent queue implementations in Rust, designed for efficient and safe communication between threads. It offers different queue types optimized for various use cases, including single-producer/single-consumer, multi-producer/multi-consumer, and bounded/unbounded queues. These queues are essential for building concurrent data structures and message-passing systems, enabling threads to exchange data without race conditions or memory safety issues.
flurry
flurry
⮳ is a concurrent hash table designed for high performance. It allows fully concurrent reads and highly concurrent updates. Its main type is functionally very similar to std::collections::HashMap
⮳. Its implementation is closely based on Java's java.util.concurrent.ConcurrentHashMap
. Even though all operations on the map are thread-safe and operate on shared references, retrieval operations do not entail locking, and there is not any support for locking the entire table in a way that prevents all access (doc).
papaya
papaya
⮳ offers a fast and ergonomic concurrent hash-table for read-heavy workloads.
- Ergonomic lock-free API - no more deadlocks!
- Powerful atomic operations.
- Seamless usage in async contexts.
- Extremely scalable, low-latency reads (see performance).
- Predictable latency across all operations.
- Efficient memory usage, with garbage collection powered by
seize
⮳. (doc)
Related Topics
- Async.
- Async Channels.
- Data Structures.
- Global Static.
- Rust Patterns.
- Send and Sync.
- Shared State.