HackerTube
HomeLongsLikedHistoryWatch laterCategoriesPlaylistsSettings

2013 Keynote: Chandler Carruth: Optimizing the Emergent Structures of C++

CppNow1 HN recommender · recommended in 1 month, 2013-2018
YouTube
34K views · 13 years ago · talk · evergreen

Chandler Carruth's CppNow 2013 keynote on how C++ builds complex software from simple emergent structures, and how compilers optimize them through inlining and value semantics.

HN lists it among C++ optimization talks and cites it for how much optimizer performance comes from inlining, from an experienced compiler engineer.

C, C++, Rust, Go & systems languagesCompilers, interpreters & program analysisSoftware performance & optimization#c++#compilers#optimization#inlining#llvm

3 comments from Hacker News

@dottrap2018 · in “One year of C”

I don't claim to have any answers, but I found all of this interesting and surprising. I wondered about a couple of things. What happens if the do_stuff_to_foo is actually defined (and what happens in that actual function)? And is there a difference between value semantics and pointer/reference semantics? These questions were my take-away from one of Chandler Carruth's C++ compiler optimization talks, I think it was this talk. ▶ this video My take aways were that the optimizer gets a huge chunk of its performance by inlining. And with value semantics, the optimizer can "cheat like crazy". So I defined two different variants for do_stuff_to_foo Original Pointer/Reference Semantics: void do_stuff_to_foo(foo* a) { a->x++; } Value Semantics: foo do_stuff_to_foo(foo a) { a.x++; return a; } In both cases, the compiler emits effectively the same output for C and C++ (I only tested clang.) (The main difference was name mangling. I omit stuff for brevity.) Pointer/Reference Semantics: Lcfi2: .cfi_def_cfa_register %rbp incl (%rdi) popq %rbp retq .cfi_endproc ## -- End function .globl _blah ## -- Begin function blah .p2align 4, 0x90 _blah: ## @blah .cfi_startproc ## BB#0: pushq %rbp Lcfi3: .cfi_def_cfa_offset 16 Lcfi4: .cfi_offset %rbp, -16 movq %rsp, %rbp Lcfi5: .cfi_def_cfa_register %rbp movq %rdi, %rax popq %rbp retq .cfi_endproc Value Semantics: Lcfi3: .cfi_offset %rbx, -24 movq %rdi, %rbx incl 16(%rbp) leaq 16(%rbp), %rsi movl $1036, %edx ## imm = 0x40C callq _memcpy movq %rbx, %rax add

CitesView on HN
@humanrebar2016 · in “Why I don't spend time with Modern C++ anymore”

Here's a few: - "Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My!" link - "Understanding Compiler Optimization" link - "Optimizing the Emergent Structures of C++" ▶ this video - "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.

RecommendsView on HN
@mihai_ionic2013 · in “Linus Torvalds - C++ is a horrible language”

> That said, avoiding libraries (especially avoiding templates and just using void*-like stuff) does keep binaries/libs smaller, but I'll gladly make the computer work slightly harder considering that the result is the same speed (C++ is often faster than C, in practice). This should not be an issue with modern C++ compilers. If two template instantiations generate the same or similar code, they will be merged and useless code is removed by dead code elimination. > The downside I care about is compilation speed. Simple C projects compile/link faster than modern C++ ones, even though the code for the same functionality is far more brittle, unsafe, and opaque At the same time, a lot of potential for optimization is lost by barricading everything between translation units and/or behind opaque pointers. While yes, LTO is supposed to help there, all those memory accesses make it infinitely harder for the compiler to prove trivial properties about the data flow. See also this recent presentation by someone who has a lot more experience than me with writing compiler backends: ▶ this video

CitesView on HN
CppCon 2015: Chandler Carruth "Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My!"1:29:54

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

CppCon
188K views • 11 years ago
CppCon 2017: Chandler Carruth “Going Nowhere Faster”1:00:58

CppCon 2017: Chandler Carruth “Going Nowhere Faster”

CppCon
113K views • 9 years ago
Modernizing Compiler Design for Carbon Toolchain - Chandler Carruth - CppNow 20231:35:12

