xxHash

xxHash

Hashing faster than RAM speed

A non-cryptographic hash algorithm, proposed in four flavors: XXH32, XXH64, XXH3_64bits and XXH3_128bits.

Get started Try it in your browser API docs Star
Linux Microsoft Azure RocksDB MySQL ClickHouse Minecraft HAProxy Netflix rsync NSight compute

and 43 other projects →

Choosing a variant

All four are fully supported and specified. They differ in output width and in speed — the benchmarks show by how much.

VariantOutputNotes
XXH3_64bits64-bitFastest, and the strongest on small inputs. The recommended default.
XXH3_128bits128-bitSame speed as XXH3_64bits, with a wider output.
XXH6464-bitFast on 64-bit platforms, and widely deployed.
XXH3232-bitFastest of the 32-bit hashes, and favoured on 32-bit targets.
All variants are stable. The same input always produces the same hash, in any version, on any platform. Hashes stored today remain valid tomorrow, as documented by the format specification.
Not cryptographic. xxHash is built for speed, not for resisting an adversary. Do not use it for signatures, password storage, or any place where an attacker chooses the input and profits from a collision.

Speed

Single-threaded bandwidth on a 100 KB input, which stays in CPU cache. The memcpy bar is measured from RAM instead — it is there to show where the memory wall sits, not as a like-for-like comparison.

XXH3 (AVX2)
59.4 GB/s
XXH128 (AVX2)
57.9 GB/s
XXH3 (SSE2)
31.5 GB/s
XXH128 (SSE2)
29.6 GB/s
memcpy, from RAM
28.0 GB/s
XXH64
19.4 GB/s
XXH32
9.7 GB/s

Measured with the open source benchmark program. On 32-bit targets the ranking shifts considerably in favour of 32-bit hashes — see the wiki.

Compare with other hash algorithms

Intel i7-9700K, Ubuntu x64 20.04, clang v10.0 -O3. Small data velocity is a rough measure of efficiency on short inputs; see the wiki for the detailed analysis.

HashWidthBandwidthSmall dataNote
XXH3 (AVX2)6459.4 GB/s133.1AVX2 support (optional)
XXH128 (AVX2)12857.9 GB/s118.1AVX2 support (optional)
XXH3 (SSE2)6431.5 GB/s133.1
XXH128 (SSE2)12829.6 GB/s118.1
memcpy28.0 GB/sfrom RAM, for reference
City646422.0 GB/s76.6
T1ha26422.0 GB/s99.0Slightly worse collisions
City12812821.7 GB/s57.7
XXH646419.4 GB/s71.0
SpookyHash6419.3 GB/s53.2
Mum6418.0 GB/s67.0Slightly worse collisions
XXH32329.7 GB/s71.9
City32329.1 GB/s66.0
Murmur3323.9 GB/s56.1
SipHash643.0 GB/s43.2
FNV64641.2 GB/s62.7Poor avalanche properties
Blake22561.1 GB/s5.1Cryptographic
SHA11600.8 GB/s5.6Cryptographic but broken
MD51280.6 GB/s7.8Cryptographic but broken

Try it

xxHash compiled to WebAssembly, running in this page. Nothing is uploaded. Useful as a reference oracle when writing a port.

or drop one anywhere in this section. Read in your browser, never uploaded.

XXH3_64bits
XXH3_128bits
XXH64
XXH32

Implementations

60 ports and bindings that produce xxHash-compatible digests. To write your own, follow the format specification and check yourself against the box above.

