Updating map_benchmarks: Send your hashmaps!

This page summarizes the projects mentioned and recommended in the original post on /r/cpp

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • fph-table

    Flash Perfect Hash Table: an implementation of a dynamic perfect hash table, extremely fast for lookup

    I believe that when the number of elements is larger than 4 (a rough estimation), the associative linear table won't be faster than ska::flat_hash_map or fph-table with the identity hash function. If you look at the benchmark results, you will find that the average lookup time may well be less than 2 nanoseconds when item number is smaller than one thousand on morden CPUs. For these two hash tables, there are only about ten instructions in the critical path of lookup. And this should be faster than the linear search in a associative table, where there are a lot of branches and comparing instructions. However, you should benchmark it youself to get the real conclusion. This is just a simple analysis on paper from mine. By the way, the associative table can be faster if it is implemented with hardware circuits or SIMD instructions.

  • google-sparsehash

    Clone of google-sparsehash

    google sparsehash would be interesting to see. From what I understand it's the predecessor to the Abseil containers. Would be nice to see a comparison

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

  • sparsepp

    A fast, memory efficient hash map for C++

    Also, I'm testing https://github.com/greg7mdp/sparsepp which is based on google's sparsehash

  • gtl

    Greg's Template Library of useful classes.

    AFAIK sparsepp has been dropped entirely in favor of the containers in GTL: https://github.com/greg7mdp/gtl

  • dense_hash_map

    A simple replacement for std::unordered_map

    https://github.com/Jiwan/dense_hash_map is also a good flat hash map.

  • qc-hash

    Extremely fast unordered map and set library for C++20

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

  • eytzinger

    Cache-friendly associative STL-like container with an Eytzinger (BFS) layout for C++

    https://github.com/mikekazakov/eytzinger should always beat flat_map except for very small maps. That said, for very small maps a simple linear search probably beats everything.

  • flat_hash_map

    A very fast hashtable

    I believe that when the number of elements is larger than 4 (a rough estimation), the associative linear table won't be faster than ska::flat_hash_map or fph-table with the identity hash function. If you look at the benchmark results, you will find that the average lookup time may well be less than 2 nanoseconds when item number is smaller than one thousand on morden CPUs. For these two hash tables, there are only about ten instructions in the critical path of lookup. And this should be faster than the linear search in a associative table, where there are a lot of branches and comparing instructions. However, you should benchmark it youself to get the real conclusion. This is just a simple analysis on paper from mine. By the way, the associative table can be faster if it is implemented with hardware circuits or SIMD instructions.

  • hashtable-bench

    A benchmark for hash tables and hash functions in C++, evaluate on different data as comprehensively as possible

    I believe that when the number of elements is larger than 4 (a rough estimation), the associative linear table won't be faster than ska::flat_hash_map or fph-table with the identity hash function. If you look at the benchmark results, you will find that the average lookup time may well be less than 2 nanoseconds when item number is smaller than one thousand on morden CPUs. For these two hash tables, there are only about ten instructions in the critical path of lookup. And this should be faster than the linear search in a associative table, where there are a lot of branches and comparing instructions. However, you should benchmark it youself to get the real conclusion. This is just a simple analysis on paper from mine. By the way, the associative table can be faster if it is implemented with hardware circuits or SIMD instructions.

  • llvm-project

    The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.

    I would be interested to see how good is https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ADT/DenseMap.h

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts