The tendency for the CPU/programs to access the same set of memory locations over a short period of time. It tells us that we should keep things in locality together so that accesses can be faster.
The main problem is that we can’t predict what future memory we will need to access, but we can let the two guidelines below help us design better hardware and write faster code.
Two types
What does “same set” mean? There are two “sames” we can talk about:
- Temporal locality: if we access a portion of memory, we will likely reference it again soon
- Spatial locality: if we access a portion of memory, we will likely reference memory close to it in the near future.
These are both assumptions. However, both of these assumptions often inform hardware design decisions to allow them to happen more frequently.