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 • 94 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.

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.

sanderjdon Hacker News • Mentions

On “C++ vs. OCaml: Ray tracer comparison (2005)”

…ried that the standardized specification for `std::unordered_map` more or less forces an implementation to use buckets instead of the more cache-friendly technique of probing. I'm sure that the people who standardized it were very competent, which makes me think that, at least at the time, buckets were thought to be the better implementation. 0: link to this video Edit: Added video link.…

santaclauson Hacker News • Mentions

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

I think C++'s built in unordered_map has to use chaining due to restrictions on iterators mandated for standard library containers, which is a drag. You've still got to roll your own open addressed container. :( This comes up in one of Chandler Carruth's talks 1. 1 link to this video

adrianNon Hacker News • Mentions

On “Searching 20 GB/sec: Systems Engineering Before Algorithms (2014)”

Uniformly shitty code is hard to profile. See for example what Chandler has to say about writing good code link to this video