# cpu-caches

Published articles for cpu-caches.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## CPU Caches and Spatial Locality: Why an Array is 3x Faster Than a Linked List for the Exact Same Big-O Complexity

DevFeed: [CPU Caches and Spatial Locality: Why an Array is 3x Faster Than a Linked List for the Exact Same Big-O Complexity](<https://devfeed.tech/articles/cpu-caches-and-spatial-locality-why-an-array-is-3x-faster-than-a-linked-list-for-the-exact-same-big-o-complexity-39570.md>)

Original publisher: [Read original article](<https://ankit-rana.com/logs/18-cpu-caches-spatial-locality/>)

Author: hello@ankit-rana.com

Published: 2026-03-21T00:00:00Z

Content type: tutorial

Language: en

Sources: [Ankit Rana | Mechanical Sympathy](<https://devfeed.tech/sources/ankit-rana-mechanical-sympathy.md>)

Topics: [cpu](<https://devfeed.tech/topics/cpu.md>), [Cache](<https://devfeed.tech/topics/cache.md>), [Caching](<https://devfeed.tech/topics/caching.md>), [Data structures](<https://devfeed.tech/topics/data-structures.md>), [Benchmark](<https://devfeed.tech/topics/benchmark.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>)

Tags: [arrays](<https://devfeed.tech/tags/arrays.md>), [benchmark](<https://devfeed.tech/tags/benchmark.md>), [complexity](<https://devfeed.tech/tags/complexity.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [cpu-caches](<https://devfeed.tech/tags/cpu-caches.md>), [data-structure](<https://devfeed.tech/tags/data-structure.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [memory-hierarchy](<https://devfeed.tech/tags/memory-hierarchy.md>), [performance](<https://devfeed.tech/tags/performance.md>), [spatial-locality](<https://devfeed.tech/tags/spatial-locality.md>), [systems](<https://devfeed.tech/tags/systems.md>)

### AI overview

This article explains why arrays can outperform linked lists despite both having O(N) traversal complexity. Sequential array access benefits from cache lines, spatial locality, and hardware prefetching, while scattered linked-list nodes cause pointer chasing and more cache misses. The supplied summary reports an approximate threefold performance difference.

### Source excerpt

Arrays and linked lists are both O(N) to traverse, but an array can run about three times faster because CPUs fetch 64-byte cache lines, not individual values. Sequential array access turns the next several iterations into cache hits at roughly 1 ns and lets the hardware prefetcher work ahead. Linked list nodes scattered across the heap defeat the prefetcher, so each dereference risks a 100 ns trip to RAM.