An extensive benchmark of C and C++ hash tables

(jacksonallan.github.io)

32 points | by fanf2 2 days ago ago

4 comments

  • unclad5968 2 days ago ago

    Why does the STL use such a poor implementation? It says it's performance is due to chasing pointers and allocating/freeing each node individually. Are stl implemented not able to change the details due to backwards compatibility?

    • variadix 2 days ago ago

      The use of chaining and the requirement of pointer stability are written into the standard. Changing the implementation to do something else would require changing the standard, which would change the API contract, which would break existing code.

      • beached_whale a day ago ago

        I think Boost::unordered_map is a drop in replacement, but I think it is the breaking of existing code part. Not that they couldn't pop that behind an ABI flag.

      • cozzyd a day ago ago

        Yeah but they could add a better one with a different name (std::dict?)