Closed tkaitchuck closed 3 months ago
I performed a quick benchmark with runtime-rng enabled (the most common feature I suppose) and the time to hash a 10 byte string goes from 2.5ns to 12.3ns, which puts it in siphash territory.
Do you think we could take some liberties with the creation of RandomState from SmallState, like
let [a, _] = get_fixed_seeds();
AHasher::from_random_state(&RandomState {
k0: self.key as u64 ^ a[0],
k1: self.key as u64 ^ a[1],
k2: self.key as u64 ^ a[2],
k3: self.key as u64 ^ a[3],
_h: PhantomData::<T>,
})
This brings it down from 12ns to 4ns
@arthurprs The code you have there won't be sufficiently strong. But I have tried to speed it up. Give it another try.
I got 7ns for 3e14ceb and 6.3ns for 1e94eac. For context, it's 2.5ns for the regular ahash and 10.3ns for sip13.
I think it's good now, unless you can squeeze more out of it :rocket:
I think I should be able to lower the added overhead by another 20%.
@arthurprs Is e2ae7b7 any faster on your system? It should be, but it my tests it appears to be, but only by about the same margin as random variation, so I am not sure if it is significant.
I can confirm the latest commit (~5ns) is 12% faster than the previous.
Is an optional reduced size state. Fixes #158