revm icon indicating copy to clipboard operation
revm copied to clipboard

Use a faster hash for the state diff map

Open onbjerg opened this issue 3 years ago • 4 comments

The default hasher is pretty slow for HashMaps. We should consider using something like https://docs.rs/seahash/latest/seahash/

onbjerg avatar Mar 21 '22 01:03 onbjerg

Found this: https://gist.github.com/daboross/976978d8200caf86e02acb6805961195?permalink_comment_id=4205660#gistcomment-4205660

rakita avatar Aug 18 '22 14:08 rakita

@rakita yep, it seems faster than seahash according to that benchmark which also has several even better candidates https://github.com/rurban/smhasher

both are non-cryptographic and should be ok for some of the revm usecases

shekhirin avatar Aug 19 '22 14:08 shekhirin

@rakita yep, it seems faster than seahash according to that benchmark which also has several even better candidates https://github.com/rurban/smhasher

both are non-cryptographic and should be ok for some of the revm usecases

Should be okaу for all revm usecases, it is just i didnt spend time changing it 😅

Good link, thank you for sharing

rakita avatar Aug 19 '22 14:08 rakita

TIL that hashbrown already uses ahash by default, and revm uses hashbrown for all performance-critical things 🙂

/// Default hasher for `HashMap`.
#[cfg(feature = "ahash")]
pub type DefaultHashBuilder = ahash::RandomState;

source: https://github.com/rust-lang/hashbrown/blob/1d2c1a81d1b53285decbd64410a21a90112613d7/src/map.rs#L11-L13

shekhirin avatar Aug 21 '22 11:08 shekhirin

hashbrown it is :)

rakita avatar Sep 06 '22 23:09 rakita