Master the fundamental concepts of memory hierarchy through this focused micro-challenge.
Cache latency benchmarks avoid compiler optimizations by chasing pointers through a large buffer. Each load depends on the previous address, serializing memory access and exposing true RAM or cache miss cost.
cLoading…
Sweep array size from 4 KiB (fits L1) to 64 MiB (exceeds last-level cache) and plot nanoseconds per access.
For this exercise, you will implement pointer chasing and print latency versus working set size. This task asks you to measure the cliff when data falls out of each cache level, grounding every optimization task that follows in real hardware numbers.
Keep the relevant datasheet, ISA manual, or architecture textbook chapter open while you implement. When your output disagrees with the reference trace on the same program, the bug is usually a mis-decoded opcode, a stale register read, or a flag bit left unchanged after arithmetic.
For this exercise, you will use those habits while implementing the requirement in the starter code. Microarchitectural product names change across CPU generations, but the control ideas (fetch, bypass, cache lines, vector lanes) stay stable enough to debug from first principles.
Benchmark memory latency across cache levels.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github