#hash-map #atomic #rw-lock

clashmap

Sharded hashmap suitable for fast concurrent access

1 stable release

new 1.0.0 Jan 29, 2025

#301 in Concurrency

MIT license

135KB
3K SLoC

ClashMap

Conrad Ludgate's Dashmap Fork: Removes much of the unsafe from dashmap, and improves on the API

Sharded hashmap suitable for fast concurrent access.

ClashMap is an implementation of a concurrent associative array/hashmap in Rust.

ClashMap tries to implement an easy to use API similar to std::collections::HashMap with some slight changes to handle concurrency.

ClashMap tries to be very simple to use and to be a direct replacement for RwLock<HashMap<K, V>>. To accomplish these goals, all methods take &self instead of modifying methods taking &mut self. This allows you to put a ClashMap in an Arc<T> and share it between threads while still being able to modify it.

ClashMap puts great effort into performance and aims to be as fast as possible. If you have any suggestions or tips do not hesitate to open an issue or a PR.

version

documentation

downloads

minimum rustc version

Cargo features

  • serde - Enables serde support.

  • raw-api - Enables the unstable raw-shard api.

  • rayon - Enables rayon support.

  • inline - Enables inline-more feature from the hashbrown crate. Can lead to better performance, but with the cost of longer compile-time.

Contributing

ClashMap gladly accepts contributions! Do not hesitate to open issues or PR's.

I will take a look as soon as I have time for it.

Performance

A comprehensive benchmark suite, not yet including ClashMap, can be found here. As of the time of writing this, clashmap@1.0.0 is equivalent in performance to dashmap@6.1.0.

Special thanks

License

This project is licensed under MIT.

Dependencies

~1–6MB
~28K SLoC