ogxd / gxhash

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

Add no `no_std` support #55

Open ogxd opened 9 months ago

notsatvrn commented 9 months ago

It would be possible to get the hasher module working if rand was swapped out for rand_chacha in GxBuildHasher and if it was given a constant seed in no_std environments.

const-random could be used, or the seed could be generated in the build script.

notsatvrn commented 9 months ago

I got this working, generating the seed using the latter method here. I wanted to avoid drawing in more dependencies, and this actually reduces the number of dependencies, as rand depends on all of these.

ogxd commented 9 months ago

Interesting, so if I understand correctly, with your changes, the Hasher remains even in no std builds, but with the following subtleties:

The author of ahash has done something similar, but making a separate crate for the build time random. Maybe we can reuse it to avoid the complexity introduced in build.rs

notsatvrn commented 9 months ago

Switched over to const-random here (also fixed the entopy issue here :p)

ogxd commented 9 months ago

Nice! I have just cherry-picked your changes. Next step is to have this covered by tests/CI and add a few lines about it in the readme. I can do it when I have some time this week.

ogxd commented 4 months ago

Hello! I'm sorry I haven't provided any update here. The no_std is still very relevant. Since there might be some changes regarding the Hasher construction and the dependencies, I've cherry-picked the first commit of this PR, even if the no_std removes the Hasher. This can be done as a second step once we have figured out what's best for the Hasher seeds generation.

https://github.com/ogxd/gxhash/pull/74