Here is a small puzzle. You write a C program that adds up every number in a table of 4,096 rows and 4,096 columns, 16,777,216 integers in all. You run it on an ordinary desktop and it finishes in about 3 milliseconds. Now you swap two lines of the program, so that it visits the very same numbers in a different order. Nothing else changes: same table, same additions, same computer. This time it takes about 80 milliseconds, more than 20 times longer.
Where did the time go? Not into the arithmetic, because the processor did exactly the same additions. It went into waiting. Between the processor and the main memory (RAM) sits a small, very fast memory called the cache, and visiting the numbers in the first order keeps the cache happy; the second order keeps it busy fetching. This chapter is about that small memory: what it is, why it works at all, and how much faster it makes a computer.
It is also one of the most dependable topics in a Computer Architecture paper. The written paper often asks what cache memory is and how it improves performance, the MCQ paper asks which memory is fastest or what happens on a hit and on a miss, and a short calculation of the average memory access time comes back with the same numbers.
By the end of the chapter you will be able to say why a fast processor needs a cache, put the levels of the memory hierarchy in order and explain the trade-off that creates them, and follow one memory access through a cache, hit or miss.