3 ms·
What's wrong with unordered map?
by RantyDave 7y ago
What's wrong with unordered map?
- ezoe 7y agoIt's implementation is buckets divided node based hash map. Theoretically, its order is good, but not that efficient in modern hardware where the memory access is heavily cached so the data locality is more important than saving the memory copy or memory size. Using the linked list to save some memory copy doesn't benefit at all and the overhead is far greater than simply copying the contagious large chunk of memory. Especially so if the data type is trivial so the simple byte by byte memcpy is suffice.
- gpderetta 7y ago> contagious normally I wouldn't point out an obvious autocorrect mistake, but this is really season-appropriate (or, better, inappropriate) :).
- ezoe 7y agoOh that's... not intended really.
- TwoBit 7y agoSo use unordered_map with an allocator that returns nodes from a small local memory?
- josefx 7y agoTo be useful that would require that the nodes are allocated in the order they appear in the map (and still has pointer overhead). Is that a given with an unordered map or does it break down the moment the map is rehashed?