HashMap, im::HashMap, picking # of buckets

How do Rust data structures like HashMap and im::HashMap decide how many buckets to pick? It seems we have the options of:

constant, too low => collisions, long lists, bad performance
constant, too high => many empty buckets, wasting memory
dynamically adjust => ???

HashBrown aims to keep 1/8 or more buckets empty and to align on powers of two. The SwissTable resources linked from the front page may have more technical details on why, but I'm not certain they do.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.