r/programming • u/TheFlyingCoderr • Jul 13 '23
What Every Programmer Should Know About Memory
https://people.freebsd.org/~lstewart/articles/cpumemory.pdfThis 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)
298
Upvotes
View all comments
Show parent comment
11
u/siemenology Jul 13 '23
Yeah it's kind of hard to write code that takes advantage of caching and prefetches and stuff when you are writing in a high level language that runs on a language-specific VM. Where you have zero control over the assembly generated, where and how it is stored, when and how memory is allocated, where and how your data is stored, etc etc. You are better off reading performant-coding guides for your language. The things they tell you to do may make your code more performant because the code generated will be better optimized for CPU caches, but that detail doesn't actually matter to you as a programmer -- it could just as easily improve performance for reasons that are entirely specific to the language and VM, that have nothing to do with the CPU and memory.