rapidhash - Very fast, high quality, platform-independent

June 2, 2026 · View on GitHub

Family of three hash functions: rapidhash, rapidhashMicro and rapidhashNano

Used by Chromium, NodeJS, Folly's F14, Fuchsia, Ninja, JuliaLang, ziglang, fb303, zxc, among others

Rapidhash
General purpose hash function, amazing performance across all sizes.
Surpasses 70GB/s on Apple's M4 cpus.
Clang-18+ compiles it to ~185 instructions, both on x86-64 and aarch64.
The fastest recommended hash function by SMHasher and SMHasher3.

RapidhashMicro
Designed for HPC and server applications, where cache misses make a noticeable performance detriment.
Clang-18+ compiles it to ~140 instructions without stack usage, both on x86-64 and aarch64.
Faster for sizes up to 512 bytes, just 15%-20% slower for inputs above 1kb.
Produces same output as Rapidhash for inputs up to 80 bytes.

RapidhashNano
Designed for Mobile and embedded applications, where keeping a small code size is a top priority.
Clang-18+ compiles it to less than 100 instructions without stack usage, both on x86-64 and aarch64.
The fastest for sizes up to 48 bytes, but may be considerably slower for larger inputs.
Produces same output as Rapidhash for inputs up to 48 bytes.

Streamable
The three functions can be computed without knowing the input length upfront.

Universal
All functions have been optimized for both AMD64 and AArch64 systems.
Compatible with gcc, clang, icx and MSVC.
They do not use machine-specific vectorized or cryptographic instruction sets.

Excellent
All functions pass all tests in both SMHasher and SMHasher3.
Collision-based study showed a collision probability close to ideal.
Outstanding collision ratio when tested with datasets of 16B and 67B keys:

Input LenNb HashesExpectedNb Collisions
1215 Gi7.06
1615 Gi7.07
2415 Gi7.07
3215 Gi7.010
4015 Gi7.04
4815 Gi7.07
6415 Gi7.06
8015 Gi7.011
9615 Gi7.06
12015 Gi7.08
12815 Gi7.06
1262 Gi120.1122
1662 Gi120.197
2462 Gi120.1125
3262 Gi120.1131
4062 Gi120.1117
4862 Gi120.1146
6462 Gi120.1162
8062 Gi120.1165
9662 Gi120.1180
12062 Gi120.1168

More results can be found in the collisions folder

Outstanding performance

Average latency when hashing keys of 4, 8 and 16 bytes

HashM1 ProM3 ProNeoverse V2AMD TurinRyzen 9700X
rapidhash1.79ns1.38ns2.05ns2.31ns1.46ns
xxh31.92ns1.50ns2.15ns2.35ns1.45ns

Peak throughput when hashing files of 16Kb-2Mb

HashM1 ProM3 ProM3 UltraM4Neoverse V2Ryzen 9700X
rapidhash47GB/s57GB/s61GB/s71GB/s38GB/s68GB/s
xxh337GB/s43GB/s47GB/s49GB/s34GB/s78GB/s

Long-input measurements were taken compiling with the RAPIDHASH_UNROLLED macro.

The benchmarking program can be found in the bench folder

Collision-based hash quality study

A perfect hash function distributes its domain uniformly onto the image.
When the domain's cardinality is a multiple of the image's cardinality, each potential output has the same probability of being produced.
A function producing 64-bit hashes should have a p=1/264p=1/2^{64} of generating each output.

If we compute nn hashes, the expected amount of collisions should be the number of unique input pairs times the probability of producing a given hash.
This should be (n(n1))/21/264(n*(n-1))/2 * 1/2^{64}, or simplified: (n(n1))/265(n*(n-1))/2^{65}.
In the case of hashing $15*2^{30} (~16.1B) different keys, we should expect to see \7.03$ collisions.

We present an experiment in which we use rapidhash to hash $68 datasets of \15*2^{30} (15Gi) keys each. For each dataset, the amount of collisions produced is recorded as measurement. Ideally, the average among measurements should be \7.03 and the results collection should be a binomial distribution. We obtained a mean value of \7.60, just \8.11% over \7.03. Each dataset individual result and the collisions test program can be found in the [collisions folder](https://github.com/Nicoshev/rapidhash/tree/master/collisions). The default seed \0$ was used in all experiments.

Ports

Java by hash4j
Rust by hoxxep
JavaScript by komiya-atsushi
Go by dwisiswant0