Apex › Systems & OS

How the CPU prefetches memory (stride prefetcher)

A cache miss stalls the CPU for hundreds of cycles, so hardware fetches the next line before it’s asked for. A stride prefetcher keeps a reference prediction table indexed by each load’s PC {last address, stride, state}; when two consecutive address deltas match, it locks onto the stride and prefetches addr+stride. Verified in node: on a strided array walk coverage is ~99.9% (only the two warm-up accesses miss), while random access and pointer-chasing a shuffled linked list get ~0% — the concrete reason arrays are cache-friendly and linked lists are not. Pick a pattern and watch the RPT lock on.

More in Systems & OS