Part 7 of 7 · 3 min read
Exercises
Easy
Easy 1: Throughput (20 minutes)
A disk does 5,000 IOPS with 8 KiB requests. Find the throughput.
Done when: 40.96 MB/s (5,000 x 8,192 bytes).
Hint
IOPS times bytes per request.
Easy 2: Little's law (20 minutes)
A disk has an average of 4 requests in flight and a latency of 2 ms. Find the IOPS.
Done when: 2,000.
Hint
in flight = IOPS x latency, so IOPS = in flight / latency.
Easy 3: Bytes from sectors (20 minutes)
The sectors-read counter rises by 400,000 in 2 seconds. Find the read rate in MB/s.
Done when: 102.4 MB/s (400,000 x 512 / 2).
Hint
sectors times 512, divided by seconds.
Medium
Medium 1: Average latency (45 minutes)
Between two samples, reads completed rose by 12,000 and the milliseconds spent reading rose by 3,000. Find the average read latency and, if the interval was 4 seconds, the IOPS and the average queue depth.
Done when: 0.25 ms, 3,000 IOPS and 0.75 in flight.
Hint
latency = ms spent / requests. IOPS = requests / seconds. In flight = IOPS x latency.
Medium 2: Run the tool (45 minutes)
Compile the program of section 3 and run it on your own disk and a large file. Name the disk by looking at /proc/diskstats. Report the four printed values.
Done when: a line of output, and a note on whether the busy share and the average time are consistent with Little's law for one thread.
Hint
if the device has a different name, change the first argument.
Medium 3: dd on your machine (45 minutes)
Run the two dd commands of section 4 on your disk with a file of at least 512 MiB. Report both rates and the ratio.
Done when: two rates and a ratio, and a sentence that explains it using the fixed cost for each request.
Hint
use iflag=direct for both.
Hard
Hard 1: Add writes (90 minutes)
Extend the program of section 3 to print the writes completed, the write MB/s and the average write time, and run a write load of 4 KiB O_DIRECT writes to a scratch file in the child.
Done when: a second output line for writes that agrees with the sector and request counts, and a check of the write MB/s against the file size written.
Hint
the write fields come after the read fields. Use O_WRONLY | O_DIRECT and a file that you create.
Hard 2: Queue depth experiment (90 minutes)
Run 1, 2, 4, 8 and 16 threads that each make random 4 KiB O_DIRECT reads, and measure the IOPS at each count. Make a table and plot or describe the curve.
Done when: a table of five rows, and a sentence on where the IOPS stop growing, with the average latency at each row.
Hint
use fork or pthread_create. Count the completed reads of each thread.
Hard 3: Diagnose three servers (90 minutes)
A server shows 0.3 ms latency, queue depth 1, 100% busy, 3,300 IOPS on a flash disk that can do 40,000 IOPS at queue depth 32. A second shows 12 ms, depth 90, 100% busy, 7,000 IOPS on a hard disk that normally gives 100 IOPS at depth 1. A third shows 0.2 ms, depth 3, 25% busy. Decide which are limited by the disk and say what you would do.
Done when: a verdict for each with a reason: the first is limited by the program, the second needs an investigation of the measurement or of a cache, and the third is fine.
Hint
the second server's numbers are impossible for a hard disk, so ask what else answers the requests.