~/talk

Mastering the unordered_map in C++

Talkat ACCU on Sea 2026 · 2026-06-17..06-20· [c-and-cpp]
links:none on file
slides:none on file

Benchmarks show std::unordered_map gives ~8–9x speedups over std::map at millions of keys (10M lookup example: map ~9× slower), but a poor hasher or crafted collisions can degrade it to O(n) — experiments show a bad hash making unordered_map ~100× slower than map and hash‑DOS attacks pinning a core with a few hundred KB of keys. Practical fixes: use reserve to avoid rehash spikes, write a good hash (hash_combine or salted/SipHash), and profile — a removed global lock doubled throughput in a real service. Alternatives: flat_map/Swiss tables trade insert cost for much better cache locality.

AI-written summary · about

  1. 0:00Introduction
  2. 1:24unordered_map as default
  3. 3:28Map vs unordered_map
  4. 8:11How unordered_map works
  5. 13:33Ordering trap pitfall
  6. 18:11Bad hash function
  7. 23:43Collision catastrophes
  8. 24:46Hidden rehashing costs
  9. 27:17Hash DoS attacks
  10. 31:35Flat map and alternatives
  11. 35:06When to use map
  12. 35:26Open addressing & cache
  13. 39:25Memory overhead
  14. 42:20Profiling performance
  15. 45:58Real-world performance
  16. 47:23Container choice guide
  17. 49:54Summary & Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.