Part 4 of 7 · 3 min read
I/O time and rate
Think of a delivery van that takes 13 minutes to reach the warehouse and load, and then drives a fixed route at constant speed. For one small parcel the whole trip is mostly waiting. For a full load the trip is mostly the drive. The analogy stops in one place: a van's load time grows with the parcel, and a disk's start-up time does not.
In plain words: The time to start moving data is a fixed cost: seek plus rotation. The time to move data grows with the size. A small request pays the fixed cost for almost no data, so its rate is tiny. A large request spreads the same fixed cost over many bytes, so its rate approaches the drive's peak rate.
A worked example (made up to show the idea). The drive has a 9 ms seek, a 7,200 RPM spindle and a peak rate of 100 MB/s. A 4 KiB read (4,096 bytes) needs 4,096 / 100,000,000 s = 0.041 ms of transfer. The I/O time is 9 + 4.167 + 0.041 = 13.208 ms. The rate is 4,096 bytes / 0.013208 s = 0.31 MB/s. A 100 MB read needs 1,000 ms of transfer. The I/O time is 9 + 4.167 + 1,000 = 1,013.167 ms and the rate is 98.70 MB/s.
The key lines. This small C program does the same sum. Compile it with gcc -Wall -Wextra.
#include <stdio.h>
int main(void) {
double rpm = 7200.0, seek_ms = 9.0, rate = 100e6; /* bytes per second */
double rot_ms = 60000.0 / rpm; /* one full turn */
double avg_rot = rot_ms / 2.0;
double sizes[] = {4096.0, 100e6};
for (int i = 0; i < 2; i++) {
double xfer = sizes[i] / rate * 1000.0;
double t = seek_ms + avg_rot + xfer;
printf("size %.0f B: seek %.2f + rot %.3f + xfer %.3f = %.3f ms, rate %.2f MB/s\n",
sizes[i], seek_ms, avg_rot, xfer, t, sizes[i] / (t / 1000.0) / 1e6);
}
return 0;
}
Output on the test machine:
size 4096 B: seek 9.00 + rot 4.167 + xfer 0.041 = 13.208 ms, rate 0.31 MB/s
size 100000000 B: seek 9.00 + rot 4.167 + xfer 1000.000 = 1013.167 ms, rate 98.70 MB/s
I/O time
The I/O time of one disk request is the time from the start of the request until its data has been transferred. For a hard disk it is the sum of the seek time, the rotational delay and the transfer time.
Example: 9 ms of seek, 4.167 ms of rotation and 0.041 ms of transfer give an I/O time of 13.208 ms for a 4 KiB read.
Check yourself: 1. In the worked example, what share of the 13.208 ms is transfer? 2. Why is the rate of a 100 MB read almost equal to the peak rate? 3. If the seek time halves, which request gains more in percent, the 4 KiB read or the 100 MB read?