4 ms·
Try hashbrown. Author declares 8x improvement over standard HashMap. https://github.com/Amanieu/hashbrown https://github.com/Amanieu/hashbrown https://blog.wa
by v_lisivka 8y ago
Try hashbrown. Author declares 8x improvement over standard HashMap.
https://github.com/Amanieu/hashbrown https://github.com/Amanieu/hashbrown
https://blog.waffles.space/2018/12/07/deep-dive-into-hashbrown/ https://blog.waffles.space/2018/12/07/deep-dive-into-hashbro...
https://gankro.github.io/blah/hashbrown-insert/ https://gankro.github.io/blah/hashbrown-insert/
- steveklabnik 8y agoIt soon will be the standard hashmap!
- littlestymaar 8y agoDoes it still provide the DoS protection SipHash offered, or does that mean that Rust is moving from secure-by-default to fastest-by-default when it comes to HashMap ? If so it's kind of a big philosophical switch.
- rapsey 8y agoHashbrown is not about the hashing algorithm. It uses fx hash which is pretty commonly used in Rust. I imagine they will still keep SipHash
- littlestymaar 8y agoOK thanks. But that would mean the performance gain would not be as dramatic I guess ?
- Manishearth 8y agoIt's still pretty major, because SIMD, but not as dramatic https://github.com/Amanieu/hashbrown#performance https://github.com/Amanieu/hashbrown#performance Note that the hashbrown crate uses FxHash by default, so the second table is the fair comparison. When ported to the stdlib it will likely be changed to have SipHash as the default. For the standard hashmap, replacing SipHash with FxHash gets you a 4x perf boost. Replacing the standard hashmap with hashbrown gets you a 2x perf boost (when you're using FxHash, there are no numbers here for when you're using SipHash but I suspect it will still be significant, if smaller)
- littlestymaar 8y agoThanks a lot for the clarification!
- lower 8y agoThanks! I just replaced FnvHashMap with hashbrown::HashMap and get a 20% overall performance improvement in my workload (which is rather HashMap-heavy).