Moving an `int` Is Slow: Debug Performance Matters!
summary
Benchmark shows C++20's std::accumulate uses std::move in assignment and on -O0 that call is not inlined, producing 1.4× slowdown versus C++17 for an int-heavy workload. The concrete cause is that move/forward are ordinary template functions and result in extra function-call overhead in debug builds; workarounds include using -Og (where available), local macro wrappers or manual copying, and pushing compiler changes — GCC now folds moves in the front end while MSVC lacks an equivalent.
AI-written summary · about
chapters (6)
related talks
58mTo Move or Not to Move - An Interactive Analysis
01h 19mThis is C++: Uncompromised Performance, Undefined Behavior, & Move Semantics
01h 00mMoving Faster: Everyday efficiency in modern C++
01h 03mC++ Trivial Relocation Through Time
01h 00mThe Fine Details Behind C++ Containers And Algorithms
33mFaster Complex Numbers
57mC++ MythBusters Strike 2
58mRefresher on Containers, Algorithms and Performance
