-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up hasher discussion on HashMap #36557
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,15 +196,29 @@ fn test_resize_policy() { | |
// | ||
// FIXME(Gankro, pczarn): review the proof and put it all in a separate README.md | ||
|
||
/// A hash map implementation which uses linear probing with Robin | ||
/// Hood bucket stealing. | ||
/// A hash map implementation which uses linear probing with Robin Hood bucket | ||
/// stealing. | ||
/// | ||
/// By default, HashMap uses a somewhat slow hashing algorithm which can provide resistance | ||
/// to DoS attacks. Rust makes a best attempt at acquiring random numbers without IO | ||
/// blocking from your system. Because of this HashMap is not guaranteed to provide | ||
/// DoS resistance since the numbers generated might not be truly random. If you do | ||
/// require this behavior you can create your own hashing function using | ||
/// [BuildHasherDefault](../hash/struct.BuildHasherDefault.html). | ||
/// By default, `HashMap` uses a hashing algorithm selected to provide | ||
/// resistance against HashDoS attacks. The algorithm is randomly seeded, and a | ||
/// reasonable best-effort is made to generate this seed from a high quality, | ||
/// secure source of randomness provided by the host without blocking the | ||
/// program. Because of this, the randomness of the seed is dependant on the | ||
/// quality of the system's random number generator at the time it is created. | ||
/// In particular, seeds generated when the system's entropy pool is abnormally | ||
/// low such as during system boot may be of a lower quality. | ||
/// | ||
/// The default hashing algorithm is currently SipHash 1-3, though this is | ||
/// subject to change at any point in the future. While its performance is very | ||
/// competitive for medium sized keys, other hashing algorithms will outperform | ||
/// it for small keys such as integers as well as large keys such as long | ||
/// strings, though those algorithms will typically *not* protect against | ||
/// attacks such as HashDoS. | ||
/// | ||
/// The hashing algorithm can be replaced on a per-`HashMap` basis using the | ||
/// `HashMap::default`, `HashMap::with_hasher`, and | ||
/// `HashMap::with_capacity_and_hasher` methods. Many alternative algorithms | ||
/// are available on crates.io. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this could mention "such as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
/// | ||
/// It is required that the keys implement the [`Eq`] and [`Hash`] traits, although | ||
/// this can frequently be achieved by using `#[derive(PartialEq, Eq, Hash)]`. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there perhaps a wikipedia article or something we could link to here with "HashDoS attacks" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to find anything that seems like a particularly good source to link to, unfortunately.