this post was submitted on 11 Oct 2023
14 points (100.0% liked)

Rust Programming

8159 readers
1 users here now

founded 5 years ago
MODERATORS
 

I'm curious as to how the hashbrown crate can have up to 2x performance on certain operations, even though it looks like the standard library's HashMap is just a wrapper for hashbrown.

I understand that a wrapper could add a small overhead, but 50% of the original performance is a bit silly, especially considering all of the functions in the wrapper are #[inline], so there should be no overhead in calling most functions.

Does anyone know the reason for this?

top 3 comments
sorted by: hot top controversial new old
[–] [email protected] 11 points 1 year ago

hashbrown uses aHash by default, which is much faster than std's SipHash-1-3

[–] [email protected] 7 points 1 year ago

I suppose it's because the article you're citing is from april 22nd, and that hashbrown has replaced old std hashmap in this commit, which hash been created on 24th.

I suppose (can't test myself) that if you do the test now (hashbrown against std), the performance difference would be negligeable beacuse you would be testing roughly the same algorithms.

[–] [email protected] 2 points 1 year ago

Stdlib uses SipHash, not HashBrown.