# Why the shorter seek can lose

This is an exact arithmetic teaching example, not a hardware benchmark,
a workload simulation, or a reproduction of any paper's performance results.
All times below are synthetic. No confidence interval is appropriate for
a deterministic calculation.

## The decision

Let R be the revolution period in microseconds, s the seek-and-settle time,
t the dispatch time, and p the time offset at which the target sector passes
the head in each revolution, with 0 <= p < R. In this deliberately simple
model the first accessible passage is:

    residual_rotation = (p - t - s) mod R
    positioning = s + residual_rotation

Modulo returns a nonnegative remainder. Rotation continues during the seek.
A sector exactly under the head when the seek completes is catchable here;
real hardware needs its own settle, command and safety margins.

At t = 0 and R = 10,000 microseconds:

| Request | Seek | Sector phase | Residual rotation | Positioning |
| --- | ---: | ---: | ---: | ---: |
| near | 1,000 | 500 | 9,500 | 10,500 |
| far | 3,000 | 3,500 | 500 | 3,500 |

SSTF chooses near. SPTF chooses far. Both are given the same 100-microsecond
transfer time. These two hypothetical choices do not establish a workload
speedup, a complete optimal schedule, or an SSD recommendation.

## A discontinuity, not a proportional penalty

With phase 1,000, a seek that ends at 1,000 reaches the sector immediately.
Ending at 1,001 misses that passage and starts transfer at 11,000 instead.
A one-microsecond seek prediction error therefore changes this model's
transfer-start time by one complete revolution. It does not mean every
one-microsecond error on a real drive costs one revolution.

## Positioning is not completion

The additional unequal-transfer case selects a request positioned at 100
with transfer length 10,000, giving completion at 10,100. A competing request
positioned at 200 with transfer length 100 would complete at 300 if selected.
Minimizing positioning alone does not minimize completion for unequal transfers.

## Evidence and limits

[Worthington, Ganger and Patt (SIGMETRICS 1994), sections 2-4](https://users.ece.cmu.edu/~ganger/papers/sigmetrics94.pdf)
distinguish seek-only from positioning-aware selection and examine disk-cache
effects using a validated simulator and traced workloads.
[Jacobson and Wilkes (1991), sections 4-5](https://john.e-wilkes.com/papers/HPL-CSP-91-7rev1.pdf)
give a rotational access-time equation and distinguish greedy selection from
whole-queue optimization.
[Seltzer, Chen and Ousterhout (Winter USENIX 1990), sections 3 and 5](https://web.eecs.umich.edu/~pmchen/papers/seltzer90.pdf)
provide earlier seek-plus-rotation scheduling and describe their simulation
and validation method. None of their empirical curves is recreated here.

We supply seek duration directly, rather than claim a calibrated geometry.
There are no cache hits, prefetching, remapped sectors, track skew, queue arrivals,
firmware reordering, retry costs, bus contention or multi-actuator effects.
The selector makes one decision and cannot establish fairness or starvation bounds.

## Reproduce

Python 3 standard library only. In a directory containing the linked files:

    python3 -B model.py --check
    python3 -B -m unittest -v test_model.py
    python3 -B -O -m unittest -v test_model.py

[model.py](model.py), [test_model.py](test_model.py), and [result.json](result.json)
are public. The tests compare modulo arithmetic against independently enumerated
sector passages, including zero seeks, multi-revolution seeks, dispatch phase,
ties, invalid inputs and the exact boundary. Use model.py --write to regenerate
the result; verification never rewrites it.
