The a5hash()
function available in the a5hash.h
file implements a fast
64-bit hash function, designed for hash-table, hash-map, and bloom-filter
uses. Function’s code is portable, cross-platform, scalar, zero-allocation,
is header-only, inlineable C (C++ compatible). Compatible with 32-bit
platforms, but the use there is not recommended due to a lacking performance.
This function features a very high hashing throughput for small
strings/messages (about 11 cycles/hash for 0-64-byte strings). The bulk
throughput is, however, only moderately fast (10-15 GB/s), and that is for a
purpose… All newest competing “fast” hash functions try to be fast both in
common keyed string hash-maps, and in large data hashing. In most cases,
this is done for the sake of better looks in benchmarks as such hash functions
rarely offer streamed hashing required for large data or file hashing…
a5hash
was designed to be “ultimatively” fast only for common string/small
key data hash-maps and hash-tables, by utilizing “forced inlining” feature
present in most modern C/C++ compilers: this is easily achievable since in
compiled binary form, a5hash
is very small – about 400 bytes, depending on
compiler. Moreover, if the default seed (0) is used, or if a constant-size
data is being hashed, this further reduces the code size and increases the
hashing throughput.
a5hash
produces different hashes on big- and little-endian systems. This is
a deliberate design choice, to narrow down the scope of uses to run-time
hashing. If you need a reliable and fast hash function for files, with
portable hashes, the komihash is a
great choice.
In overall, a5hash
achieves three goals: ultimate