Talks to Watch

code::dive conference 2014 - Scott Meyers: Cpu Caches and Why You Care

231K views · Jan 5, 2015 · 1:16:58 · 3 HN recommenders · 6 mentions · discussed 2018–2023

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.

Why Hacker News points people here: HN points to it as the go-to explanation of why memory layout beats pointer-chasing structures on real hardware.

“Scott Meyers had a very good talk which contained this information”HN comment, 2023

What Hacker News said 6

Strongly recommendsdrainyardOct 2018

“They're mostly about C++ and cache aware/data oriented programming.”

Talk on cache-aware, data-oriented programming.

Full comment

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.

in “Ask HN: What are some of the best technical talks you've heard?” · view on HN
Recommendsjimmy1Apr 2018

“Here is a good visualization on access speeds for each level of cache”

Visualizes access speeds across cache levels and main memory.

Full comment

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

in “Intel brings a six-core i9 CPU to laptops” · view on HN
RecommendscoppsilgoldApr 2023

“Scott Meyers had a very good talk which contained this information”

Covers cache associativity and conflict misses.

Full comment

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 >

in “Beautiful branchless binary search” · view on HN
Cites itreificatorDec 2020

“goes into more detail about why this happens”

Explains why arrays beat linked lists on real hardware.

Full comment

> 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

in “An iOS zero-click radio proximity exploit odyssey” · view on HN
Cites itgame_the0ryDec 2021

“Relevant video”

Relevant talk on cache effects in multithreading.

Full comment

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.

in “A single line of code made a 24-core server slower than a laptop” · view on HN
CriticalinsanitybitNov 2022

“Cache prefetching works best for linear accesses like with a vector, not for random pointer lookups.”

Full comment

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.