DoumanAsh / xxhash-rust

Rust implementation of xxhash
Boost Software License 1.0
205 stars 20 forks source link

How it compares to rustc's hash function #38

Closed yyy33 closed 6 months ago

yyy33 commented 6 months ago

The rust compiler has an fxhash, which seems to be unencrypted as well, how does the speed of xxhash compare to its

DoumanAsh commented 6 months ago

Generally Rust's hash interface is not very good for performance of xxhash due to it re-creating state every time. But on large input (i.e. 1kb) it would generally out perform fxhash.

If you're only concerned with usage within hash map I believe default hasher would suit you more than enough as most of the time your input will be fairly small keys.

But if you need high performance outside hash map I recommend to not use default hasher for sure. Especially if you need handle fairly large inputs (e.g. file, other binary blobs)

Other notes to consider:

Do note that if you need uniquness prefer hashes that has at least 128 bytes output like xxh3

DoumanAsh commented 6 months ago

btw I believe default hasher is SipHasher13 for HashMap