LanguageAuthorSource
C multithreadedShawn Bayerngithub.com/shawnbayern/xxHash
C# (std pkg)Microsoftlearn.microsoft.com/en-us/dotnet/api/system.io.hashing?view=net-9.0-pp
C# (port)Melnik Alexandergithub.com/uranium62/xxHash
C# (.net std 2.0)Sedat Kapanoğlugithub.com/ssg/HashDepot#xxhash
C++ (simple)Stefan Brummecreate.stephan-brumme.com/xxhash
C++ constexpr (XXH64)Daniel Kirchnergithub.com/ekpyron/xxhashct
C++ constexpr (XXH32)Takayuki Matsuokagithub.com/Cyan4973/xxHash/issues/496
C++ constexpr (XXH3)chys87github.com/chys87/constexpr-xxh3
C++ 17Red Gavingithub.com/RedSpah/xxhash_cpp
CrystalLucjan Suskigithub.com/methyl/xxhash
DMasahiro Nakagawagithub.com/repeatedly/xxhash-d
Dart (XXH3)SamJakobpub.dev/packages/xxh3
Elixir (nif)Ali Farhadigithub.com/farhadi/xxh3
Elixir (port)Mykola Konykgithub.com/ttvd/elixir-xxhash
ErlangPierre Matrigithub.com/pierresforge/erlang-xxhash
Erlang (XXH3)Ali Farhadigithub.com/farhadi/xxh3
Go (XXH64)Ahmed Waheedgithub.com/OneOfOne/xxhash
Go (XXH3)Jeff Wendlinggithub.com/zeebo/xxh3
Go + ASMCaleb Sparegithub.com/cespare/xxhash
HaskellHenri Verrokenhackage.haskell.org/package/xxhash-ffi
Haskell (port)Christian Mariehackage.haskell.org/package/xxhash
JavaAdrien Grandgithub.com/lz4/lz4-java/tree/master/src/java/net/jpountz/xxhash
Java (all, port)Dynatracegithub.com/dynatrace-oss/hash4j/blob/main/src/main/java/com/dynatrace/hash4j/hashing/XXH3_64.java
Java (XXH3, XXH128)James Z.M. Gaogithub.com/OpenHFT/Zero-Allocation-Hashing/blob/master/src/main/java/net/openhft/hashing/XXH3.java
JavaScript (WebAssembly)Michael Jungowww.npmjs.com/package/xxhash-wasm
JavaScript (port)Pierre Curtonpmjs.org/package/xxhashjs
JavaScript (nodeJS)Brian Whitenpmjs.org/package/xxhash
JavaScript (nodeJS, xxh3)Nhan Khonggithub.com/ktrongnhan/xxhash-addon
JavaScript (React Native)Alex Shumihingithub.com/pioner92/react-native-xxhash
JSX (static JavaScript)Yoshiki Shibukawawww.npmjs.org/package/xxhash.jsx
JuliaHanan Rosemaringithub.com/hros/XXhash.jl
KotlinMatthew Dolangithub.com/appmattus/crypto/tree/main/cryptohash
Lua (binding)Masatoshi Teruyagithub.com/mah0x211/lua-xxhash
Lua (jit, XXH32)szenskgithub.com/szensk/luaxxhash
Lua (jit, XXH64)Soojin Namgithub.com/sjnam/luajit-xxHash
OCamlPieter Goetschalckxopam.ocaml.org/packages/xxhash
PascalVojtěch Čiháksourceforge.net/projects/xxhashfpc
PerlSanko Robinsonmetacpan.org/module/Digest::xxHash
Perl (streaming)Bela Bodecsgithub.com/DoubleBB/digest-xxhash64
PHPNir Heimanngithub.com/nheimann1/php-xxhash
PHP (port)Scott Duttongithub.com/exussum12/xxhash
PHP7Craig R Megasaxongithub.com/Megasaxon/php-xxhash
PHP8Anatol Belskiphp.watch/versions/8.1/xxHash
PicoLispmpechgit.envs.net/mpech/xxhash-picolisp
PythonYue Dupypi.python.org/pypi/xxhash
RDirk Eddelbuettelgithub.com/eddelbuettel/digest
R (XXH3)mikefcgithub.com/coolbutuseless/xxhashlite
Ruby (port)Justin W Smithrubygems.org/gems/ruby-xxHash
Ruby (wrapper)Vasiliy Ermolovichrubygems.org/gems/xxhash
Ruby (digest::class)konsoleboxrubygems.org/gems/digest-xxhash
RustJake Gouldinglibraries.io/cargo/twox-hash
Rust (const xxh3)Arthur Martirosyancrates.io/crates/xxhash-rust
ScalaDesmond Yeunggithub.com/desmondyeung/scala-hashing
SwiftDaisuke Tgithub.com/daisuke-t-jp/xxHash-Swift
Tcl (XXH32, port)D. Bohdanwiki.tcl-lang.org/48790
Zigziglanggithub.com/Cyan4973/xxHash/issues/1001
Shells and assembly
Bash (port)Devin Husseygithub.com/easyaspi314/xxbash
Batch (XXH32, port)Antonio Aacinigithub.com/Aacini/xxHash32
sh (port)Jan Chrengitlab.com/rindeal/xxHashish
x86 assembly (XXH32)Antonio Aacinigithub.com/Aacini/xxHash32

Used by

53 projects that ship xxHash. Missing one? Open an issue.

Systems & Infrastructure

Databases

Games

Filters

File Transfer

Other