Skip to content
0:00 / 0:00

#chandlercarruth#cachelocality#std::unordered_map

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

CppCon

189K subscribers • 101 videos on Hallway • Conference channel

YouTube
  • Recommended by 10 people: 7 on Hacker News, 1 on Lobsters, 1 in engineering communities and 1 curated list.
  • A classic. People kept recommending it from 2014 to 2024.
  • Presented by Chandler Carruth
  • Linked in the descriptionCppCon/CppCon2014

Intermediate. Assumes working knowledge.

234K views12 years ago10 recommendations

Systems programmingComputer scienceC++Performance and optimizationData structures

Chandler Carruth explains how modern CPU architectures make data structure choice and memory layout more critical for performance than algorithmic complexity.

cppcon.org — Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2014 -- Why do you write C++ code? There is a good chance it is in part because of concerns about the performance of your software. Whether they stem from needing to run on every smaller mobile devices, squeezing the last few effects into video game, or because every watt of power in your data center costs too much, C++ programmers throughout the industry have an insatiable desire for writing high performance code. Unfortunately, even with C++, this can be really challenging. Over the past twenty years processors, memory, software libraries, and even compilers have radically changed what makes C++ code fast. Even measuring the performance of your code can be a daunting task. This talk will dig into how modern processors work, what makes them fast, and how to exploit them effectively with modern C++ code. It will teach you how modern C++ optimizers see your code today, and how that is likely to change in the coming years. It will teach you how to reason better about the performance of your code, and how to write your code so that it performs better. You will even learn some tricks about how to measure the performance of your code. -- 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

10 people recommend this

What people say. Engineers frequently recommend this talk to explain why contiguous memory layouts outperform node-based structures like hash maps on modern CPUs.

Moments people linked to

u/rochein r/haskell • Recommends

Discontiguous Data Structures are the Root of all (performance) Evil (x-post from /r/programming)
26View on Reddit

amakson Hacker News • Recommends

On “Std::string half of all allocations in the Chrome browser process”

There are many things in the standard C++ library which are named incorrectly (std::string), awkwardly (std::unordered_map) and and implemented inefficiently from the perspective of modern CPUs (same std::unordered_map, which uses linked list for the underlying hash table buckets). See the great talk on CppCon 2014 about those issues - link to this video .

slavik81on Hacker News • Recommends

On “Ask HN: How can I learn about performance optimization?”

Strongly agree. That's perhaps less true for the software I work on these days (lapack), but I've seen that so many times over my career. I'm also a big fan of "Efficiency with Algorithms, Performance with Data Structures" by Chandler Carruth at CppCon 2014. link to this video

programming-talkscurated list on GitHubRecommends

Under “C++”

Efficiency with Algorithms, Performance with Data 01:13:41 by **Chandler Carruth** (2014)

yoklovon Hacker News • Recommends

On “The Care and Feeding of C++'s Dragons (2013) [video]”

Chandler Carruth's CPPCon talk 0 this year was also great (surprisingly, as I had a fairly low opinion of most of the others). It wasn't better than Mike Acton's 1, but I suspect that it was more actionable for most devs. 0 link to this video 1 link

sanderjdon Hacker News • Recommends

On “The Case for Controlled Side Effects”

Also, those allocations imply linked, rather than contiguous, data structures, which (often? always?) imply poor cache interaction, which is a major source of inefficiency. Would love some more perspectives on this, as I've just watched a couple cppcon talks (0, 1) and I'm feeling a bit drunk on the kool-aid. 0: link to this video 1: link

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 - "Understanding Compiler Optimization" link - "Optimizing the Emergent Structures of C++" link - "Efficiency with Algorithms" link to this video 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.

amakson Hacker News • Recommends

On “C++ for Games: Performance, Allocations and Data Locality”

STL is not inherently slow per se, some data structures are just not fast on modern CPUs, so they have to be chosen wisely. Here is good talk: link to this video .

adrianNon Hacker News • Recommends

On “Diving into the world of hash tables”

Yes, if you write performance sensitive code you have to be very careful with dictionaries. See for example this nice talk by Chandler Carruth link to this video

alexhutchesonon Hacker News • Recommends

On “On modern hardware the min-max heap beats a binary heap”

If you haven't already seen it, you'd probably really enjoy Chandler Carruth's "Efficiency with Algorithms, Performance with Data Structures" talk from CppCon 2014: link to this video

pushcxon Lobsters • Recommends

Efficiency with Algorithms, Performance with Data Structures Not much of this is C++ specific, despite the venue.

u/ewmailingin r/C_Programming • Mentions

On “Creating a Linked list library C/C++”

…are the worst data structure you can use with respect to performance. Start with a vector. They are even simpler to implement and will always be faster (except in the most contrived cases that have almost no real world use). Bjarne Stroustrup (C++ creator) gave a explaining that arrays are always faster than linked lists on modern architectures. link to this video Clang/LLVM engineer, Chandler Carruth also makes the same point. Efficiency with Algorithms, Performance with Data Structures link to this video At 34:40, he talks about "Performance and Data Structures". Reveal: "Discontiguous data structures are the root of all (performance) evil". and "Just say NO to linked lists". "There is almost nothing…

u/skeetoin r/C_Programming • Mentions

On “Why is there no C conference?”

Every year you can think of a subset of CppCon as being like a C conference. There are a bunch of presentations that are entirely or mostly relevant to C, and not just in a broader sense of being relevant to *any* language. I plucked out a bunch from CppCon 2017 for you. These are *roughly* ordered from best to worst: * [Matt Godbolt “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”] * Chandler Carruth “Going Nowhere Faster” * James McNellis “Everything You Ever Wanted to Know about DLLs” * John Regehr “Undefined Behavior in 2017 (part 1 of 2)” * John Regehr “Undefined Behavior in 2017 (part 2 of 2)” * Piotr Padlewski “Undefined Behaviour is awesome!” * [Tob…

Skerilyoon Stack Overflow • Mentions

On “Can I Use C++ vector insted of queue for FIFO order”

You "can" use a vector over a queue, if the queue lifetime is short or if you know the maximum size of your queue. Just use a vector, push_back in it, and keep an index of where your "head" is. For exemple if i push back 3 elements, and i want to pop one, i'll just increment my "head" index by one. This technique as been explained by Chandler Carruth in this video: link to this video
7View the answer

u/skeetoin r/compsci • Mentions

On “What does /r/compsci think of green computing? We've developed an online compiler that measures software energy consumption.”

At the moment there's no distinction between optimizing for time (compute per second) and optimizing for energy (compute per watt). Race to sleep is all it comes down to.

u/ewmailingin r/C_Programming • Mentions

On “Dynamic array versus queuing then dequeuing into an array.”

Yes. That was Stroustrup's point. And he's not the only one. Clang/LLVM engineer, Chandler Carruth also makes the same point. Efficiency with Algorithms, Performance with Data Structures link to this video At 34:40, he talks about "Performance and Data Structures". Reveal: "Discontiguous data structures are the root of all (performance) evil". and "Just say NO to linked lists". "There is almost nothing more harmful you can do to the performance of an actual modern microprocessor than to use a linked list data structure." Cache effects are real and to be taken seriously. Or stated differently, modern RAM busses are extremely slow.