DRAM generations
| Type | Data rate | Peak bandwidth (single channel) |
|---|---|---|
| DDR3-1600 | 1600 MT/s | 12.8 GB/s |
| DDR4-2400 | 2400 MT/s | 19.2 GB/s |
| DDR4-3200 | 3200 MT/s | 25.6 GB/s |
| DDR5-4800 | 4800 MT/s | 38.4 GB/s |
| DDR5-6400 | 6400 MT/s | 51.2 GB/s |
| LPDDR5 | 6400 MT/s | mobile / soldered |
| HBM2e | 3.6 Gbps/pin | ~460 GB/s stack |
| HBM3 | 6.4 Gbps/pin | ~800 GB/s stack |
Virtual memory
| Page size | 4 KB default; huge pages 2 MB or 1 GB |
|---|---|
| Page table | Maps virtual → physical — multi-level (typically 4 on x86-64) |
| TLB | Caches recent translations |
| TLB miss | Costs ~100 ns on x86; use huge pages for large working sets |
| Swap / paging | Move cold pages to disk — modern systems avoid swap when possible |
Cache behavior
| Cache line | 64 bytes on x86 / ARM |
|---|---|
| Associativity | 8–16-way typical |
| Coherence | MESI / MOESI between cores |
| False sharing | Different cores hitting same cache line — pad to 64 B |
| Write-back | Dirty lines flushed to next level on eviction |
Tips
- Design data for locality — contiguous arrays beat linked lists for iteration.
- Align hot data on cache-line boundaries.
- Prefetch: modern CPUs detect sequential access automatically; manual prefetch hints help for irregular patterns.
- Avoid false sharing between threads by padding or separating per-thread data.
Worked examples
Bandwidth from the data rate. A DDR channel moves 8 bytes (64 bits) per transfer, so peak bandwidth is the data rate times 8. DDR4-3200 gives 3,200 million transfers per second × 8 B = 25.6 GB/s, and two channels give 51.2 GB/s. The “3200” is megatransfers per second, not megahertz: DDR memory transfers on both clock edges, so the I/O clock for DDR4-3200 is 1,600 MHz. Real programs rarely reach peak, because refresh, bank conflicts and read/write turnaround take cycles.
Cache lines and stride. A 64-byte line holds sixteen 4-byte integers. Summing an array in order misses once per 16 elements; the hardware prefetcher usually hides even that. Walking the same data with a 4,096-byte stride touches a new line on every access and uses only 4 of its 64 bytes, so effective bandwidth falls to a small fraction.
Pages and the TLB. A 1 GiB working set is 1 GiB / 4 KiB = 262,144 pages of 4 KiB, but only 512 pages of 2 MiB. Fewer pages means far fewer TLB entries are needed, which is why large databases often enable huge pages.
Common mistakes
- Confusing GB/s with Gb/s: a factor of 8. Memory bandwidth is quoted in bytes, network links in bits.
- Comparing MT/s with MHz across generations without checking which is meant.
- Quoting peak bandwidth as if it were sustained throughput.
- Assuming a linked list is as fast as an array. Pointer chasing defeats the prefetcher and takes a cache miss per node.