Earlier quoted context omitted.
> It really says something about C that so many useful-but-small systems have a good chunk of code devoted to hash table implementations For this speed-obsessed project, I wouldn't have it any other way: Benchmarking hash lookups in an integer-keyed hash table. Table size: 8, keys: 1-8 ==== upb_inttable(seq): 410 M/s upb_inttable(rand): 334 M/s std::map (seq): 149 M/s std::map (rand): 170 M/s __gnu_cxx::hash_map (seq…
Summarizing your results, your hash table implementation is between five and ten times faster than STL and G++ generic maps, because G++, like most C++ compilers, imposes a substantial abstraction penalty on the use of templates — even though in theory that's not necessary. Is that right?
So at least part of the penalty there is simply choosing the wrong data structure.
Also, IIRC, both hash_map and std::map don't support a reserve call. Which means you pay for quite a few allocations.