There Are No Zero-cost Abstractions
summary
Argument: claiming zero-cost abstractions is false and dangerous. Case study: adding arena allocation to protocol buffers (rolled out from late 2013) shifts cost into compiler work, pushing 90/99th-percentile file compile times up until single-file compiles hit 15-minute compile timeouts; deploying C++ modules reduces but does not remove the cost. Another case: using unique_ptr introduces extra loads and exception handling paths that measurably increase latency unless careful ABI and moves are used. Practical rule: measure, prefer simpler abstractions, and choose where to pay the cost.
AI-written summary · about
chapters (8)
- 0:00Introduction and apology
- 1:54What abstractions cost
- 5:44Protocol buffers cost surprise
- 17:10Unique pointer overhead
- 28:46Function extraction trade-offs
- 33:01Guidelines for abstractions
- 35:51Abstractions as fire
- 36:35Q&A session
related talks
01h 31mZero-Cost Abstractions in C++ - High Performance Message Dispatch
01h 18mAbstraction: The True Superpower of C++
01h 02mThe Surprising Costs of void() (and Other Not-Quite-Innocuous Evils)
57mAbstraction: The True Superpower of C++
01h 31mWhen Abstractions Fix Too Much - Towards Flexible Library Design
01h 05mAbstraction Patterns: Making Code Reliably Better Without Deep Understanding
01h 23mRethink Polymorphism in C++
26mWhen Idioms Become Bottlenecks
