4 ms·
The author found that HashMap::get was taking most of the time and didn't swap the hashing function?? It's well known that Rust's default HashMap hashing funct
by brabel 3y ago
The author found that HashMap::get was taking most of the time and didn't swap the hashing function??
It's well known that Rust's default HashMap hashing function is slow because it's designed to be safe against DoS [1]. If you want your HashMap to be faster, just use a faster hashing function like ahash[2], which can be up to 40% faster.
[1] https://doc.rust-lang.org/book/ch08-03-hash-maps.html#hashing-functions https://doc.rust-lang.org/book/ch08-03-hash-maps.html#hashin...
[2] https://docs.rs/ahash/0.7.4/ahash/ https://docs.rs/ahash/0.7.4/ahash/
- ChrisSD 3y agoThey did swap the hashing function > Note that everywhere we refer to HashMap is actually an alias for fxhash::FxHashMap, which is just std::collections::HashMap with a more efficient hashing algorithm