# Noncontiguous reads: fewer calls, more bytes

This constructed example counts logical bytes and read windows. It does not run
MPI, access a device or reproduce the performance results of either paper.

Start with four 4 KiB ranges whose starting offsets are 0, 16, 32 and 48 KiB.
They contain 16 KiB of useful data. Reading their entire span transfers 52 KiB,
including 36 KiB not requested: a logical amplification of 3.25.

Keep the range lengths but space the starts 1 MiB apart. The useful payload is
still 16 KiB; the complete span is now 3076 KiB, giving amplification 192.25.
Neither ratio is a slowdown or a physical-device write-amplification factor.

## Reproduce

Requires Node.js, with no packages to install:

```sh
node model.mjs
node --test model.test.mjs
```

The output contains eight cases: both layouts with maximum windows of 4, 16,
64 and 4096 KiB. With caps of 4 or 16 KiB, each layout needs four windows
and transfers only its 16 KiB payload. A 64 KiB cap covers the first layout
in one window but still uses four windows for the 1 MiB-spaced layout.

## Counting rule

Intervals are half-open: [start, end), in integer bytes. Overlaps are rejected.
The teaching implementation rejects more than 10000 ranges or output windows.
Sort the intervals, start at the next requested byte, and permit a window of
at most the specified cap. Include requested ranges inside that window and
trim any trailing unrequested gap. Split an interval when it exceeds the cap.
Jump over wholly unrequested gaps before starting the next window.

This is our illustrative bounded-span planner, not ROMIO source code or an
optimal grouping algorithm. Memory capacity limits each window, not total bytes
transferred. The output reports useful bytes, transferred bytes, extra bytes,
window count and their ratio. Empty input has zero bytes and a null ratio.

## What the counts leave out

Filesystem/block-device request splitting, cache hits, readahead, alignment,
network traffic, parallel execution, locking and buffer copies can change the
physical work and elapsed time. Four logical calls do not establish four disk
commands. A read-only accounting model does not implement safe write sieving.

The final test illustrates a separate correctness hazard with four array cells:
two writers snapshot [0,0,0,0], then modify different cells. Replacing the whole
array with the second stale snapshot loses the first writer's change.
Serializing the snapshots and replacements preserves both. This is a state
example, not a concurrent filesystem experiment or a durability guarantee.

## Evidence and scope

- [Data sieving](https://hesela.dev/terms/data-sieving/) summarizes the historical
  ROMIO mechanism and its independent-write protection requirement.
- [Disk-directed I/O](https://hesela.dev/terms/disk-directed-io/) explains the
  different server-side scheduling boundary.
- Thakur, Gropp and Lusk, *Data Sieving and Collective I/O in ROMIO*,
  Frontiers 1999, pp. 182-189:
  https://web.cels.anl.gov/~thakur/papers/romio-coll.pdf
- David Kotz, *Disk-Directed I/O for MIMD Multiprocessors*, ACM TOCS 15(1),
  February 1997, pp. 41-74:
  https://kotz.cs.dartmouth.edu/research/kotz-jdiskdir/kotz-jdiskdir.pdf

Accessed 2026-12-02. The source PDFs remain with their publishers/authors;
they are not redistributed here. The calculation inputs above are constructed,
not extracted benchmark records. Exact fetched-source hashes are recorded in
the repository research notes.