Modernizing Compiler Design for Carbon Toolchain - Chandler Carruth - CppNow 2023

CppNow
71K views • 3 years ago
CppCon 2014: Chandler Carruth "Efficiency with Algorithms, Performance with Data Structures"1:13:41

CppCon 2014: Chandler Carruth "Efficiency with Algorithms, Performance with Data Structures"

CppCon
235K views • 12 years ago
CppCon 2019: Chandler Carruth “There Are No Zero-cost Abstractions”59:53

CppCon 2019: Chandler Carruth “There Are No Zero-cost Abstractions”

CppCon
147K views • 7 years ago
CppCon 2016: Chandler Carruth “High Performance Code 201: Hybrid Data Structures"55:49

CppCon 2016: Chandler Carruth “High Performance Code 201: Hybrid Data Structures"

CppCon
119K views • 10 years ago
CppCon 2016: Chandler Carruth “Garbage In, Garbage Out: Arguing about Undefined Behavior..."57:39

CppCon 2016: Chandler Carruth “Garbage In, Garbage Out: Arguing about Undefined Behavior..."

CppCon
94K views • 10 years ago
C++Now 2018: Matt Godbolt “What Else Has My Compiler Done For Me Lately?”1:30:03

C++Now 2018: Matt Godbolt “What Else Has My Compiler Done For Me Lately?”

CppNow
11K views • 8 years ago
CppCon 2018: G. Nishanov “Nano-coroutines to the Rescue! (Using Coroutines TS, of Course)”1:04:26

CppCon 2018: G. Nishanov “Nano-coroutines to the Rescue! (Using Coroutines TS, of Course)”

CppCon
40K views • 8 years ago
CppCon 2017: Matt Godbolt “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”1:15:46

CppCon 2017: Matt Godbolt “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”

CppCon
178K views • 9 years ago
CppCon 2014: Mike Acton "Data-Oriented Design and C++"1:27:46

CppCon 2014: Mike Acton "Data-Oriented Design and C++"

CppCon
862K views • 12 years ago
'Fastware' - Andrei Alexandrescu [ ACCU 2016 ]1:02:17

'Fastware' - Andrei Alexandrescu [ ACCU 2016 ]

ACCU Conference
34K views • 10 years ago
Plenary: Performance Matters - Emery Berger - CppCon 20201:01:09

Plenary: Performance Matters - Emery Berger - CppCon 2020

CppCon
32K views • 6 years ago
Can C++ be 10x Simpler & Safer?  - Herb Sutter - CppCon 20221:54:00

Can C++ be 10x Simpler & Safer? - Herb Sutter - CppCon 2022

CppCon
277K views • 3 years ago
CppCon 2019: Matt Godbolt “Path Tracing Three Ways: A Study of C++ Style”55:42

CppCon 2019: Matt Godbolt “Path Tracing Three Ways: A Study of C++ Style”

CppCon
77K views • 7 years ago
CppCon 2017: Carl Cook “When a Microsecond Is an Eternity: High Performance Trading Systems in C++”1:00:07

CppCon 2017: Carl Cook “When a Microsecond Is an Eternity: High Performance Trading Systems in C++”

CppCon
357K views • 9 years ago
CppCon 2015: Herb Sutter "Writing Good C++14... By Default"1:29:06

CppCon 2015: Herb Sutter "Writing Good C++14... By Default"

CppCon
193K views • 11 years ago
Carbon Language Successor Strategy: From C++ Interop to Memory Safety - Chandler Carruth - CppNow 231:38:57

Carbon Language Successor Strategy: From C++ Interop to Memory Safety - Chandler Carruth - CppNow 23

CppNow
24K views • 3 years ago
CppCon 2017: Fedor Pikus “C++ atomics, from basic to advanced.  What do they really do?”1:14:22

CppCon 2017: Fedor Pikus “C++ atomics, from basic to advanced. What do they really do?”

CppCon
288K views • 9 years ago
CppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”1:19:52

CppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”

CppCon
264K views • 10 years ago