# Fewer file reads, another transfer boundary

A constructed read example separates three quantities: requested file bytes,
logical file-read calls, and payload moved between ranks. It is not a storage
benchmark, a ROMIO implementation or a reproduction of published timings.

## Layout and accounting

The file contains 16 adjacent blocks of 4096 bytes each. Rank r owns blocks whose
index modulo 4 equals r. Each of four ranks therefore needs 16 KiB, and the group
needs the full 64 KiB file. KiB means 1024 bytes.

Two aggregators, ranks 0 and 1, own contiguous file domains: blocks 0-7 and 8-15.
Each retains its own two blocks and sends the other six to their requesting
ranks. Thus 12 blocks cross rank boundaries: 12 x 4096 = 49152 bytes (48 KiB).
This is payload counted once at the sending boundary, not packets, messages,
physical network traffic or send-plus-receive byte counters. Ranks can share a
host, so cross-rank does not necessarily mean cross-host.

| Read strategy | Logical file-read calls | File-read bytes | Cross-rank redistribution |
| --- | ---: | ---: | ---: |
| One read per requested block | 16 | 64 KiB | 0 |
| One spanning read per rank, unlimited buffer | 4 | 208 KiB | 0 |
| Two equal domains, 32 KiB buffers | 2 | 64 KiB | 48 KiB |
| Two equal domains, 8 KiB buffers | 8 | 64 KiB | 48 KiB |

A rank's spanning read covers 13 blocks to obtain four; the four reads therefore
transfer 52 blocks. Complementary ownership makes every file block useful to the
group, but not to every independent reader. Smaller aggregator buffers increase
calls without changing this example's payload totals. The model does not decide
which strategy is faster.

## Reproduce and change the example

Run `node model.mjs` for input/output JSON and `node --test model.test.mjs`
for boundary and exhaustive small-layout tests. Import `account` from
[model.mjs](model.mjs) to vary positive integer ranks, blocks per rank, block size,
aggregator count and buffer capacity in blocks.

Ranks are limited to 1024; aggregator count cannot exceed ranks. Equal whole-block
domains are required. Unsupported fractional, zero, nonfinite and unsafe values
are rejected. Internal integer arithmetic is exact; results exceeding the safe
JavaScript Number range are rejected. No input files or external dependencies
are required. [Tests](model.test.mjs) check the closed form against block-by-block
enumeration instead of merely restating its formula.

For p ranks, k blocks per rank and block size b, useful bytes are p*k*b.
Independent full-span bytes are p*((k-1)*p+1)*b. With a aggregators and capacity c,
each domain has d=p*k/a blocks and the collective call count is a*ceil(d/c).
Aggregator r retains blocks j in its domain satisfying j mod p = r.

## Interpret the boundary

These illustrative domains are specified inputs, not a prediction of any MPI
library's aggregator selection or hint defaults. There are no missing blocks,
overlapping requests, duplicate consumers or writes. The independent baseline
coalesces the single-rank case. The full-span baseline has no buffer cap.
File reads can be split or satisfied from caches below the modeled boundary.

Redistribution has startup, copying and synchronization costs. Physical placement,
filesystem striping, caches, contention, network topology and durability are
outside this accounting. No timing or performance ratio can be inferred from
the table.

In the historical ROMIO algorithm, bounded memory can require several rounds
within the two-phase strategy. Its UNSTRUC read results also include a case
where independent sieving outperformed collective access; aggregation is not
universally faster. [ROMIO paper](https://web.cels.anl.gov/~thakur/papers/romio-coll.pdf)

Collective buffering is an optimization, while MPI collective participation is
a call contract. The ROMIO guide allows collective calls to use individual
accesses when buffering is disabled or not selected by heuristics.
[ROMIO hints](https://ftp.mcs.anl.gov/pub/romio/users-guide/node6.html)

## Connected definitions

[Collective I/O](https://hesela.dev/terms/collective-io/),
[two-phase I/O](https://hesela.dev/terms/two-phase-io/),
[data sieving](https://hesela.dev/terms/data-sieving/) and
[disk-directed I/O](https://hesela.dev/terms/disk-directed-io/) describe different
contracts or control locations.

Created 2026-12-02. Original Hesela arithmetic; no external dataset or hardware
measurement. Third-party papers are linked, not redistributed here.
