@@ -196,15 +196,29 @@ fn test_resize_policy() {
196
196
//
197
197
// FIXME(Gankro, pczarn): review the proof and put it all in a separate README.md
198
198
199
- /// A hash map implementation which uses linear probing with Robin
200
- /// Hood bucket stealing.
199
+ /// A hash map implementation which uses linear probing with Robin Hood bucket
200
+ /// stealing.
201
201
///
202
- /// By default, HashMap uses a somewhat slow hashing algorithm which can provide resistance
203
- /// to DoS attacks. Rust makes a best attempt at acquiring random numbers without IO
204
- /// blocking from your system. Because of this HashMap is not guaranteed to provide
205
- /// DoS resistance since the numbers generated might not be truly random. If you do
206
- /// require this behavior you can create your own hashing function using
207
- /// [BuildHasherDefault](../hash/struct.BuildHasherDefault.html).
202
+ /// By default, `HashMap` uses a hashing algorithm selected to provide
203
+ /// resistance against HashDoS attacks. The algorithm is randomly seeded, and a
204
+ /// reasonable best-effort is made to generate this seed from a high quality,
205
+ /// secure source of randomness provided by the host without blocking the
206
+ /// program. Because of this, the randomness of the seed is dependant on the
207
+ /// quality of the system's random number generator at the time it is created.
208
+ /// In particular, seeds generated when the system's entropy pool is abnormally
209
+ /// low such as during system boot may be of a lower quality.
210
+ ///
211
+ /// The default hashing algorithm is currently SipHash 1-3, though this is
212
+ /// subject to change at any point in the future. While its performance is very
213
+ /// competitive for medium sized keys, other hashing algorithms will outperform
214
+ /// it for small keys such as integers as well as large keys such as long
215
+ /// strings, though those algorithms will typically *not* protect against
216
+ /// attacks such as HashDoS.
217
+ ///
218
+ /// The hashing algorithm can be replaced on a per-`HashMap` basis using the
219
+ /// `HashMap::default`, `HashMap::with_hasher`, and
220
+ /// `HashMap::with_capacity_and_hasher` methods. Many alternative algorithms
221
+ /// are available on crates.io.
208
222
///
209
223
/// It is required that the keys implement the [`Eq`] and [`Hash`] traits, although
210
224
/// this can frequently be achieved by using `#[derive(PartialEq, Eq, Hash)]`.
0 commit comments