31 ms·
A concrete explanation of how a cache works
- rramadass 2mo agoMeh... Wikipedia has it better and more comprehensive - https://en.wikipedia.org/wiki/CPU_cache https://en.wikipedia.org/wiki/CPU_cache For usage of caches from a OS, particularly in the context of multicores/multiprocessors see Curt Schimmel's classic Unix Systems for Modern Architectures: Symmetric Multiprocessing and Caching for Kernel Programmers.
- jdw64 2mo agoIf it's not too much trouble, could you recommend some other books as well? I've only read Computer Systems: A Programmer's Perspective when it comes to caching-related books.
- rramadass 2mo agoCaches and Memory Systems have to be looked at from three related perspectives viz. a) Hardware/SoC/Physical level b) OS/Compiler system software level c) Applications usage level. To that end; 1) Buy/Beg/Borrow/Steal the Curt Schimmel book mentioned above. That one book will teach you all about how OSes manage caches/memory for SMP multiprocessing systems. You really get to understand multiprocessing at a fundamental level. 2) Memory Systems: Cache, DRAM, Disk by Bruce Jacob et al. - Old classic and a comprehensive book on all aspects of memory systems. Supplement with papers on newer technologies as needed. 3) Ulrich Drepper's classic What every Programmer should know about Memory - https://news.ycombinator.com/item?id=36420502 https://news.ycombinator.com/item?id=36420502 4) Cache-Oblivious Algorithm - https://en.wikipedia.org/wiki/Cache-oblivious_algorithm https://en.wikipedia.org/wiki/Cache-oblivious_algorithm See in particular, Harald Prokop's thesis on the above linked to under "References" section. 5) Cache-aware Programming pattern from the book Game Programming Patterns - https://gameprogrammingpatterns.com/data-locality.html https://gameprogrammingpatterns.com/data-locality.html 6) There are lots more resources on cache-aware programming and using compiler builtins to help you do it. Here is a list of tips - https://johnnysswlab.com/make-your-programs-run-faster-by-better-using-the-data-cache/ https://johnnysswlab.com/make-your-programs-run-faster-by-be... This website has a lot of info. on all aspects of memory optimization. 7) AoS and SoA - https://en.wikipedia.org/wiki/AoS_and_SoA https://en.wikipedia.org/wiki/AoS_and_SoA
- jdw64 2mo agoThank you always for the great book recommendations. The books you've suggested are deep and interesting. I've read book no.5 from your recommendations, and I'm planning to read book no.2 next. Have a nice day.
- rramadass 2mo agoSpringer Nature has a series of concise books under the series-title "Synthesis Lectures on Computer Architecture" that covers all aspects including Caching, Memory, Security, Power, Virtualization etc. - https://link.springer.com/series/16916 https://link.springer.com/series/16916