~/talk

Gotta Cache 'Em All: Optimize Your C++ Code By Utilizing Your Cache!

Talkat CppNorth 2025 · 2025-07-21..07-23· [c-and-cpp, web-performance]
links:none on file
slides:none on file

Replacing an unordered_map with a vector produces a 10x speedup in a production case (toy test showed ~15x) because contiguous memory and index lookup avoid hashing, pointer chasing, and cache misses; a 512 MB cache polluter is used to clear caches between runs. Benchmarks compare std::vector, std::set, std::unordered_set, boost::flat_set and boost::unordered_flat_set (boost unordered flat wins at large N; std::unordered_set wins small, vector wins for N<10). Measurement uses RDTSC, taskset, BIOS SMT off and memory fences; padding or thread_local eliminates 67% improvement from removing false sharing; cachegrind misses multi-core effects.

AI-written summary · about

  1. 0:00The 10x speedup mystery
  2. 2:03Data structures and cache
  3. 5:16How cache lines work
  4. 9:10Selecting data structures
  5. 13:27Benchmarking search performance
  6. 19:17Cache-friendly data placement
  7. 24:14Debugging micro-benchmarks
  8. 39:07Caches, threads, and false sharing
  9. 48:04Conclusion and Q&A
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 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
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
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.