DashMap
A blazing-fast concurrent HashMap for Rust that shards state across locks instead of using one global RwLock.
Repository Health
Technical Analysis
DashMap implements a concurrent associative array for Rust, designed as a near drop-in replacement for RwLock<HashMap<K, V>>. Instead of guarding the whole map behind a single lock, it shards entries across many internal locks, so concurrent readers and writers touching different keys rarely contend with each other.
All of DashMap’s methods take &self rather than &mut self, which means a DashMap can be wrapped in an Arc and shared across threads while still supporting in-place mutation — a pattern that’s awkward to express safely with the standard library’s HashMap alone. The crate builds on hashbrown for its underlying table implementation and parking_lot for its locking primitives, and offers optional serde and rayon integrations for serialization and parallel iteration.
What You Get
- A sharded concurrent HashMap and HashSet with an API closely mirroring
std::collections::HashMap - All methods take
&self, so the map works behind anArcwithout an outerMutex/RwLock - Built on
hashbrown(SwissTable-style hashing) andparking_lotfor low-overhead locking - Optional
rayonfeature for parallel iteration over entries - Optional
serdefeature for (de)serializing the map - A
raw-apifeature exposing lower-level shard access for advanced use cases
Common Use Cases
- Shared in-memory caches accessed concurrently from multiple async tasks or threads
- Connection/session registries in servers where many threads insert, update, and evict entries
- Counters, rate-limiter state, or metrics maps updated from parallel workers
- Replacing a
Mutex<HashMap<_, _>>orRwLock<HashMap<_, _>>bottleneck identified via profiling
Under The Hood
Architecture — DashMap’s core (lib.rs) partitions the map into a fixed number of shards, each an independent hashbrown table guarded by its own parking_lot::RwLock; a key’s shard is selected by hashing, so operations against different shards proceed with no contention. mapref/setref modules provide guard types (Ref/RefMut) that hold a shard’s lock for the lifetime of the borrow, giving reference-like ergonomics without exposing the underlying lock directly. Tech Stack — pure Rust (2021 edition, MSRV 1.70), built on hashbrown for its table implementation, parking_lot/lock_api for lighter-weight locks than the stdlib’s, crossbeam-utils for cache-line padding to avoid false sharing between shards, and optional rayon/serde/arbitrary/typesize integrations behind Cargo features. Code Quality — set.rs and read_only.rs reuse the same sharded-map core to offer a DashSet and a read-only view without duplicating logic; the crate has shipped 60+ releases since 2019, though recent commit activity is low (health-score data shows low recent development activity despite the project’s maturity and continued adoption). API Design — the public API deliberately mirrors std::collections::HashMap (get, insert, remove, entry, iter) so existing HashMap code ports over with minimal changes, and the key ergonomic difference — all methods taking &self instead of &mut self — is called out prominently in the README specifically so users understand why the map is safe to share via Arc without an outer lock.
Used by 21 apps in this directory
Lemmy
Community · Social Media
Federated, self-hosted Reddit alternative with full community ownership and no corporate control.
Meetily
AI Assistants · Productivity
Privacy-first AI meeting assistant that transcribes and summarizes your meetings entirely on your local machine — no cloud, no data leakage.
OpenViking
AI Development · AI Memory · Databases
An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.
PostHog
Ab Testing Experimentation · Analytics · Developer Tools
The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.
QuestDB
Analytics · Databases
A high-performance, open-source time-series database built for financial market data, IoT telemetry, and real-time analytics, combining a zero-GC Java/C++ core with SIMD-accelerated SQL and a WAL-to-Parquet storage engine.
Tabby
AI Code Assistants
Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.
Temps
Analytics · Devops · Monitoring
A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.
TensorZero
Ab Testing Experimentation · AI Development · Monitoring
TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.
Trieve
AI Development · Developer Tools · Search
All-in-one self-hostable platform for hybrid search, RAG, recommendations, and analytics built on Rust and Qdrant.