Not Leaving Performance On The Jump Table
summary
Shows that std::function incurs about 79% overhead versus raw function pointers in real benchmarks (function pointer ~46 μs, std::function ~81–86 μs) and that folly::Function cuts that by ~14% while the Zoo implementations cut another ~24% (about 35% over libc++). Uses compiler explorer and microbenchmarks with varying call entropy, builds a portable type‑erasure trampoline with a 16‑byte local buffer and reordered arguments to avoid null checks, shrinks object code, and runs in production on mobile at scale.
AI-written summary · about
chapters (6)
- 0:00Introduction and speaker background
- 2:58Performance on the jump table
- 16:32Runtime polymorphism challenges
- 29:48Problems with std::function
- 40:43Benchmarking and performance gains
- 57:51Q&A and closing remarks
related talks
31m“folly::Function: A Non-copyable Alternative to std::function”
32mWhy and How to Roll Your Own std::function Implementation
01h 02mFunctional C++
01h 01mHigher-order functions in Modern C++: existing techniques and function_ref
01h 29mHigher-order functions and function_ref
50mC++ Costless Abstractions: the compiler view
49mThe Evolution of Functional Programming in C++
57mA Tour of Polymorphism Techniques in C++
