Repository navigation
v3.0.0
Big performance improvements, and potentially rust's fastest general-purpose hasher!
Breaking changes
- Replaced
FNVwith aSPONGEconfiguration withRapidHasherto improve integer and tuple hashing performance. RandomStateremoved thewith_seedandwith_seed_and_static_secretsmethods to reduce the struct size. Please raise a GitHub issue if you need aSeededState-style hash builder for the in-memoryRapidHasher.- Added a
RapidSecretstype for all versions to generate seeds and secrets for HashDoS-resistant hashing. This makes generating unique seeds/secrets easier for persistent hashing use cases.rapidhash::v*portable hashing functions now all take a&RapidSecretsargument as a seed.- For full compatibility with the old integer seeds, instantiate
RapidSecrets::seed_cpp(u64)with your integer seed which will continue to use the default secrets. - For minimal DoS resistance, use
RapidSecrets::seed(u64)to generate a new seed and secrets.
RapidHasherremoved the oldwrite_constandfinish_constmethods as they were unlikely to be used and may cause confusion.rapidhash_v*_innermethods have a newAVALANCHEconst argument to control whether they should avalanche the output. Setting this totruewill match the default hash output and C++ implementation for the highest quality hashing. Turning off avalanching will reduce the hash quality, but improve performance, especially for small inputs.- Fixed the
rapidhash::v1V1_BUGargument to actually match the originalv1.x.xcrate behaviour, which changes the hash output. The if statement was fundamentally wrong in thev2.x.xcrate and failing to hash some bytes, apologies. This now has a proper test to prevent future regressions.
Additions
rapidhash::rng::rapidrng_fast_non_portable: a slightly faster, lower-quality RNG that also has optimisations for u32 platforms without wide-arithmetic support. Excellent for generating fixtures in our WASM benchmarks.
Deprecations
- The V1 and V2
rapidhash_filemethods have been deprecated, with a note to userapidhash::v3instead. This is because they aren't streaming-compatible hashing algorithms which may be misleading if someone has not read the documentation in detail. They will continue to be included for the foreseeable future as they provide the CLI functionality.
Performance improvements
RapidHashersignificantly improved performance hashing integers, tuples, and integer types using the newSPONGEconfiguration in both fast and quality modes.RapidHashernow uses a non-portable mixing function for an improvement on platforms with slow wide arithmetic, such as wasm32.rapidhash::v3has a healthy performance improvement for mid-size input lengths by skipping the 112+ length setup/teardown.