Performance benchmarks for rapidhash
masterrapidhash is a high-performance, non-cryptographic hash function. In benchmarks, it is one of the fastest general-purpose options, often ranking second only to gxhash (which requires AES instructions and is not portable).
Benchmarking Methodology
- Raw Throughput: Measured via charts to evaluate performance across various input sizes.
- Real-world Workloads: Measured using the foldhash benchmark suite, which includes metrics for raw throughput, hashmap lookup (miss/hit), and hashmap insertion performance across common types.
Key Comparisons
- vs. foldhash: rapidhash uses the same integer buffer construction as foldhash but is faster for strings due to its specific algorithm. It also provides portable and streaming hash flavors.
- vs. gxhash:
gxhashis faster but requires AES instructions and is not portable. rapidhash is preferred for applications requiring portability or when hashing tuples and structs rather than just strings. - vs. SipHash: The default Rust hasher (SipHash) is included in benchmarks for comparison, though rapidhash generally provides higher throughput.
Best Practices for Benchmarking
To ensure consistent inlining and accurate performance results when benchmarking your own use cases, it is recommended to use the following profile settings in your Cargo.toml:
[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1