2 ms·
>Rust is willing to completely fill its hashmap. Which is the correct decision for lower size(s). I use dynamic fill factor with 1 being the default with <= 16
by xxs 5y ago
>Rust is willing to completely fill its hashmap.
Which is the correct decision for lower size(s). I use dynamic fill factor with 1 being the default with <= 16 elements.
- dhosek 5y agoIt depends on how you're using the hash lookup though. In my case, most lookups would be expected to not return a value, so completely filling the small hashmap will cause retrievals to be slower since it has to keep going until it determines that there's no match.
- xxs 5y agoYes, of course. There are many use cases. Yet, in practical terms - most (90%) of look ups do return a value. For 'small' N, you can consider everything O(1). If you do know the use case - like most look ups fail, you can pick a proper impl. and tune it. Yet again, very few cycles are spent on small hash table look ups in general. Yet, a lot of (like really a lot) is spent on small hash table wasted memory. If you care about performance: measure, measure, measure... and know what you measure.