code::dive conference 2014 - Scott Meyers: Cpu Caches and Why You Care
NOKIA Technology Center Wrocław3 HN recommenders · recommended in 3 months, 2018-2023
231K views · 11 years ago · talk · evergreen
Scott Meyers explains how CPU caches work and why they matter for performance, covering cache levels, access speeds, associativity, and effects in multithreaded code. The focus is C++ and cache-aware, data-oriented programming.
HN points to it as the go-to explanation of why memory layout beats pointer-chasing structures on real hardware.
59:21A Crash Course in Modern Hardware by Cliff Click
Devoxx
21K views • 9 years ago
1:13:41CppCon 2014: Chandler Carruth "Efficiency with Algorithms, Performance with Data Structures"
CppCon
235K views • 12 years ago
1:27:46CppCon 2014: Mike Acton "Data-Oriented Design and C++"
CppCon
862K views • 12 years ago
1:00:58CppCon 2017: Chandler Carruth “Going Nowhere Faster”
CppCon
113K views • 9 years ago
2:50:14Simple Code, High Performance
Molly Rocket
463K views • 5 years ago
19:25New computers don't speed up old code
Matthias random stuff
187K views • 1 year ago
1:04:26CppCon 2018: G. Nishanov “Nano-coroutines to the Rescue! (Using Coroutines TS, of Course)”
CppCon
40K views • 8 years ago
1:02:17'Fastware' - Andrei Alexandrescu [ ACCU 2016 ]
ACCU Conference
34K views • 10 years ago
52:54Rust at speed — building a fast concurrent database
Jon Gjengset
225K views • 7 years ago
1:33:022013 Keynote: Chandler Carruth: Optimizing the Emergent Structures of C++
CppNow
34K views • 13 years ago
59:11How to Speed up a Python Program 114,000 times.
InfoQ
171K views • 13 years ago
46:40Andrew Kelley: A Practical Guide to Applying Data Oriented Design (DoD)
ChimiChanga
415K views • 2 years ago
1:30:03C++Now 2018: Matt Godbolt “What Else Has My Compiler Done For Me Lately?”
CppNow
11K views • 8 years ago
1:29:54CppCon 2015: Chandler Carruth "Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My!"
CppCon
188K views • 11 years ago
1:04:48"Performance (Really) Matters" with Emery Berger
Association for Computing Machinery (ACM)
7K views • 6 years ago
1:00:07CppCon 2017: Carl Cook “When a Microsecond Is an Eternity: High Performance Trading Systems in C++”
CppCon
357K views • 9 years ago
1:21:13C++ and Beyond 2012: Herb Sutter - atomic Weapons 1 of 2
alexsmail
71K views • 9 years ago
22:41"Clean" Code, Horrible Performance
Molly Rocket
1.2M views • 3 years ago
1:32:47Data-Oriented Demo: SOA, composition
Jonathan Blow
201K views • 11 years ago
1:32:33C++ and Beyond 2012: Herb Sutter - atomic Weapons 2 of 2
alexsmail
29K views • 9 years ago
6 comments from Hacker News
Cache associativity, conflict miss. You have too many memory addresses mapping to the same cache lines all being used together at the same time. Scott Meyers had a very good talk which contained this information: < ▶ this video >
I don't buy this. ▶ this video Prefetching in CPUs predates this talk. link That talk is 2018. Cache prefetching works best for linear accesses like with a vector, not for random pointer lookups. Prefetchers are also going to have an extra harder time with double indirection since they're unable to see which value is going to be fed to the lea. Prefetching is also expensive in and of itself, the CPU doesn't do it unless you're already incurring cache hits. This makes cache misses even worse . There are also multiple prefetchers in the CPU and the L1 prefetcher is very basic and is only going to help with contiguous accesses. Your allocator might be doing some nice things for you that let the one of the L2 prefetchers help, I would expect that you'll see better L2 performance due to prefetching. If you have an example of a linked list being as fast as a vector for iteration, please do show it.
Relevant video - Scott Meyers: Cpu Caches and Why You Care ▶ this video Remember, boys and girls, small mistakes can have big consequences. Keep those data in immutable data structures when mutli-threading. Actor model also helps.
> If your primary operation is inserting at a random location in the list, linked lists are faster than arrays at large sizes. You avoid having to move all the memory after the index you are modifying (to make space for the inserted element). This is false. Big O notation says it should be true, you'll get marked wrong if you say arrays are faster in your algorithms & data structures final, but when you're running on actual hardware the array is faster at all sizes of n and as n becomes larger so does the gap in performance. Here is a talk[0] by Bjarne Stroustrop (Creator of C++) that even includes imaginary graphs demonstrating this phenomenon. If you want a visual for what the missing graph was supposed to look like, here's a similar one.[1] Here's another video[2] by Scott Meyers (Author of Effective C++) that goes into more detail about why this happens. [0]: link [1]: link [2]: ▶ this video
Two of my favorites: code::dive conference 2014 - Scott Meyers: Cpu Caches and Why You Care: ▶ this video CppCon 2014: Mike Acton "Data-Oriented Design and C++": link They're mostly about C++ and cache aware/data oriented programming.
Here is a good visualization on access speeds for each level of cache, then main memory. Now take the main memory access time and essentially double it (for your state of the art SSD's today) and that's the access speed. ▶ this video