Storage, in 16 keywords
Learn the keywords, then use them to estimate how long it takes to read data from an HDD or an SSD.
- memory hierarchy
- software-managed
- seek time
- rotational delay
- transfer time
- sequential vs random
- channels
- erase-before-write
- garbage collection
- write amplification
- FTL
- ZNS
- NVMe queue pair
- Little’s Law
- io_uring / SPDK
- IOPS
1 · Hierarchy
- memory hierarchy
- Registers → L1/L2/L3 → DRAM → SSD/HDD. Each level down is bigger, slower and cheaper: 1 cycle, ~4, ~10, ~30–60, then DRAM ~60 ns, then storage at µs–ms Storage p.6. The step from DRAM to storage is about 1000× slower. That step is what this lecture is about.
- software-managed
- Hardware moves data into the caches for you. Moving data between DRAM and storage is done by software: the OS or your program Storage p.8. Because software does this step, a data system can be designed to do it well or badly.
| Level | Latency | Capacity | Unit moved |
|---|---|---|---|
| Registers | 1 cycle | 16 × 8 B | 4–8 B word |
| L1 / L2 / L3 | ~4 / ~10 / ~30–60 cy | 32 KB / 256 KB / 10s MB | 64 B cache line |
| DRAM | ~100–200 cy (~60 ns) | GB–TB | 4 KB page |
| SSD / HDD | µs – ms | TBs | disk block(s) |
Storage pp.6, 7, 10
Which data movement is managed by software rather than hardware?
Caches are hardware-managed; DRAM ↔ storage is done by the OS or the application Storage p.8.
Roughly how much slower is a DRAM access than an L1 hit?
L1 ≈ 4 cycles, DRAM ≈ 100–200 cycles ⇒ 25–50× Storage p.6.
2 · HDD: you pay for moving parts
I/O time = seek + rotational delay + transfer- seek time 1–20 ms
- Time for the arm to move the head to the right track Storage p.20.This is the biggest cost, and it is mechanical.
- rotational delay 0–10 ms
- Waiting for the block you want to spin under the head Storage p.20.Seek plus rotational delay together are called
a, the cost of reaching a block. - transfer time <1 ms / 4 KB
- The time to actually read or write the block's bytes Storage p.20.It is tiny compared with
a. - sequential vs random access
n random = n·(a + t), butn sequential = a + n·tStorage p.21. Random access paysafor every block; sequential pays it once. The same idea comes back with cache lines, prefetching and SIMD.
Why is sequential access so much faster than random access on an HDD?
After the first block, the head is already on the right track and the next block spins under it. Only the transfer time repeats Storage p.21.
For one random 4 KB read on an HDD, which cost dominates?
a = seek (1–20 ms) + rotation (0–10 ms) dwarfs the <1 ms transfer Storage p.20.
3 · SSD: no moving parts, but new rules
- channels internal parallelism
- An SSD is many flash chips behind a controller, connected in parallel channels. Latency is 10–100s of µs, bandwidth several GB/s Storage p.22. A single request keeps only one channel busy. Full bandwidth needs “10s or more” requests outstanding at once.
- erase-before-write
- Flash cannot be overwritten in place. The erase unit is bigger than the write unit Storage p.23.Garbage collection and write amplification both come from this rule.
- garbage collection (GC)
- To free a block, the SSD copies the pages that are still valid somewhere else, then erases the block Storage p.23.GC causes extra writes and sudden latency spikes.
- write amplification
- = data physically written ÷ data logically written, always ≥ 1 Storage p.23.A higher value means the SSD wears out faster: “not to burn money”.
- FTL flash translation layer
- Firmware in the SSD that maps logical addresses to physical ones. It hides GC and wear leveling from the host Storage p.24.To the host, the SSD looks just like an HDD, but the host also can't see or control what it does.
- ZNS zoned namespaces
- The device is split into zones. Each zone is written sequentially and reset (erased) before it is rewritten Storage p.38.There is no GC inside a zone, so write amplification is close to 1 and latency is predictable. The host (DBMS or file system) takes over the FTL's work.
An application logically writes 1 GB; the SSD physically writes 3 GB. What happened?
Write amplification = 3 GB ÷ 1 GB = 3. The extra writes came from GC copying still-valid pages before an erase Storage p.23.
Why can an SSD’s latency spike unpredictably?
A request stuck behind GC sees a latency spike Storage p.23.
What does a ZNS SSD move from the device to the host?
With ZNS, FTL logic moves partly into the host (DBMS or file system) Storage p.38.
4 · Interface and software
- IOPS
- I/O operations per second. An HDD manages ~100–200; an NVMe SSD hundreds of thousands to millions Storage p.27.With an SSD, the bottleneck moves from the device to the software stack.
- NVMe queue pair
- A submission queue (SQ) plus a completion queue (CQ) in host memory, rung with a doorbell register. NVMe allows 64 K queues × 64 K commands, typically one queue pair per core, so no locks are needed. The old AHCI/SATA interface had 1 queue × 32 Storage pp.27, 29. Deep queues are what let NVMe keep all the SSD's channels busy.
- Little’s Law
L = λ · W, i.e. queue depth = IOPS × latency. Slide example: 1 M IOPS × 10 µs = 10 Storage p.30. It tells you how many requests must be in flight to reach a target throughput.- io_uring / libaio / SPDK
- A syscall and an interrupt cost about as much as a ~10 µs device access. Two ways out: an asynchronous kernel API (io_uring with user-space buffers, or libaio), or bypassing the kernel entirely (SPDK: user-space driver, no file system) Storage pp.31–32.
Plain synchronous POSIX
read()is fine for an HDD, because the HDD has no internal parallelism to use anyway.
You want 2 M IOPS from an SSD with 10 µs latency. Minimum queue depth?
2·10⁶ /s × 10·10⁻⁶ s = 20. In practice you need more, because the IOPS are spread over several channels Storage p.30.
Why does NVMe typically use one queue pair per core?
Per-core SQ/CQ pairs mean cores submit and complete without locks Storage p.29.
An app issues one synchronous 4 KB read() at a time to a fast NVMe SSD. What limits it?
At QD 1 you get 1/latency IOPS; the channels sit idle. Little’s Law says you need more requests in flight Storage pp.22, 30.
5 · Use the keywords: the exam question
Read 100 MB in 4 KB sequential pages: SATA-II HDD vs. PCIe 5 ×4 SSD Storage p.61. Try it on paper first, then open each step to check.
Step 1: number of pages
100 MB ÷ 4 KB = 25 600 pages.
Step 2: HDD, sequential access
You pay a ≈ 10 ms once. After that the disk streams at the platter's rate (“100s of MB/s”, Storage p.19). SATA-II's link (~300 MB/s) is not the bottleneck; the platter is. At ~150 MB/s: ≈ 0.67 s + 10 ms ⇒ ≈ 0.7 s.
If the same pages were read in random order instead: 25 600 × ~10 ms ≈ 256 s.
Step 3: SSD, best case
PCIe 5 ×4 ≈ 14 GB/s Storage p.30, so ≈ 7 ms.
Step 4: catch: the best case needs a deep queue
With one synchronous read() at a time (queue depth 1): 25 600 × 10 µs ≈ 256 ms.
To reach 14 GB/s you need 14·10⁹ ÷ 4096 ≈ 3.4 M IOPS. Little's Law then gives 3.4·10⁶ × 10·10⁻⁶ ≈ 34 requests in flight. That is why io_uring or SPDK matter here.
6 · Keyword recall drill
Cover the page. For each keyword, say a one-sentence definition and why it matters, then open it to check. Do this again tomorrow and in three days.
memory hierarchy
Each level down is bigger, slower and cheaper; the DRAM-to-storage step is about 1000× slower.software-managed
DRAM ↔ storage transfers are done by the OS or the app, not by hardware.seek time
Moving the arm to the right track, 1–20 ms.rotational delay
Waiting for the block to spin under the head, 0–10 ms.transfer time
Reading the block's bytes, <1 ms per 4 KB.sequential vs random
Sequential: a + n·t. Random: n·(a + t).channels
The SSD's parallel flash chips; you need many outstanding requests to use them all.erase-before-write
Flash can't be overwritten in place, and the erase unit is bigger than the write unit.garbage collection
Copy the still-valid pages out, then erase the block. Causes latency spikes.write amplification
Physical ÷ logical bytes written, ≥ 1.FTL
Maps logical to physical addresses and hides GC and wear leveling from the host.ZNS
Zones written sequentially and reset before reuse: no GC, WA ≈ 1, and the host does the FTL's work.IOPS
HDD ~100–200, NVMe ~1 M. With an SSD the software becomes the bottleneck.NVMe queue pair
SQ + CQ with a doorbell; 64 K × 64 K; one pair per core, no locks.Little’s Law
Queue depth = IOPS × latency.io_uring / SPDK
Async kernel API with user-space buffers / kernel bypass.7 · True / False
Click True or False. The explanation appears after you answer.
T / FWith the arrival of flash, Linux retired the block device interface.
False. SSDs still offer an HDD-compatible block API through the FTL, so the two are interchangeable as generic block I/O Storage pp.22, 25, 61.
T / Fio_uring allows async disk access with buffers located in kernel space.
False. io_uring is async with user-space buffers Storage pp.32, 61.
T / FAHCI/SATA supports thousands of queues, just like NVMe.
False. AHCI has 1 queue of 32 commands; NVMe has 64 K queues of 64 K commands each Storage pp.27, 29.
T / FFor an HDD, synchronous POSIX I/O is acceptable because the disk has no real internal parallelism.
True Storage p.32.
T / FEvery read() of a file goes to the disk.
False. The buffer cache in DRAM serves repeated reads Storage p.53.
T / FIn a ZNS SSD, a zone must be written sequentially and reset before it can be rewritten.
True Storage p.38.
T / FParquet is a text-based, row-oriented format like CSV.
False. Parquet is binary, columnar and page-based, with rich metadata Storage p.57.
T / FWith NVMe SSDs, the OS software stack can become the bottleneck instead of the device.
True. The device takes ~10 µs, and a syscall plus interrupt path can cost as much or more Storage pp.27, 31.
T / FA bigger file-system block size is always better.
False. Too big wastes space on small files; too small means too many blocks to track. 4 KB is typical Storage p.48.
8 · What is …? no options: answer aloud, then reveal
What isan inode, and what does the inode table do?
Show answer
An index node holding a file's metadata. The inode table maps an inode number to its inode Storage p.49.
What isthe superblock?
Show answer
Metadata about the file-system instance: bitmap size, number of inodes and file blocks, offsets of the components, file-system type Storage p.51.
What isthe free-block bitmap?
Show answer
One bit per block, 1 = occupied and 0 = free. Some file systems use a B-tree instead Storage p.50.
What isthe virtual file system (VFS)?
Show answer
The OS layer that gives one common interface over different file systems (EXT*, ZFS, NFS…) Storage p.43.
What isa doorbell register in NVMe?
Show answer
A memory-mapped register that is written to signal new entries in a submission or completion queue Storage p.29.
What isNVMe-oF?
Show answer
The NVMe protocol carried over a network (RDMA, TCP) instead of PCIe. It enables disaggregated flash pools (JBOF) Storage p.35.
What isCXL, and what is a Type-3 device?
Show answer
Compute Express Link, a cache-coherent interconnect over the PCIe physical layer. Type-3 devices are memory expanders Storage p.37.
What iscomputational storage?
Show answer
Running filters, scans or decompression inside the storage device, so less data crosses PCIe. Example: KV-SSDs. Caveats: programmability, vendor lock-in Storage p.39.
What iswear leveling?
Show answer
Spreading writes over the flash cells, because cells and blocks wear out and become faulty over time Storage p.23.
What isthe difference between Parquet and Arrow?
Show answer
Both are columnar. Parquet is a storage format focused on compression; Arrow is an in-memory format focused on access speed. Loading means decoding and decompressing Parquet into Arrow Storage p.58.
9 · Calculations
ComputeAn HDD has 6 ms seek, 4 ms rotation and 0.1 ms transfer per 4 KB block. How long do 50 random reads take, and 50 sequential reads? What is the speedup?
Show solution
Random: 50 × (10 + 0.1) = 505 ms. Sequential: 10 + 50 × 0.1 = 15 ms. Speedup ≈ 34× Storage p.21.
ComputeAn SSD has 20 µs latency, and you want 500 K IOPS. What queue depth do you need?
Show solution
Little's Law: 5·10⁵ × 2·10⁻⁵ = 10 requests in flight Storage p.30.
ComputeAn SSD is rated for 600 TB written. The application writes 2 TB/day logically, and the write amplification is 2.5. How many days until the SSD is worn out?
Show solution
Physical = 2 × 2.5 = 5 TB/day ⇒ 600 / 5 = 120 days. With WA = 1 (e.g. ZNS) it would be 300 days Storage pp.23, 38.
Compute10 GB of data is stored on an HDD (150 MB/s). Parsing CSV runs at 50 MB/s; Parquet at 500 MB/s per core. Ignoring compression, where is the bottleneck in each case?
Show solution
Reading: 10 000 / 150 ≈ 67 s. CSV parsing: 10 000 / 50 = 200 s ⇒ CPU-bound on parsing. Parquet: 20 s ⇒ the disk (67 s) is the bottleneck. (In reality Parquet is also smaller on disk because it is binary and compressed.) Storage pp.56–57
ComputeOn an SSD with 10 µs latency, at queue depth 1, what bandwidth do you get with 4 KB requests?
Show solution
1 / 10 µs = 100 K IOPS × 4 KB ≈ 400 MB/s, which is a small fraction of the 14 GB/s PCIe 5 ×4 link Storage p.30.
10 · Exam-style questions (written)
- Explain why. Why can an NVMe SSD at queue depth 1 deliver only a fraction of its rated bandwidth?
- Compare. FTL-managed SSD vs ZNS SSD: who does garbage collection, and what happens to write amplification and to latency?
- Argue. Do applications require fundamentally different interfaces for accessing local and remote storage? Why or why not Storage p.61?
- Explain. Give two reasons a DBMS might bypass the OS file system, and one cost of doing so Storage p.33.
Bring your answers to the chat and I'll grade them the way an examiner would.
Read next
OSTEP ch. 37, Hard Disk Drives · OSTEP ch. 44, Flash-based SSDs · the L01 cheat sheet (also covers file systems and CSV vs Parquet).