Caches, locality, and working sets

15-minute session: read for 3 minutes, trace for 3, experiment for 7, and complete the check for 2. Spend longer whenever you need.

Locality describes reuse of nearby data or recently accessed data. A working set that fits a cache can behave differently from one that streams through RAM. Stride, element size, prefetching, compiler optimization, and the amount of useful work all affect results. A Python loop also measures interpreter overhead, so it cannot isolate cache latency by itself.

Practice and evidence: Predict the example or draw its state transitions. Change one assumption, test the boundary, and record the actual result. Explain what this small model does not establish about a production system.

data=list(range(16))
print(sum(data))
print(sum(data[::4]))

Expected result: 120 24

Practice and evidence

Keep three notes: your prediction, the actual result, and why they match or differ. The completion check grades understanding; the practice task builds skill.

Language reference: git.agilaos.com

Language reference: docs.nvidia.com