Effortless Performance Improvements in C++: std:unordered_map

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

JetBrains - Tell us how you use coding tools. You may win a prize!
Are you a developer or a data analyst? Share your thoughts about your coding tools in our short survey and get a chance to win prizes!
surveys.jetbrains.com
featured
InfluxDB – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com
featured
  1. flat_hash_map

    A very fast hashtable

    If you don't need all the guarantees provided by std::unordered_map (pointer stability is usually the big one), you can go a /lot/ faster with a map that uses open addressing.

    Some of my favorite alternative hash map implementations are ska::flat_hash_map and ska::bytell_hash_map from https://github.com/skarupke/flat_hash_map. They're fast, and the single header implementation makes them easy to add to a project. For my use cases they generally offer similar performance to abseil and folly F14.

    Don't be fooled by the fact that they haven't been updated in ~5 years. I've been using them for nearly that long and have yet to find any bugs.

  2. JetBrains

    Tell us how you use coding tools. You may win a prize! Are you a developer or a data analyst? Share your thoughts about your coding tools in our short survey and get a chance to win prizes!

    JetBrains logo
  3. unordered_dense

    A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion

    https://github.com/martinus/unordered_dense

    Check this one out, it's a successor to this idea. Boost also introduced a very performant flat_hash_map in 1.81

  4. robin-hood-hashing

    Discontinued Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20

    For anyone in a situation where a set/map (or unordered versions) is in a hot part of the code, I'd also highly recommend Robin Hood: https://github.com/martinus/robin-hood-hashing

    It made a huge difference in one of the programs I was running.

  5. CPython

    The Python programming language

    XOR is a bad way to do it, but there are ones that work much better that are described in answers to that post, and it's what other languages use in similar situations (e.g. tuples in Python and C#):

    https://github.com/python/cpython/blob/71db5dbcd714b2e1297c4...

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

  • Solving “Two Sum” in C with a tiny hash table

    1 project | news.ycombinator.com | 29 Jun 2023
  • A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion

    5 projects | /r/cpp | 4 Jul 2022
  • Hashing of integer keys in hash maps

    1 project | /r/cpp | 7 Mar 2022
  • how to do memory pool de-fragmentation?

    1 project | /r/gamedev | 3 Aug 2021
  • Fast And Memory Efficient C++ Hashtable Based On Robin Hood Hashing

    1 project | /r/programming | 23 May 2021

Did you know that C++ is
the 7th most popular programming language
based on number of references?