Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Mostly for buck2, but starlark should benefit from it too. `ahash` is supposed to to be the fastest but: - it does not guarantee to produce the same result on different machines, and generally being deterministic is not their goal - moreover, `ahash` works the best when AES instructions are available, which are not always available. In particular, when compiled by default on x86_64 (`rustc -O`), ahash works without AES. `fxhash` is roughly the same as `fnv`, but processes words instead of bytes. For both starlark and buck2 being deterministic is very important. We try carefully to use ordered collections like `SmallMap` where deterministic output is needed, so technically deterministic hashing is not important. However, I'm not 100% sure that we do that correctly in every single place, and we won't make such error in the future, so stable hasher is safer option even if performance is suboptimal. For the same reason I picked `FxHasher64` instead of `FxHasher` to make hasher behave identically on 32 and 64 bit machines. However, `FxHasher64` (or `FxHasher`) hashes strings reading words in native endianness. So if someone compiles buck2 on POWER, it may behave differently. This is not an issue practically, but ideally we should fix it. `cquery deps(...)` spends most of the time hashing. This diff makes it better. Reviewed By: dtolnay Differential Revision: D52787463 fbshipit-source-id: d8e4cd52f36f7ed7d679d08cdf31e6d00421d84c
- Loading branch information