Can You RVO?
reserved. © 2024 Bloomberg Finance L.P. All rights reserved. Can you RVO? Using Return Value Optimization for Performance in Bloomberg’s C++ Codebases CppCon 2024 September 16, 2024 Michelle D’Souza RVO? How many people here have heard about “Return Value Optimization”? 2 How many people here are experts on “Return Value Optimization”?© 2018 Bloomberg Finance L.P. All rights reserved. © 2024 Finance L.P. All rights reserved. © 2024 Bloomberg Finance L.P. All rights reserved. Return Value Optimization (RVO) 5© 2018 Bloomberg Finance L.P. All rights reserved. Agenda Questions at the end Source:0 码力 | 84 页 | 9.98 MB | 5 月前3What Volatile Means (and Doesn't Mean)
However, an optimizer might cause this code to fail. 17 Overly-Aggressive Optimization To see why optimization might be a problem, consider this variation on the code, which sends a '\r' and Volatile Means (and Doesn't Mean) Copyright © 2024 by Ben Saks and Dan Saks 0-8 Overly-Aggressive Optimization Although they’re mapped to memory locations, device registers aren’t ordinary memory. effects. Eliminating those side effects might cause device drivers to fail. 19 Overly-Aggressive Optimization Unfortunately, to the compiler, USTAT0looks like an ordinary object. Its state should change0 码力 | 32 页 | 901.80 KB | 5 月前3Branchless Programming in C++
BENCHMARK ● 03a, b – branch is not predicted, optimization works ● 03c, d – branch is well-predicted, no optimizationBranchless Computing 51 ADVANCED OPTIMIZATION – ALWAYS MEASURE ● Sometimes the compiler – Often using “conditional move” instructions (they are not branches) ● Compiler’s branchless optimization is usually better than yours ● In particular, this is almost always branchless in reality: return Branchless Computing 52 BENCHMARK ● 04c, d – optimization does not work with GCC ● with perf – no branchBranchless Computing 53 ADVANCED OPTIMIZATION – ALWAYS MEASURE ● Sometimes the compiler will0 码力 | 61 页 | 9.08 MB | 5 月前3Just-in-Time Compilation - J F Bastien - CppCon 2020
hardware. Static compilation can also devote an arbitrary amount of time to program analysis and optimization. This brings us to the primary constraint on JiT systems: speed A JiT system must not cause hardware. Static compilation can also devote an arbitrary amount of time to program analysis and optimization. This brings us to the primary constraint on JiT systems: speed A JiT system must not cause hardware. Static compilation can also devote an arbitrary amount of time to program analysis and optimization. This brings us to the primary constraint on JiT systems: speed A JiT system must not cause0 码力 | 111 页 | 3.98 MB | 5 月前3Undefined Behavior: What Every Programmer Should Know and Fear
= 0; j != n; j += 2) ++n2; } ● As written, loop overhead is incurred twice ● Very desirable optimization: void f(size_t n) { for (size_t j = 0; j != n; j += 2) ++n1, ++n2; }Undefined Behavior 19 Why Optimized code: for (size_t j = 0; j != n; j += 2) ++n1, ++n2; ● Is the optimization valid? ● If the loops terminate, then the optimization is valid ● If the first loop runs forever, n2 should not be incremented today ● Oversights or omissions in the standard – Some may be considered bugs in the standard ● Optimization-related reasons always remain – Compilers need to make assumptions they cannot proveUndefined0 码力 | 38 页 | 2.56 MB | 5 月前3Unraveling string_view: Basics, Benefits, and Best Practices
string_view • Using string_view safely • Intro to span • span vs. string_view • Case study of an optimization using string_view. 2Motivation • Consider a function foo which operates on an immutable string allocation. Ensure that string_view is not converted to string later. That will cause us to lose the optimization. 24 Where to use?• string_view can used in constexpr functions. • string constructors are constexpr (aka 'span>') return kKnownHosts; ^~~~~~~~~~~ < > Optimization: Using span, string_view in GetKnownHosts 48Using the above version, we immediately run into 0 码力 | 61 页 | 1.11 MB | 5 月前3TiDB v8.4 Documentation
Indexing· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 612 4.10.5 Other Optimization Methods · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 615 4.11 Troubleshoot· Understanding the Query Execution Plan · · · · · · · · · · · · · · · · · · · · · · · · · 1625 11.3.3 SQL Optimization Process · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 1709 11.3 · · · · · · 5236 15.3.22 SQL optimization· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 5241 15.3.23 Database optimization· · · · · · · · · · · · · · · ·0 码力 | 6705 页 | 110.86 MB | 9 月前3TiDB v8.5 Documentation
Indexing· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 617 4.10.5 Other Optimization Methods · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 620 4.11 Troubleshoot· Understanding the Query Execution Plan · · · · · · · · · · · · · · · · · · · · · · · · · 1927 11.3.3 SQL Optimization Process · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 2011 11.3 · · · · · · 5257 15.3.22 SQL optimization· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 5262 15.3.23 Database optimization· · · · · · · · · · · · · · · ·0 码力 | 6730 页 | 111.36 MB | 9 月前3TiDB 原理与实战
○ GitHub:https://github.com/zimulala Agenda ● A brief introduction of NewSQL ● TiDB ● Plan optimization ● Dist SQL ● Online DDL ● TiKV ● Feelings ● Q & A A brief introduction of NewSQL 1970s 2010 目前还有少量函数或功能未 实现 Plan optimization 逻辑优化 ● 主要依据关系代数的等价交 换做一些逻辑变换 物理优化 ● 主要依据数据读取、表连接方式、表连接顺序、排序等技术对查询进行优化。 TP Parse Logical Plan Physical Plan Exec Stat CBO RBO Plan optimization Logical plan ● Prune column count(*)from t group by id -> select 1 from t id is unique index ● Aggregation push down Plan optimization Decorrelation select * from t where t.id in (select id+1 as c2 from s where s.c1 < 10 and s.n0 码力 | 23 页 | 496.41 KB | 5 月前3TiDB v8.3 Documentation
Indexing· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 531 4.9.5 Other Optimization Methods · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 534 4.10 Troubleshoot· Understanding the Query Execution Plan · · · · · · · · · · · · · · · · · · · · · · · · · 1512 11.3.3 SQL Optimization Process · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 1595 11.3 · · · · · · 5184 15.3.22 SQL optimization· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 5189 15.3.23 Database optimization· · · · · · · · · · · · · · · ·0 码力 | 6606 页 | 109.48 MB | 9 月前3
共 160 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16