~/talk

What Every Programmer Should Know about How CPUs Work

Talkat GOTO Chicago 2024 · 2024-10-21..10-22· [concurrency, computer-vision]
slides:none on file

Modern CPUs use an in-order front end, out-of-order execution back end and heavy branch prediction, and that matters: a tiny loop in Python runs about 80 ms faster when data is sorted because branch prediction improves; the same loop in C++ compiles to a conditional move and runs ≈8 ms, but forcing branches raises it to ≈39 ms. Replacing a modulus (division) with a power-of-two mask drops a hashed loop from ~148 cycles to ~33 cycles. Randomized pointer chasing turns an 11 ms array walk into ~1.3 s. Measurements use perf counters, Compiler Explorer and llvm-mca for microarchitectural insight.

AI-written summary · about

  1. 0:00Intro
  2. 0:25What to get out of this talk
  3. 1:13A modern CPU pipeline
  4. 11:47Branch prediction
  5. 21:27Demo
  6. 26:15Execution
  7. 28:56Demo
  8. 34:53Can the compiler save us?
  9. 35:08Demo
  10. 36:46Memory
  11. 37:52Results
  12. 40:11Top-down analysis
  13. 41:12Perf
  14. 42:06Conclusion
  15. 43:11Outro
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.