CppCon 2014: Andrei Alexandrescu "Optimization Tips - Mo' Hustle Mo' Problems"

CppCon · 76K views · 2014 · 58:19

Open on YouTube

Software performance & optimizationC, C++, Rust, Go & systems languagestalk

Why Stack Overflow recommends it

Stack Overflow users link it as a primary source for Alexandrescu's claims on single-threaded shared pointers, integer signedness, inlining behavior, and his goto example.

Recommended by 2 people across 2 different months, 2014 to 2020.

What it is

A CppCon 2014 talk by Andrei Alexandrescu on optimizing C++ on modern hardware, where speed has no natural stopping point. It covers hardware quirks that are poorly understood and how to weigh design and implementation choices to get faster code.

What people said

Recommends onqtam · 2014-11 · Stack Overflow · on “Creating a non-thread safe shared_ptr”

Andrei Alexandrescu talked about implementing your own single threaded shared pointer class (with some additional optimizations) at the CppCon 2014 See the video here [this video] And the slides here [LINK] I really think the standard or boost should supply a template parameter for using atomic ref counting in their shared ptrs though...

Recommends user2356685 · 2018-02 · Stack Overflow · on “performance of unsigned vs signed integers”

Signed and unsigned integers will always both operate as single clock instructions and have the same read-write performance but according to Dr Andrei Alexandrescu [LINK] unsigned is preferred over signed. The reason for this is you can fit twice the amount of numbers in the same number of bits because you're not wasting the sign bit and you will use fewer instructions checking for negative numbers yielding performance increases from the decreased ROM. In my experience with the Kabuki VM [LINK] , which features an ultra-high-performance Script [LINK] Implementation, it is rare that you actually require a signed number when working with memory. I've spend may years doing pointer arithmetic wi

Cites T.C. · 2015-04 · Stack Overflow · on “Is there still a use for inline?”

OTOH, currently careful manual tuning of inlining can still beat compilers (see Andrei Alexandrescu's talk at CppCon 2014 [this video] ) . But the small performance gain is only meaningful if you are Facebook or something on that scale, where a 0.3% performance loss is a serious regression.

Cites Nick · 2016-03 · Stack Overflow · on “what so special about a use of goto in a chain of if else”

I was watching a video of Alexandrescu's, he has the following code snippet: // an example implementation of a single threaded shared_ptr ~SingleThreadPtr() { if(!c_) { soSueMe: delete p_; } else if(--*c_ == 0) { delete c_; goto soSueMe; } } This is here [this video] . He says, "I use my famous 'goto soSueMe' construct", and says "try to write this without goto and [..] you'll see it is difficult". What is so difficult here? Isn't the following the same, and obviously not difficult, and more readible: // an example implementation of a single threaded shared_ptr ~SingleThreadPtr() { if(!c_) { delete p_; } else if(--*c_ == 0) { delete c_; delete p_; } } or is that not even the same (thereby reinfor

Cites Roquentin · 2020-04 · Stack Overflow · on “What are the exceptions for __always_inline and __never_inline in gcc?”

Andrei Alexandrescu mentioned in a talk that he presented at cppcon [this video] that gcc doesnt always inline when then __always inline macro is defined and used, and vice-versa for __never_inline. I couldn't find much documentation about which scenarios that occurs in, so someone tell me?