-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce til::hasher for sucessive hashing of structs (#11887)
This commit serves two purposes: * Simplify construction of hashes for non-trivial structs This is especially helpful for ActionArgs * Improve hash quality by not needlessly throwing away entropy `til::hasher` is modeled after Rust's `std::hash::Hasher` and works similar. The idea is simple: A stateful hash function can hash multiple unrelated fields, without loosing entropy by running a finalizer after hashing each interim field. This is especially useful for modern hash functions, which often have a wider internal state than the output width. Additionally this improves performance for hash functions with complex finalizers. Most of this is of course a bit moot right now, considering that `til::hasher` is still based on STL's FNV1a algorithm, which offers a very poor hash quality. But counterintuitively, FNV1a actually benefits most from this PR: Since it lacks a finalizer entirely, this commit greatly improves hash quality as it encodes more data into FNV's state and thus improves randomness. ## PR Checklist * [x] I work here * [x] Tests added/passed ## Validation Steps Performed * No unusual behavior ✅
- Loading branch information
Showing
12 changed files
with
316 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.