Photo by Franck V. on Unsplash

Memory Interleaving: Spreading Data Across Memory Channels


Modern CPUs can execute hundreds of instructions per second, but they’re only as fast as their access to data allows. Memory interleaving is a hardware technique that spreads consecutive memory addresses across multiple physical memory channels, allowing the CPU to access different parts of memory simultaneously rather than waiting for sequential operations on a single channel.

How Memory Interleaving Works

Without interleaving, consecutive memory addresses map to consecutive locations within a single memory module. If a program reads addresses 0x1000, 0x1008, and 0x1010, all three requests queue up on the same channel, executing serially even though multiple memory channels exist in the system.

Memory interleaving distributes these addresses across different channels using the lower bits of the address as a channel selector. In a system with four channels, addresses might map like this: addresses ending in 0x0 go to channel 0, 0x8 to channel 1, 0x10 to channel 2, and 0x18 to channel 3. When a program reads a contiguous block of memory, the requests automatically spread across all available channels, allowing parallel execution.

The granularity of interleaving varies by system. Some use cache-line granularity (typically 64 bytes), while others interleave at page boundaries (4KB). Finer granularity provides better parallelism for small sequential accesses, while coarser granularity reduces complexity in the memory controller.

Why This Matters for Performance

Memory bandwidth becomes a bottleneck in data-intensive workloads: database scans, machine learning inference, scientific computing, and video encoding all move large volumes of data between memory and CPU. A modern server-grade CPU might support four or more memory channels, each capable of 25+ GB/s. Without interleaving, only one channel services requests at a time, leaving the others idle.

Interleaving automatically parallelizes sequential memory access patterns without requiring software changes. When scanning an array, the hardware splits requests across channels, achieving aggregate bandwidth that scales with channel count. A four-channel system can theoretically deliver four times the bandwidth of a single channel for workloads with good spatial locality.

The benefits aren’t limited to pure throughput. Interleaving also reduces latency variance by distributing load across channels, preventing any single channel from becoming saturated while others sit idle.

The NUMA Complication

Memory interleaving interacts with NUMA (Non-Uniform Memory Access) architectures in multi-socket systems. Each CPU socket has its own set of memory channels, and accessing local memory is faster than reaching across the interconnect to another socket’s memory.

Many systems support two interleaving modes. Local interleaving keeps addresses on the same NUMA node, interleaving only across channels within that node. This preserves NUMA locality benefits while still gaining parallel channel access. Remote interleaving spreads addresses across NUMA nodes, maximizing total system bandwidth but introducing cross-socket latency.

The choice depends on workload characteristics. Applications with thread-local memory access patterns benefit from NUMA-aware allocation with local interleaving. Shared data structures accessed by threads across sockets might benefit from cross-node interleaving, trading some latency for bandwidth.

Configuration and Detection

Most BIOS/UEFI implementations enable interleaving by default, but some expose configuration options. Enterprise systems may allow administrators to choose between interleaving modes or disable it entirely for specific workloads.

Linux exposes interleaving information through /sys/devices/system/node/ and memory topology detection. The numactl --hardware command shows how memory distributes across nodes and channels. Performance monitoring tools can measure memory bandwidth utilization per channel to verify interleaving effectiveness.

When Interleaving Doesn’t Help

Random access patterns see diminished benefits because they already spread naturally across channels. Small, pointer-chasing workloads (like traversing a linked list) don’t generate enough outstanding memory requests to saturate multiple channels simultaneously.

Some high-frequency trading and real-time systems disable interleaving when they need deterministic latency rather than maximum throughput. Interleaving introduces variation depending on which channel services each request, and in latency-critical scenarios, predictability matters more than average-case performance.

Memory interleaving represents a fundamental architectural decision: modern systems assume sequential access patterns are common enough to warrant hardware support for automatic parallelization. For most workloads, this assumption holds, and interleaving delivers transparent performance scaling as memory channel counts increase.