Expand description
A fork of the fnv crate from https://github.com/servo/rust-fnv. The code is forked since it
is small and to reduce the maintenance overhead of importing into other monorepos.
FNV is an implementation of the Fowler–Noll–Vo hash function.
§About
The FNV hash function is a custom Hasher implementation that is more
efficient for smaller hash keys.
The Rust Standard Library documentation states that while the default Hasher implementation,
SipHash, is good in many cases, it is notably slower than other algorithms with short keys, such
as when you have a map of integers to other values. In cases like these, FNV is demonstrably
faster.
Its disadvantages are that it performs badly on larger inputs, and provides no protection against collision attacks, where a malicious user can craft specific keys designed to slow a hasher down. Thus, it is important to profile your program to ensure that you are using small hash keys, and be certain that your program could not be exposed to malicious inputs (including being a networked server).
The Rust compiler itself uses FNV, as it is not worried about denial-of-service attacks, and can assume that its inputs are going to be small—a perfect use case for FNV.
Structs§
Constants§
- INITIAL_
STATE 🔒 - PRIME 🔒