Cache Locality
Cache Locality — The performance property of keeping temporally or spatially related data close to the processor caches that repeatedly consume it.
Spatial and Temporal Locality
Temporal locality means recently used data is likely to be used again. Spatial locality means nearby addresses are likely to be accessed together. Cache-friendly data structures exploit one or both patterns.
A theoretically efficient algorithm can still perform poorly when it repeatedly misses cache or follows pointer-heavy layouts with weak locality.
Measurement Boundary
Locality depends on working-set size, access order, cache hierarchy and the target processor. Source code alone cannot establish cache behavior; hardware counters and profiling are more reliable.
Multi-core workloads also interact with Cache Coherence and False Sharing.