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

NOKIA Technology Center Wrocław · 230K views · 2015 · 1:16:58

Open on YouTube

Software performance & optimizationComputer architecture & CPUsC, C++, Rust, Go & systems languagestalk

Why Hacker News recommends it

HN points to it as the go-to explanation of why memory layout beats pointer-chasing structures on real hardware.

What it is

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.

Recommended by 3 HN commenters across 3 different months, 2018 to 2023.

What Hacker News said

Strong rec drainyard · 2018-10 · on “Ask HN: What are some of the best technical talks you've heard?”

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.

Recommends jimmy1 · 2018-04 · on “Intel brings a six-core i9 CPU to laptops”

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]

Recommends coppsilgold · 2023-04 · on “Beautiful branchless binary search”

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] >

Cites reificator · 2020-12 · on “An iOS zero-click radio proximity exploit odyssey”

> 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 grap

Cites game_the0ry · 2021-12 · on “A single line of code made a 24-core server slower than a laptop”

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.

Critical insanitybit · 2022-11 · on “In defense of linked lists”

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 on