aHash
A fast, DOS-resistant, AES-accelerated non-cryptographic hasher purpose-built for in-memory HashMaps
Repository Health
Technical Analysis
aHash is a Rust hashing algorithm designed exclusively for in-memory hash maps and sets — it is not a cryptographic hash and is explicitly unsuitable for network protocols, persisted hash values, or anywhere a stable, verifiable digest is required. It uses hardware AES instructions where available to achieve very high throughput while remaining a keyed hash: each HashMap instance gets a randomized seed, so hash outputs can’t be predicted without knowing that seed, which is what gives it DOS resistance against hash-flooding attacks.
Because aHash has no fixed output specification, its internal algorithm can change between versions to improve speed or fix any discovered weakness, meaning hash values are not portable across machines or versions and should never be persisted or transmitted. It passes the full SMHasher test suite for statistical hash quality, and is notably the default hasher used internally by hashbrown (and therefore relevant to Rust’s std HashMap ecosystem via that dependency), making it one of the most widely-deployed hashers in the Rust ecosystem despite deliberately narrow intended use.
What You Get
- A drop-in
Hasherimplementation plusAHashMap/AHashSetconvenience wrappers around std collections - AES-hardware-accelerated hashing for high throughput on supported CPUs
- Keyed, randomized hashing per HashMap instance to prevent hash-flooding DOS attacks
no_std-compatible builds and acompile-time-rngfallback for targets without runtime randomness- Optional
serdesupport for the AHashMap/AHashSet wrapper types
Common Use Cases
- Speeding up in-memory HashMap/HashSet-heavy Rust code where hashing overhead is a bottleneck
- Protecting public-facing services from hash-collision DOS attacks via keyed, randomized hashing
- Building on
no_stdor embedded targets that need a lightweight, allocation-free hasher - Underlying performance layer for other data-structure crates (e.g. hashbrown, which uses aHash by default)
Under The Hood
Architecture: aHash exposes an AHasher type implementing the standard library’s Hasher trait, combined with a RandomState type that generates a per-instance random seed so that HashMap<K, V, RandomState> (or the AHashMap/AHashSet wrappers) produce different hash outputs across different map instances — directly preventing the classic DoS pattern of feeding an application many keys engineered to collide under a fixed hash. Internally, the hash mixes input bytes using AES round instructions when the target CPU supports them, falling back to a portable non-AES implementation otherwise, with the exact algorithm treated as an implementation detail that may change between releases as faster or more DOS-resistant techniques are found.
Tech Stack: Nearly pure Rust (99.9% of tracked bytes), with feature flags for std (enables AHashMap/AHashSet, on by default), serde, runtime-rng (uses the getrandom crate for seeding, on by default), compile-time-rng (embeds compile-time-generated randomness for targets without OS randomness), and nightly-arm-aes for 32-bit ARM AES support. A no_std_test directory and smhasher subdirectory (containing the full SMHasher quality-test harness output) are checked directly into the repo.
Code Quality: Testing is comparatively lean for a widely-depended-upon crate — 3 test files under tests/ — but is supplemented by the checked-in SMHasher suite results demonstrating statistical hash-quality validation, and a compare/ directory benchmarking aHash against other hashers (FxHash, SipHash, etc.) with published performance charts in the README. With 45 contributors but 401 of the ~464 total commits from the single primary author, and zero recent commit velocity per the latest snapshot, this reads as a mature, feature-complete crate in low-churn maintenance mode rather than one under active development — consistent with a narrowly-scoped, already-optimized hashing primitive.
API Design: The library is designed as a true drop-in replacement — swapping std::collections::HashMap for HashMap<K, V, ahash::RandomState>, or using the AHashMap/AHashSet wrapper types, requires no other code changes, keeping adoption friction near zero. The README is explicit and prominent about aHash’s non-goals (not cryptographic, not for persisted/network hashes), which meaningfully reduces the risk of misuse despite the library exposing very few safety rails against it at the type level.
Used by 4 apps in this directory
Fluree DB
Databases
A temporal, verifiable graph database with git-like branching, integrated vector/text/geo search, and RDF/SPARQL/JSON-LD/openCypher support — benchmarked at 10.4x faster than the next database on the full Wikidata dump.
InfluxDB
Databases · Analytics
Open-source time-series database built for real-time ingest, fast SQL queries, and embedded Python automation — powered by Apache Arrow and Parquet.
Stalwart
Collaboration
All-in-one secure mail and collaboration server covering IMAP, JMAP, SMTP, CalDAV, CardDAV, and WebDAV in a single memory-safe Rust binary.
Volga
Data Engineering
A Rust-based real-time data processing engine for AI/ML feature computation, built on Apache DataFusion and Arrow — positioned as an alternative to Flink, Spark, Chronon, and OpenMLDB with unified streaming, batch, and request-time execution.