Master the fundamental concepts of storage fundamentals through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksHDD random reads pay seek plus rotational delay before a 4KB sector arrives. SSD reads are electrical with tens of microseconds latency but very different write semantics: NAND must erase before reprogramming, driving write amplification and wear leveling.
Model HDD random read as seek + average rotation + transfer. Model SSD read as fixed microseconds; model SSD random write as read-modify-erase-write on affected pages.
cLoading…
Keep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will compute latency and IOPS tables for HDD and SSD constants provided in the starter code. This exercise asks you to print a comparison that motivates buffering and sequential layout.
"SSDs are faster" hides the real lesson: a hard disk pays a mechanical positioning cost, a seek plus half a rotation on average, before every random I/O, while its sequential bandwidth is respectable. Build a small latency model for disks and SSDs, run workloads against it, and see exactly where the 100× gap comes from, and where it shrinks to about 10×.
cLoading…
Up to 8 devices, with unique names of up to 15 characters. run evaluates the workload on every device, in definition order.
transfer(bytes) = round(bytes × 1000 / MBPS) (MB = 10^6 bytes).half_rotation = round(30,000,000,000 / RPM) and position = SEEK_US × 1000 + half_rotation.
COUNT × (position + transfer(size));position + transfer(COUNT × size) (one seek, then streaming).lat = READ_US or WRITE_US, × 1000.
COUNT × (lat + transfer(size));lat + transfer(COUNT × size).cLoading…
ms/op is round(total / COUNT) ns, printed the same way.IOPS = round(COUNT × 10^9 / total_ns), and MB/s = round(total_bytes × 10000 / total_ns) / 10, with one decimal. fastest: A, R.Rx faster than B, where A has the smallest total, B the largest (the first defined wins ties), and R = round(10 × worst / best) / 10. If all are equal, print all devices take the same time instead.error: usage: hdd NAME RPM SEEK_US MBPS (also for a duplicate name or a 9th device);error: usage: ssd NAME READ_US WRITE_US MBPS;error: usage: run random|seq read|write COUNT SIZE_KIB;error: workload larger than 1 TiB (COUNT × SIZE_KIB > 2^30);error: no devices;error: unknown command CMD.Input:
cLoading…
Output:
cLoading…
run must work for any mix of disks and SSDs.Hidden tests cover sequential workloads (where the gap shrinks), writes, a 15k-RPM disk against a SATA SSD, a single-device run, equal devices, large transfers, and malformed input.