AlgoViz

Queues along the storage I/O path

medium 7 min

An application issues reads and writes with sizes, access patterns and durability requirements.

Video lesson · Chapter 1 of 8

A throughput gain that hurts tail reads

0:00 / 5:34

Theory

Read or listen first. About 2 min.

What it is

An application issues reads and writes with sizes, access patterns and durability requirements. The filesystem and block layer can batch, merge and queue that work before the device completes it. Asynchronous submission allows several requests to overlap. The cost is that deep queues can hide service time behind a much larger wait.

Why it exists

A bulk writer improves total MiB/s by increasing its outstanding I/O. Interactive reads on the same device then miss their deadline. Compare response time and queue depth by workload and request size. Device utilization by itself is hard to interpret on hardware that serves multiple operations concurrently. A rate or concurrency cap on the batch job can reserve short waits for reads.

If device waits remain flat while the application slows, measure filesystem serialization or application-side queueing.

A throughput gain that hurts tail reads

Read requests → Block queues (submit I/O). Block queues → Storage device (dispatch)
Read requests → Block queues (submit I/O). Block queues → Storage device (dispatch)

Inside this chapter

Buffered I/O vs. Direct I/O (O_DIRECT)
Buffered I/O uses the page cache. Direct I/O requests a path around that cache with alignment and filesystem constraints. Bypassing the page cache is distinct from guaranteeing persistence.
Synchronous vs. Asynchronous I/O
Synchronous submission waits for completion in the issuing flow. Asynchronous submission separates issue from completion. Buffer lifetime and error handling must extend through completion.
I/O Schedulers: Noop, CFQ, Deadline, BFQ
Schedulers balance latency, fairness and throughput. Older single-queue scheduler names differ from blk-mq choices. Inspect the device’s actual scheduler options before applying historical tuning.
The evolution of Async I/O: select, poll, epoll
Select, poll and epoll report readiness for supported descriptors. Readiness lets a loop decide when to attempt an operation. It is distinct from a completed disk read.
High-performance I/O: io_uring
Io_uring exchanges submissions and completions through shared rings. The application must track outstanding requests and buffer ownership. Queue depth changes both throughput and tail waits.
Journaling File Systems: ext4 and XFS
A journal records changes needed for filesystem recovery. Data versus metadata guarantees depend on filesystem and mode. Applications still need the right sync and ordering protocol.
SSD vs HDD: Characteristics and Optimization
Rotating media incur seek and rotational delay. Flash removes mechanical seeks but has internal parallelism, garbage collection and wear management. Random-write latency still varies with load.
NVMe internals and queues
NVMe supports multiple submission and completion queues. Device parallelism can sustain several outstanding requests, though pushing beyond useful depth increases completion time.
RAID Levels Overview (0, 1, 5, 6, 10)
Striping spreads work, mirroring duplicates data and parity reconstructs after certain failures. RAID level changes failure tolerance and rebuild risk. It does not provide historical recovery.

How it works

Step through the idea, or press Play.

Step 1 of 4

Read on a miss. The requested data is absent from page cache and must be fetched.

Understand it

Worked incident

A throughput gain that hurts tail reads

ObservationRead completion p95 (ms)Interpretation
Baseline4Reads share a shallow queue.
Incident81Outstanding bulk writes occupy queue slots and tail reads wait.
After intervention7Limit bulk queue depth and verify read p95 alongside sustained batch throughput.
Illustrative measurements from the same workload at three checkpoints.

Choose the next investigation

If device waits remain flat while the application slows, measure filesystem serialization or application-side queueing.

Summary

The whole topic in one minute.

The device can deliver high throughput while individual reads wait behind earlier work. The user deadline applies to completion time.

If device waits remain flat while the application slows, measure filesystem serialization or application-side queueing.

Sources