CppCon 2014: Chandler Carruth "Efficiency with Algorithms, Performance with Data Structures"
CppCon7 HN recommenders · recommended in 7 months, 2014–2024
talk · intermediate · evergreen · 2014–2024 on HN
Chandler Carruth's CppCon 2014 talk on writing fast C++, explaining why data structure choice and memory layout matter more than clever algorithms. It covers why standard containers like unordered_map perform poorly on modern CPUs.
A perennial recommendation for anyone learning performance optimization, cited whenever hash tables, cache behavior or STL containers come up.
Up next
3 mo on HNWild Tricks for Greenscreen in Blender
IanHubert
3 HN recommender · 2020–2026
3 mo on HNBlender Motion Tracking - Room Transformation!
IanHubert
4 HN recommender · 2020–2022
2 mo on HNCppCon 2017: Herb Sutter “Meta: Thoughts on generative C++”
CppCon
2 HN recommender · 2017–2020
5 mo on HNBut what is the Riemann zeta function? Visualizing analytic continuation
3Blue1Brown
6 HN recommender · 2017–2023
6 mo on HNCppCon 2015: Greg Law " Give me 15 minutes & I'll change your view of GDB"
CppCon
6 HN recommender · 2018–2023
4 mo on HNCppCon 2017: Louis Brandy “Curiously Recurring C++ Bugs at Facebook”
CppCon
4 HN recommender · 2020–2025
3 mo on HNHow wildlife trade is linked to coronavirus
Vox
5 HN recommender · 2020–2020
3 mo on HNCppCon 2015: Chandler Carruth "Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My!"
CppCon
3 HN recommender · 2015–2020
16 mo on HNHow Python was Shaped by leaky Internals, Armin Ronacher, Flask framework
Видео с мероприятий {speach!
15 HN recommender · 2017–2025
11 mo on HNCppCon 2015: Andrei Alexandrescu “std::allocator...”
CppCon
7 HN recommender · 2017–2025
12 mo on HNPreventing the Collapse of Civilization / Jonathan Blow (Thekla, Inc)
DevGAMM
14 HN recommender · 2020–2025
10 mo on HN"Performance Matters" by Emery Berger
Strange Loop Conference
12 HN recommender · 2019–2025
12 comments from Hacker News
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. ▶ this video
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 - ▶ this video .
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: ▶ this video
Yes, if you write performance sensitive code you have to be very careful with dictionaries. See for example this nice talk by Chandler Carruth ▶ this video
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" ▶ 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.
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: ▶ this video .
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]: ▶ this video [1]: link
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] ▶ this video [1] link
But then your objects are scattered all over the address space, which means that objects you’re accessing in sequence are unlikely to be in the same cache line, so you pay a cache miss on every single access. Having (maybe?) more efficient malloc/free in exchange for dramatically increasing the cost of accessing your data is not a good trade-off for most access patterns. See Chandler Carruth’s talk from CppCon 2014: ▶ this video
This talk seems to me to follow a similar line of thinking to the one I saw presented by Chandler Carruth at the 2014 C++ conference [0]. In the talk he presented a table with (approximately) round-trip-times of various data layers. [0]: ▶ this video
Somewhat interestingly, C++ STL unordered_map is so much slower than it needs to be: ▶ this video Using one of the policy-based data structures instantly gets you about an order magnitude of speedup (for accesses).
Chandler Carruth talks about unordered_map performance[1] in his CppCon 2014 talk "Efficiency with Algorithms, Performance with Data Structures". He endorses most of the other alternatives you mentioned. [1] ▶ this video