You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+23-2Lines changed: 23 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,32 @@
1
1
# Changelog
2
2
3
+
## 4.0.0 (20250901)
4
+
5
+
https://github.com/hoxxep/rapidhash/pull/43
6
+
7
+
### Breaking changes
8
+
-**`rapidhash::v3` micro/nano output change:** input lengths 5-7 were mismatching the intended C++ V3 output. The C++ rapidhash V3 has been [yanked and re-released as V3](https://github.com/Nicoshev/rapidhash/issues/33) to fix the bug, and this rust implementation will follow. This changes the hash outputs for `rapidhash_v3_micro_inline` and `rapidhash_v3_nano_inline` for inputs of size 5, 6, and 7 bytes.
9
+
-**`RapidBuildHasher` renamed and refactored** to `SeedableState`.
10
+
-**`RapidHasher<'s>` new lifetime parameter** added to support user-defined secrets via `SeedableState`.
11
+
-**`RapidHashMap` and `RapidHashSet` moved to crate top level** for convenience. The top level uses the `fast::` variants, and the `quality::` and `inner::` hashmaps have been removed. They can still be built manually using `inner::RandomState` if required. The `fast::` collection variants have been deprecated to be removed in a future major release.
12
+
13
+
### Additions
14
+
-**`nightly` feature** which improves str hashing performance by omitting the `0xFF` suffix write and adds likely/unlikely hints.
15
+
-**`SeedableState`**: a hasher builder which can be seeded with fixed or user-defined secrets. This replaces `RapidBuildHasher`, but still defaults to random seeds. It is slightly slower than `RandomState`.
16
+
17
+
### Performance improvements
18
+
-**Bounds check elision**: Improved `RapidHasher` by eliding extra bounds checks in some cases by using `assert_unchecked`.
19
+
-**Likely/unlikely hints**: Added stable likely/unlikely hints in various places to ensure small inputs are favoured.
20
+
21
+
### MSRV
22
+
-**MSRV reduced to 1.71.0** from 1.77.0 by removing const usage of `first_chunk`.
23
+
3
24
## 3.1.0 (20250809)
4
25
5
-
## Performance improvements
26
+
###Performance improvements
6
27
- Improved `RapidHasher` small string hashing performance by 1.5-15% depending on the benchmark, by reducing the small string hashing code size and allowing the compiler to inline more. Performance was also improved on big-endian platforms by reading native-endian bytes. The portable hashers (`rapidhash::v3` etc. modules) are unaffected by this change. [#37](https://github.com/hoxxep/rapidhash/pull/37)
7
28
8
-
## Fixes
29
+
###Fixes
9
30
- Fixed compilation on targets without atomic pointers. [#38](https://github.com/hoxxep/rapidhash/issues/38), [#39](https://github.com/hoxxep/rapidhash/pull/39)
Copy file name to clipboardExpand all lines: README.md
+17-10Lines changed: 17 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,8 @@ A rust implementation of [rapidhash](https://github.com/Nicoshev/rapidhash), the
4
4
5
5
-**High quality**, the fastest hash passing all tests in the SMHasher and SMHasher3 benchmarks. Collision-based study showed a collision probability that's close to ideal.
6
6
-**Very fast**, the fastest passing hash in SMHasher3. Significant peak throughput improvement over wyhash and foldhash. Fastest platform-independent hash. Fastest const hash.
7
-
-**Platform independent**, works on all platforms, no dependency on machine-specific vectorized or cryptographic hardware instructions. Optimised for both AMD64 and AArch64.
7
+
-**Platform independent and no-std compatible**, works on all platforms, no dependency on machine-specific vectorized or cryptographic hardware instructions. Optimised for both AMD64 and AArch64.
8
8
-**Memory safe**, when the `unsafe` feature is disabled (default). This implementation has also been fuzz-tested with `cargo fuzz`.
9
-
-**No dependencies and no-std compatible** when disabling default features.
10
9
-**Official successor to wyhash** with improved speed, quality, and compatibility.
11
10
-**Run-time and compile-time hashing** as the hash implementation is fully `const`.
12
11
-**Idiomatic**`std::hash::Hasher` compatible hasher for `HashMap` and `HashSet`.
@@ -21,12 +20,12 @@ A rust implementation of [rapidhash](https://github.com/Nicoshev/rapidhash), the
21
20
Following rust's `std::hash` traits, the underlying hash function may change between minor versions, and is only suitable for in-memory hashing. These types are optimised for speed and minimal DoS resistance, available in the `rapidhash::fast` and `rapidhash::quality` flavours.
22
21
23
22
-`RapidHasher`: A `std::hash::Hasher` compatible hasher that uses the rapidhash algorithm.
24
-
-`RapidHashBuilder`: A `std::hash::BuildHasher` for initialising the hasher with the default seed and secrets.
25
23
-`RandomState`: A `std::hash::BuildHasher` for initialising the hasher with a random seed and secrets.
26
-
-`RapidHashMap` and `RapidHashSet`: Helper types for using `RapidHasher` with `HashMap` and `HashSet`.
24
+
-`SeedableState`: A `std::hash::BuildHasher` for initialising the hasher with the custom seed and secrets.
25
+
-`RapidHashMap` and `RapidHashSet`: Helper types for using `fast::RandomState` with `HashMap` and `HashSet`.
27
26
28
27
```rust
29
-
userapidhash::fast::RapidHashMap;
28
+
userapidhash::RapidHashMap;
30
29
31
30
// A HashMap using RapidHasher for fast in-memory hashing.
32
31
letmutmap=RapidHashMap::default();
@@ -35,11 +34,11 @@ map.insert("key", "value");
35
34
36
35
```rust
37
36
usestd::hash::BuildHasher;
38
-
userapidhash::quality::RapidBuildHasher;
37
+
userapidhash::quality::SeedableState;
39
38
40
39
// Using the RapidHasher directly for in-memory hashing.
-`rand`: Enables using the `rand` library to more securely initialise `RandomState`. Includes the `rand` crate dependency.
95
94
-`rng`: Enables `RapidRng`, a fast, non-cryptographic PRNG based on rapidrng. Includes the `rand_core` crate dependency.
96
95
-`unsafe`: Uses unsafe pointer arithmetic to skip some unnecessary bounds checks for a small 3-4% performance improvement.
96
+
-`nightly`: Enable nightly-only features for even faster hashing, such as overriding `Hasher::write_str` and likely hints.
97
97
98
98
## Benchmarks
99
99
@@ -241,6 +241,13 @@ The benchmarks have been compiled with and without `-C target-cpu=native` on a v
241
241
-**Comparison to gxhash**: gxhash achieves its high throughput by using AES instructions and consistently outperforms the other accelerated hashers (ahash, th1a, xxhash3_64). It's a great hash function, but is not a portable hash function, requiring `target-cpu=native` or specific feature flags to compile. Gxhash is a great choice for applications that can guarantee the availability of AES instructions and mostly hash strings, but rapidhash may be preferred for hashing tuples and structs, or by libraries that aim to support a wide range of platforms.
242
242
- The default rust hasher (SipHasher) unexpectedly appears to run consistently faster _without_`target-cpu=native` on various x86 and ARM chips.
243
243
- Benchmark your own use case, with your real world dataset! We suggest experimenting with different hash functions to see which one works best for your use case. Rapidhash is great for fast general-purpose hashing in libraries and applications that only need minimal DoS resistance, but certain hashers will outperform for specific use cases.
244
+
- We recommend using `lto = "fat"` and `codegen-units = 1` in your `Cargo.toml` release and bench profiles to ensure consistent inlining, application performance, and benchmarking results. For example:
245
+
```toml
246
+
[profile.release]
247
+
opt-level = 3
248
+
lto = "fat"
249
+
codegen-units = 1
250
+
```
244
251
245
252
</details>
246
253
@@ -260,14 +267,14 @@ C++ compatibility is presented in `rapidhash::v1`, `rapidhash::v2`, and `rapidha
260
267
Rapidhash V3 is the recommended, fastest, and most recent version of the hash. Streaming is only possible with the rapidhash V3 algorithm. Others are provided for backwards compatibility.
261
268
262
269
### In-Memory Hashing
263
-
Rust hasing traits (`RapidHasher`, `RapidBuildHasher`, etc.) are implemented in `rapidhash::fast`, `rapidhash::quality`, and `rapidhash::inner` modules. These are not guaranteed to give a consistent hash output between platforms, compiler versions, or crate versions as the rust `Hasher` trait [is not suitable](https://github.com/hoxxep/portable-hash/?tab=readme-ov-file#whats-wrong-with-the-stdhash-traits) for portable hashing.
270
+
Rust hashing traits (`RapidHasher`, `RandomState`, etc.) are implemented in `rapidhash::fast`, `rapidhash::quality`, and `rapidhash::inner` modules. These are not guaranteed to give a consistent hash output between platforms, compiler versions, or crate versions as the rust `Hasher` trait [is not suitable](https://github.com/hoxxep/portable-hash/?tab=readme-ov-file#whats-wrong-with-the-stdhash-traits) for portable hashing.
264
271
265
272
- Use `rapidhash::fast` for optimal hashing speed with a slightly lower hash quality. Best for most datastructures such as HashMap and HashSet usage.
266
273
- Use `rapidhash::quality` where statistical hash quality is the priority, such as HyperLogLog or MinHash algorithms.
267
274
- Use `rapidhash::inner` to set advanced parameters to configure the hash function specifically to your use case.
268
275
269
276
## Crate Versioning
270
-
The minimum supported Rust version (MSRV) is 1.77.0.
277
+
The minimum supported Rust version (MSRV) is 1.71.0.
271
278
272
279
The rapidhash crate follows the following versioning scheme:
273
280
- Major for breaking API changes and MSRV version bumps or any changes to `rapidhash_v*` method output.
0 commit comments