r/programming • • Jul 13 '23

What Every Programmer Should Know About Memory

https://people.freebsd.org/~lstewart/articles/cpumemory.pdf

This resource is starting to get a bit older. But it's such a good resource for learning about memory.

Hope you like it (it's a pdf)

296 Upvotes

156 comments sorted by

View all comments

Show parent comment

33

u/exex Jul 13 '23

He was the main glibc maintainer and working for Red Hat back when he wrote this. But if I remember the text correct (been a few years...) a lot of information in there is about how the hardware works. Like how memory is always copied with 64 byte lines to the cache and implications of that on speed. Which will also be true on other OSes.

5

u/siemenology Jul 13 '23

Well, true on other OSes running the same architecture. Less helpful for mobile or embedded developers working on ARM or other architectures.

1

u/ZMeson Jul 14 '23

There's some stuff in there that can be generalized. For example the discussion on efficient access of memory by many cores when different groups of cores have separate caches (ex: cores 0 & 1 sharing L2 cache and cores 2 & 3 sharing a separate L2 cache). While some information can be generalized, it does often require a deep knowledge about the architecture in use.

2

u/TheDevilsAdvokaat Jul 13 '23

Fair enough. Yes that would be useful.