Description

Different storage technologies trade speed, density, cost, volatility and endurance:

TechnologyCellVolatile?Typical latency (order of magnitude)Use
SRAM6 transistors (flip-flop)Yes~1 ns (a few cycles)Registers, L1-L3 caches, TLBs
DRAM1 transistor + 1 capacitorYes (refresh needed)~50-100 nsMain memory (DDR4/DDR5)
HBMStacked DRAM on interposerYesDRAM-class, huge bandwidthGPUs, accelerators
Flash (NAND)Floating-gate cellNotens of µsSSDs, phones
HDDSpinning magnetic diskNomillisecondsCheap bulk storage

SRAM vs DRAM:

FeatureSRAMDRAM
Cell6 transistors, no refresh1 transistor + 1 capacitor, refresh required
SpeedVery fast, predictable timingSlower, more complex timing
Density / costLow density, high cost per bitHigh density, low cost per bit
PowerNo refresh, higher static power per cellRefresh overhead, dynamic power
Typical useCPU cachesSystem memory

DRAM basics: the array is organized in banks of rows and columns. A read activates a row into the row buffer (RAS), then selects columns (CAS). Capacitors leak, so every row must be refreshed (typically every ~64 ms). DDR transfers data on both clock edges. HBM stacks DRAM dies and connects them with a very wide interface for bandwidth.

Flash is non-volatile and fast but cells wear out after limited write/erase cycles, so controllers use wear leveling (spread writes evenly) and error correction.

Memory optimizations (main memory level): multiple banks and interleaving, open-row (page) policy to exploit the row buffer, prefetching, write buffering, and wider/faster interfaces (DDR generations, HBM).

Dependability:

  • Soft errors: transient bit flips (cosmic rays, noise); corrected, no permanent damage.
  • Hard errors: permanent defects.
  • ECC (error-correcting code) memory detects and corrects errors; SECDED = single-error correct, double-error detect.
  • ChipKill survives the failure of an entire DRAM chip (multi-bit protection).
  • RAID adds redundancy across disks for fault tolerance and performance.
  • Scrubbing periodically reads and corrects memory to stop errors accumulating.

Key Formulas

Peak DRAM bandwidth = transfer rate (MT/s) × bus width (bytes)
Hamming bound (single-error correct): 2^r ≥ m + r + 1     (m data bits, r check bits)
SECDED check bits = r + 1
Availability = MTTF / (MTTF + MTTR)
Annual failure rate (AFR) ≈ 8760 h / MTTF
Interleaved access time (n banks) ≈ T_access + (n − 1) · T_bus

Steps

DRAM bandwidth: (1) read the transfer rate (MT/s), (2) multiply by bus width in bytes, (3) multiply by number of channels.

Check bits for ECC: (1) pick m data bits, (2) find the smallest r with 2^r ≥ m + r + 1, (3) add 1 parity bit for double-error detection.

Hamming (7,4) single-bit correction: (1) place check bits at positions 1, 2, 4, (2) compute even-parity bits over the position groups, (3) on receipt recompute the syndrome; its value is the position of the flipped bit.

Worked Example

A. DDR4-3200. 3200 MT/s × 8 B = 25.6 GB/s per 64-bit channel; dual channel = 51.2 GB/s.

B. HBM2. 1024-bit interface × 2 Gb/s per pin ÷ 8 = 256 GB/s per stack; four stacks ≈ 1 TB/s.

C. ECC overhead. 64 data bits: need r with 2^r ≥ 64 + r + 1 → r = 7 (128 ≥ 72). Add 1 for double detection → 8 check bits, a (72, 64) code, overhead 8/64 = 12.5%.

D. Hamming (7,4). Data d1..d4 = 1 0 1 1. p1 = d1⊕d2⊕d4 = 0; p2 = d1⊕d3⊕d4 = 1; p4 = d2⊕d3⊕d4 = 0. Codeword (positions 1-7) = 0 1 1 0 0 1 1. Suppose bit 6 flips → 0 1 1 0 0 0 1. Syndrome: s1 (positions 1,3,5,7) = 0; s2 (2,3,6,7) = 1; s4 (4,5,6,7) = 1 → s4 s2 s1 = 110 = 6. Flip position 6 back.

E. Disk reliability. MTTF = 1,000,000 h → AFR ≈ 8760/10⁶ ≈ 0.88%. A farm of 1000 disks expects about 8.8 failures per year. With MTTR = 24 h, availability = 10⁶/(10⁶ + 24) ≈ 99.9976% per disk.

F. Interleaving. Four words, each bank access 40 ns, bus transfer 10 ns. Single bank, sequential: 4 × 40 = 160 ns. Four-way interleaved: 40 + 3 × 10 = 70 ns.

Python / Assembly

def encode74(d1, d2, d3, d4):
    p1 = d1 ^ d2 ^ d4
    p2 = d1 ^ d3 ^ d4
    p4 = d2 ^ d3 ^ d4
    return [p1, p2, d1, p4, d2, d3, d4]          # positions 1..7

def correct74(c):
    s1 = c[0] ^ c[2] ^ c[4] ^ c[6]
    s2 = c[1] ^ c[2] ^ c[5] ^ c[6]
    s4 = c[3] ^ c[4] ^ c[5] ^ c[6]
    pos = s4 * 4 + s2 * 2 + s1                    # 0 means no error
    if pos:
        c[pos - 1] ^= 1
    return c, pos

word = encode74(1, 0, 1, 1)         # [0,1,1,0,0,1,1]
word[5] ^= 1                        # flip position 6
print(correct74(word))              # ([0,1,1,0,0,1,1], 6)

def ddr_bandwidth_gbs(mt_s, bus_bits=64, channels=1):
    return mt_s * (bus_bits / 8) * channels / 1000

print(ddr_bandwidth_gbs(3200))      # 25.6

Non-temporal stores bypass the cache for streaming writes (x86-64 AVX):

vmovntdq [rdi], ymm0     # streaming store: avoids polluting the cache

Notes

  • DRAM must be refreshed; SRAM does not. That is why DRAM latency and power have extra terms.
  • Flash is limited by write cycles, not read cycles. HDDs are slow because of mechanical seek and rotation but remain the cheapest per terabyte.
  • Hard-error handling often means retiring bad pages or spare rows, not just ECC.
  • Hybrid systems combine all layers (DRAM cache + SSD + HDD) for cost-performance.
  • Quick facts: prefetching loads data into cache before it is requested; interleaving accesses multiple banks simultaneously; write-back reduces memory writes; wear leveling prolongs flash life; RAID provides fault tolerance.

References: [HP6] Ch. 2 (2.1-2.2, 2.6), Appendix D (storage, in editions that include it) and Ch. 1 (1.7 dependability); [PH-RV] Ch. 5 (5.2, 5.5); Hamming, "Error Detecting and Error Correcting Codes," Bell System Technical Journal, 1950;