Brain Dump

Locality

Tags
comp-arch

Is a property of memory access where memory reads/writes that're close together in time tend to cluster in memory space.

This is the reason virtual memory is so effective. Without it you'd have to do a disk read/write every time you try to reach a new reference making virtual memory as slow as disk. However because programs demonstrate strong locality your OS can do relatively few swaps per read. The actual swapping algorithm uses a basic LRU cache with blocks being swapped into memory as their needed and when physical memory for the working set is running low it swaps the least-recently-used block out.