Article illustration 1

In the high-stakes world of performance-critical systems, non-cryptographic hash functions are the unsung workhorses powering everything from database indices to distributed systems. The newly released rapidhash crate for Rust has entered this competitive space with bold claims: dethroning previous champions like wyhash to become the fastest portable hash function that passes all quality benchmarks.

The Performance Crown

RapidHash's benchmark results make a compelling case. Across diverse architectures—including Apple's M1 Max, AWS Graviton3, and Intel Xeon—it consistently ranks among the top performers in the rigorous SMHasher3 test suite. Crucially, it achieves this while maintaining perfect collision resistance scores where competitors like gxhash and fxhash falter.

Benchmark comparisons across architectures (Source: rapidhash GitHub)

Technical architect Nicolas De Carli designed RapidHash around three pillars:

  1. Raw Speed: 3-4x faster than Rust's default SipHasher, with significant throughput improvements over wyhash
  2. Platform Independence: No reliance on AES-NI or other hardware-specific instructions
  3. Memory Safety: Default safe implementation with optional unsafe feature for edge performance gains

Rust-Centric Implementation

The crate provides both portable hashing (for stable output across versions) and in-memory hashing optimized for Rust collections:

use rapidhash::fast::RapidHashMap;

// High-speed HashMap alternative
let mut cache = RapidHashMap::new();
cache.insert("session_token", user_id);

// Portable hashing for consistent outputs
use rapidhash::v3::rapidhash_v3_seeded;
assert_eq!(rapidhash_v3_seeded(b"critical", &secrets), 0x8a5e...);

Notably, it addresses a key limitation in Rust's hashing ecosystem: "The standard library hashing traits aren't suitable for portable hashing," the documentation notes, hinting at future PortableHash trait implementation.

Practical Applications

Beyond raw speed, RapidHash solves real-world engineering challenges:

  • Streaming Support: Hash large files without loading entire contents into memory
  • Cross-Language Compatibility: Matches C++ RapidHash outputs for interop scenarios
  • Minimal DoS Resistance: Randomized secrets prevent trivial collision attacks
  • Embedded Readiness: no-std support for resource-constrained environments

The accompanying CLI tool demonstrates practical utility:

# Hash files 30% faster than SHA1 alternatives
echo "production.log" | rapidhash --v3

The Tradeoff Space

While gxhash outperforms RapidHash in string-heavy workloads when AES instructions are available, RapidHash maintains dominance in platform-agnostic scenarios and struct/tuple hashing. As benchmarks reveal, it strikes a unique balance—delivering near hardware-accelerated speeds without sacrificing portability or quality guarantees.

ARM performance comparisons (Source: rapidhash GitHub)

For developers building cross-platform systems where hash stability and collision resistance matter—whether for distributed caches, security-sensitive routing, or analytics algorithms—RapidHash presents a compelling new option in Rust's hashing arsenal. Its emergence signals continued innovation in low-level performance engineering, proving that carefully designed algorithms can still extract remarkable speed from modern hardware.

Source: rapidhash GitHub Repository