Image from Syirwan Ainu on Pexels

A program can perform the right operations and still be unnecessarily slow. The reason is often not the computation itself, but the way the program accesses data. Modern processors are exceptionally fast at performing calculations. Getting the data required for those calculations is a different problem. Data may be stored in main memory, but the processor does not normally retrieve every value directly from there. It relies on several levels of cache that sit much closer to the processor and can provide data much faster.

This creates an important connection between software and hardware. The way a program arranges and accesses its data can determine how effectively the processor can use its caches. Cache-aware programming is about designing software with that behaviour in mind.