Closed Zoxc closed 8 months ago
As far as licence, all of aHash is dual Apache 2.0 and MIT. This algorithm is not good though. There is no rightward propagation, so the low order bits are bad which are the ones used to select the bucket. It also still has the null terminated string problem. If you want something really basic, try doing this. (Here is the function def) That is very fast on these architectures, which I suspect is 99% of what people use for build hosts.
That logic is also giving up a lot of performance in its loop for strings, which I suspect may be important for compilation. If you are interested this might be good to combine with https://github.com/tkaitchuck/aHash/issues/58 which I have not yet started on.
It seems the performance of this has changed over time, now there's mostly regressions:
Benchmark | Before | After | |
Time | Time | % | |
🟣 winapi:check | 7.4555s | 7.4002s | -0.74% |
🟣 clap:check | 1.8083s | 1.8153s | 0.39% |
🟣 hyper:check | 0.2654s | 0.2652s | -0.07% |
🟣 syntex_syntax:check | 6.2656s | 6.2867s | 0.34% |
🟣 syn:check | 1.6118s | 1.6165s | 0.30% |
🟣 regex:check | 1.0042s | 1.0089s | 0.47% |
Total | 18.4107s | 18.3929s | -0.10% |
Summary | 1.0000s | 1.0011s | 0.11% |
@Zoxc do you want to re-benchmark / start a discussion about hashes on zulip?
This replaces the 64-bit hash function with a new one which performs better for rustc, but still isn't a good hash function.
This also adds some collision test adapted from aHash. It's MIT license claims Amanieu d'Antras as the copyright holder though (probably a copy paste error?). I'll ask @tkaitchuck to license that code under this crate's MIT/Apache 2.0 license.