ogxd / gxhash

The fastest hashing algorithm 📈
https://docs.rs/gxhash
MIT License
798 stars 27 forks source link

Only hit the RNG once per thread #65

Open vlovich opened 6 months ago

vlovich commented 6 months ago

It looks like GxBuildHasher accesses the Rng on every construction. Can the technique from RandomState be used instead which only does the RNG once per thread & then simply adds 1 to the state used on each construction?

ogxd commented 6 months ago

Indeed, that would probably increase performance in scenarios where a BuildHasher is created for hashing only a few bytes. This RandomState w/ increment is interesting (and battle-tested since it's in the std), let's explore this.

First we might want to setup a benchmark to have a sense of the rng overhead relative to the hashing process and to get some before/after numbers.