Using a custom hasher in hash maps
At the moment, the Wayland backend uses fnv for its hash maps, while all of the other backends (to my knowledge) just use the std SipHash algorithm. According to @kchibisov in Matrix, this was done because it improved benchmark times in Alacritty. If so, it would be nice to port this optimization to the other backends.
There are other hashing algorithms as well, like ahash, rustc_hash and nohash. We should compare all of these, as well as plain std hash maps, and see which one best fits our use case.
fnv is unmaintained, in the meantime the Rust ecosystem has largely moved towards hashbrown, which uses ahash under the hood.
I wouldn't call it unmaintained, it's complete, no changes required for it.
Though, ahash is a better default.
I've compared the some of the hash functions in alacritty and ahash was much better when doing get than fnv, I've also included default std, but it was way slower... The benchmark I've used is available here https://git.sr.ht/~kchibisov/hash-bench.
https://github.com/alacritty/alacritty/pull/7106#issue-1816728904
Found this while looking into Bevy's compile times. ahash takes on a few dependencies, including zerocopy, which is a surprisingly heavy crate to compile for what it does, and optionally serde. rustc-hash was benchmarked to be roughly ~1-4% faster in rustc, and comes without any dependencies. It might be worth looking into using it over ahash.
@james7132 I've filed an MR to move to foldhash, which has no dependencies and is faster than ahash.
Sounds good to me! I think this was the only instance of ahash left in Bevy's dependency tree.