Can You RVO?## +24 ## Can You RVO? Using Return Value Optimization for Performance in Bloomberg C++ Codebases MICHELLE FAE D'SOUZA Can You RVO? How many people here have heard about “Return Value Optimization” Optimization (RVO) TechAtBloomberg.com © 2024 Bloomberg Finance L.P. All rights reserved. C P ## What is RVO? Including the types of RVO & compiler support. Anti-patterns that prevent RVO Some examples examples (with prize) P ## Using RVO for performance gains Questions at the end ## The History of RVO Nancy Wilkinson implemented it in CFront 1 Walter Bright's Zortech Compiler Lajoie/Stump0 码力 | 84 页 | 9.98 MB | 1 年前3
Things Happening in SG14attributes ## • [[no_copy]] • Annotate types and function arguments with [[no_copy]] if only move and RVO are acceptable. Example: [[no_copy]] SomeContainerFoo(); [[no_copy]] SomeType Bar(); // categories ## P2966 requests: attributes • [[rvo]] • Annotate functions with [[rvo]] to ensure calls to these functions only compile if used in a RVO situation • Analogous to [[no_copy]] • There might might be a basis in P2025 and in Clang's non-standard [[musttail]] attribute • Example: [[rvo]] X f(); // ... auto x0 = f(); // Ok X x1; // x1 = f(); // not Ok ## P2966 requests: attributes ## •0 码力 | 148 页 | 1009.97 KB | 1 年前3
Hidden Overhead of a Function APImaterialized until needed, and then it is constructed directly into the storage of its final destination. RVO: how it works Itanium C++ ABI 3.1.3.1 Non-trivial Return Values If the return type is a class type in the function prototype, preceding all other parameters, including the this and vTT parameters. RVO: how it works Itanium C++ ABI 3.1.3.1 Non-trivial Return Values If the return type is a class type and only when necessary! ## +24 ## Can You RVO? Using Return Value Optimization for Performance in Bloomberg C++ Codebases MICHELLE FAE D'SOUZA ## RVO: inserting a function result into a container0 码力 | 158 页 | 2.46 MB | 1 年前3
The Surprising Costs of Voidnot use a local vector and return it, you say? I wonder too... I see this pattern quite a lot... Is RVO misunderstood? ## The case of void() member functions // real-life code... class Keywords essentially solve most to-be-initialized problems … and you’ll reap some return value optimization (RVO) benefits! ## The case of the unnecessary initializations #includeusing std::puts; struct ~Noisy() We have one less variable around, and since we’re initializing n with the return value of f, RVO kicked in! ## The case of the unnecessary initializations Noisy f(Noisy n) { return n; int main() 0 码力 | 189 页 | 60.10 MB | 1 年前3
The Roles of Symmetry And Orthogonality In DesignSymmetry C++ Techniques to cheat object lifecycle symmetry: • (Named-)Return Value Optimization (RVO, NRVO) to transfer instance • “Pilfer” or transfer object state: • xvalues ( $ &\& $ ) (since Member-function binary operator overloads (left- operand is always *this) (Named-)Return Value Optimization (RVO, NRVO) to transfer instance xvalues ( $ &\& $ ) (since C++11) to pilfer or transfer instance state") • Temporary objects (i.e., prvalue “materialization”) • xvalues (“eXpiring values”) • RVO, NRVO (Named-Return Value Optimization) ## Hierarchy Hygiene C++ inheritance exhibits ___ outstanding0 码力 | 151 页 | 3.20 MB | 1 年前3
PyWebIO v1.8.1 使用手册F V V B VLVOUH □W ¥ □WÊf dú çD & 65,§3 Ÿn®!‡}3Ç3 ŸD 85/®85/V R • PDQLIHR/RVO GLFW : HE_DSSOLFDWKRWVS_PDQLIHR/RVO 86 GRHVE:0DQLFRQ/Q/LJX7UKDWURQWXU DGG DVKRUWFXW WRWKHRPDQG ODXQFKWKHDSS OJWKHWKGHIDXOW0 码力 | 158 页 | 7.48 MB | 2 年前3
PyWebIO v1.8.2 使用手册F V V B VLVOUH □W ¥ □WÊf dú çD & 65,§3 Ÿn®!‡}3Ç3 ŸD 85/®85/V R • PDQLIHR/RVO GLFW : HE_DSSOLFDWKRWVS_PDQLIHR/RVO 86 GRHVE:0DQLF/R/Q/LJX7UKDWURQWXU DGG DVKRUWFXW WRWKHKRPDQG ODXQFKWKHDSS OJWKHWKGHIDXOW0 码力 | 160 页 | 7.48 MB | 2 年前3
C++高性能并行编程与优化 - 课件 - 17 由浅入深学习 map 容器e = get_Holder(); //// auto &s = e.s; //// auto &i = e.i; //// return s; //// RVO not applied to reference } ## 没有语法糖前,迭代器遍历的原本模样 - 看起来很高级的 for (auto tmp: m) 只是 C++17 的语法糖,他实际上会被转换成:0 码力 | 90 页 | 8.76 MB | 2 年前3
Some Things C++ Does Rightonly does a single pass • … and might at the same time benefit from the return value optimization (RVO) better # A word about beauty and elegance templateauto f_g_x(F f, G 0 码力 | 228 页 | 2.47 MB | 1 年前3
Comprehensive Rust(简体中文) 202412Rust 编译器能够执行返回值优化 (RVO)。 • In C++, copy elision has to be defined in the language specification because constructors can have side effects. In Rust, this is not an issue at all. If RVO did not happen, Rust0 码力 | 359 页 | 1.33 MB | 1 年前3
共 18 条
- 1
- 2













