~/talk

The Hidden Performance Price of C++ Virtual Functions

Talkat CppCon 2022 · 2022-09-11..09-16· [rust]
links:none on file
slides:none on file

Shows measured costs, not a rant: a short virtual call costs about 20% extra (153 ms vs 126 ms) while long calls are almost identical (32.09 s vs 31.84 s); poor memory layout turns a 200 ms run into ~1.5 s (≈7–8×); unpredictable types hurt branch prediction (~<200 ms → ~500 ms, ~2.5×). Experiments use vector of 20 million objects, pointer shuffles and a prototype polymorphic vector. Tools reported: perf and Intel VTune, multitime and likwid. Fixes that work: per-type vectors, std::variant, type-based processing; the prototype approaches show measurable wins.

AI-written summary · about

  1. 0:00Introduction
  2. 2:07How virtual functions work?
  3. 2:35How virtual functions work - virtual tables
  4. 5:03How virtual functions work-function calls
  5. 7:21Initial Analysis - experiment
  6. 13:10Vector of pointers - experiment
  7. 16:03Vector of pointers - conclusion
  8. 20:03Compiler Optimizations - Example
  9. 22:33Compiler Optimizations - experiment
  10. 24:35Compiler Optimizations - conclusion
  11. 27:12Jump Destination Guessing - experiment
  12. 31:28Instruction Cache Evictions - experiment
  13. 36:08Instruction Cache Eviction - conclusion
~/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.