Comments (4)
@domenukk - digging into the code a bit farther, it seems that using RandomState::with_seeds
should achieve the old new_with_keys
functionality.
e.g.
let st = RandomState::with_seeds(42, 1, 0 5);
let hasher = st.build_hasher();
build_hasher
just calls (private) AHasher::from_random_state
(https://docs.rs/ahash/latest/src/ahash/aes_hash.rs.html#73)
However, I still don't get consistency across multiple platforms (and I suspect 0.7 is the same)
from ahash.
I am in a similar boat. I've tried setting
default-features = false
then doing :
static HASH_KEY: usize = 12345;
lazy_static! {
static ref HASH_STATE: RandomState = {
set_random_source(NotRandomState).expect("Setting hash state to not-random");
RandomState::with_seed(HASH_KEY)
};
}
struct NotRandomState;
impl RandomSource for NotRandomState {
fn gen_hasher_seed(&self) -> usize {
HASH_KEY
}
}
fn hash_stuff(a: A, b: B) -> u64 {
let mut hasher = HASH_STATE.build_hasher();
a.hash(&mut hasher);
b.hash(&mut hasher);
hasher.finish().into()
}
This seems to produce self-consistent hashes between builds on the same platform.
However, on different platforms (e.g. aarch64) it produces different values.
Is there an easier or more reliable method of ensuring consistencency?
from ahash.
with_seeds is the method you are looking for.
However please note that aHash does not guarantee identical output across architectures, flags, or versions. For example when 0.8.1 is released, it will have performance improvements but the same data will hash to different values than it did in 0.8.0.
from ahash.
This is now better documented in 0.8.1:
https://docs.rs/ahash/0.8.1/ahash/random_state/struct.RandomState.html
from ahash.
Related Issues (20)
- test failure on s390x. HOT 1
- Significant performance regression from 0.8.6 to 0.8.7 HOT 11
- compile error: use of unstable library feature 'stdsimd' HOT 20
- feature request: ahash without length prefixing HOT 3
- Deterministic hash value HOT 2
- error[E0635]: unknown feature `stdsimd` HOT 19
- Significant bump in MSRV from 0.8.7 to 0.8.8 HOT 9
- No link to crates.io HOT 1
- RandomState has too many collisions in low order bits when hashing a u64 HOT 29
- Hashing `&T` yields different results compared to `T`
- Fragile build script: crate automatically enables "specialize" feature HOT 14
- ahash 0.8.11 breaks hashbrown? HOT 6
- Work around `swap_bytes` on WebAssembly HOT 1
- git source unaligned with crates.io release HOT 5
- Linking Errors with Specific Optimization Levels When Running Test Cases HOT 1
- rust v1.78 std simd feature removed HOT 1
- `set_random_source` never returns `Err(false)`
- Replace atomic-polyfill with portable-atomic
- Mismatch between published version on crates.io and tagged version in git repo for v0.8.11 HOT 8
- Suggestion: Alternative wrapper HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ahash.