Skip to content
0:00 / 0:00

#c++#benchmarking#compileroptimization

CppCon 2015: Chandler Carruth "Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My!"

CppCon

189K subscribers • 94 videos on Hallway • Conference channel

YouTube
  • Recommended by 4 people: 3 on Hacker News and 1 curated list.
  • A classic. People kept recommending it from 2015 to 2020.
  • Presented by Chandler Carruth

Intermediate. Assumes working knowledge.

188K views11 years ago4 recommendations

Systems programmingProgramming languagesC++Performance and optimizationCompilers and interpreters

Chandler Carruth explains how to write effective C++ benchmarks and analyze performance without compiler optimizations getting in the way.

Cppcon.org — A primary use case for C++ is low latency, low overhead, high performance code. But C++ does not give you these things for free, it gives you the tools to control these things and achieve them where needed. How do you realize this potential of the language? How do you tune your C++ code and achieve the necessary performance metrics? This talk will walk through the process of tuning C++ code from benchmarking to performance analysis. It will focus on small scale performance problems ranging from loop kernels to data structures and algorithms. It will show you how to write benchmarks that effectively measure different aspects of performance even in the face of advanced compiler optimizations and bedeviling modern CPUs. It will also show how to analyze the performance of your benchmark, understand its behavior as well as the CPUs behavior, and use a wide array of tools available to isolate and pinpoint performance problems. The tools and some processor details will be Linux and x86 specific, but the techniques and concepts should be broadly applicable. -- Chandler Carruth leads the Clang team at Google, building better diagnostics, tools, and more. Previously, he worked on several pieces of Google’s distributed build system. He makes guest appearances helping to maintain a few core C++ libraries across Google’s codebase, and is active in the LLVM and Clang open source communities. He received his M.S. and B.S. in Computer Science from Wake Forest University, but disavows all knowledge of the contents of his Master’s thesis. He is regularly found drinking Cherry Coke Zero in the daytime and pontificating over a single malt scotch in the evening. -- Videos Filmed & Edited by Bash Films: BashFilms.com Work at Hudson River Trading (HRT): tinyurl.com/safxfctf

Why it's here

4 people recommend this

What people say. Recommended as an eye-opening guide to benchmarking C++ and understanding how compilers optimize or eliminate benchmark code.

Moments people linked to

humanrebaron Hacker News • Recommends

On “Why I don't spend time with Modern C++ anymore”

Here's a few: - "Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My!" link to this video - "Understanding Compiler Optimization" link - "Optimizing the Emergent Structures of C++" link - "Efficiency with Algorithms" link The first one is really good if you've never benchmarked anything in a Linux environment. Or if you otherwise want to learn how to investigate how C++ gets turned into machine code.

programming-talkscurated list on GitHubRecommends

Under “C++”

Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My! 01:29:53 by **Chandler Carruth** (2015)

kbensonon Hacker News • Recommends

On “Do you know how much your computer can do in a second?”

Interestingly, there's quite a bit that's needed to ensure you bypass some compiler optimizations. Here's an ey-opening (for me) talk1 on benchmarking C++ and compilers which touched on it. 1: link to this video

thomashusaon Hacker News • Recommends

On “When Bloom filters don't bloom”

There is a very interesting talk 1 by Chandler Carruth that I stumbled upon last weekend that is very much related to this 1 link to this video

Chandler Carruthon Stack Overflow • Mentions

On “Enforcing statement order in C++”

I'd like to try to provide a somewhat more comprehensive answer after this was discussed with the C++ standards committee. In addition to being a member of the C++ committee, I'm also a developer on the LLVM and Clang compilers. Fundamentally, there is no way to use a barrier or some operation in the sequence to achieve these transformations. The fundamental problem is that the operational semantics of something like an integer addition are totally known to the implementation. It can simulate them, it knows they cannot be observed by correct programs, and is always free to move them around. We could try to prevent this, but it would have extremely negative results and would ultimately fa…

u/bgs11235in r/ProgrammingLanguages • Mentions

How to measure (Question) I would first like to start where I'm coming from using Chandler Carruth's 2015 Cpp con talk. There is a problem where a bottleneck was traced to an access control system that checked user queries against a long table of rules to see what access they were allowed, a problem very similar to how a firewall or file system checks permissions Ken Thompson was able to get a general 20x improvement where it was outperformed five fold (100x over the first implementation) with a trivial re-ordering by just making the most used rule the first one to be looked at. My question is how should we measure our programming languages in a way where we have clean data couple…

P. Mattioneon Stack Overflow • Mentions

…optimize. But I know that foo() will modify the memory somewhere, and the result will be observable eventually. Will the following prevent statement reordering and get the correct timing in this case? #include <chrono> #include <iostream> //I believe this tells the compiler that all memory everywhere will be clobbered? //(from his cppcon talk: link to this video __attribute__((always_inline)) inline void DoNotOptimize() { asm volatile("" : : : "memory"); } // The compiler has full knowledge of the implementation. s……
6View the answer

misnomeon Hacker News • Mentions

On “Why Const Doesn't Make C Code Faster”

> Anecdote: Optimum C blew away all the other C compilers on a magazine benchmark article because it figured out that the benchmark code did nothing and deleted it. I remember this problem being discussed in a CPPCon talk a few years ago, and some ways to "trick" the (modern) compilers into not optimising away the benchmark code - I think it was Chandler Carruth's "Tuning C++" talk: link to this video