Why is std::unordered_map slow, and can I use it more effectively to alleviate that?

The standard library’s maps are, indeed, inherently slow (std::map especially but std::unoredered_map as well). Google’s Chandler Carruth explains this in his CppCon 2014 talk; in a nutshell: std::unordered_map is cache-unfriendly because it uses linked lists as buckets.

This SO question mentioned some efficient hash map implementations – use one of those instead.

Leave a Comment