C++ RVO: Return Value Optimization for Performance in Bloomberg C++ Codebases
Talkat CppCon 2024 · on Monday, 2024-09-16· at 15:15· Maple 3/4/5, 6700 North Gaylord Rockies Boulevard·
summary
Shows concrete examples, assembly and timings that demonstrate RVO mattering: measured loops show ~26% speedup when NRVO is allowed, assembly shows fewer instructions and a smaller stack frame. Reproduces failures (returning parameters, multiple returns, parenthesized or complex expressions, structured bindings, volatile, differing types) and tools/flags that affect it like -fno-elide-constructors and the GCC warning -Wnvo (GCC 14+). Uses GCC/Clang/MSVC builds, prints ctor/copy/move traces, and uses time and generated assembly to prove when RVO actually does and does not occur.
AI-written summary · about
chapters (14)
- 0:00RVO importance
- 2:14What is RVO
- 10:24Named vs unnamed RVO
- 15:17Move semantics and RVO
- 17:27When RVO fails
- 20:26Interactive examples
- 34:23Exceptions and RVO
- 37:20RVO with complex objects
- 42:17Structured bindings limits
- 44:25Parentheses trick
- 47:39RVO standard conditions
- 48:00Is RVO micro-optimization?
- 49:30Tooling for RVO
- 51:15Q&A
related talks
01h 05mThe Most Important Optimizations to Apply in Your C++ Programs
56mPractical C++17
32mOptimizing Away C++ Virtual Functions May Be Pointless
16mImprovements to RISC-V Vector code generation in LLVM
05mCopy Elision
08mOn "simple" Optimizations
42mFaster programs with your compilers autovectorization feature
38mOptimized String Processing in RISC-V: How Toolchain Improvements Can Boost Performance
