# Benchmarks

Speed only counts if the files are right. Every benchmark here measures both: images per second, and whether each file that should exist does, byte for byte.

Clean network, 80 ms RTT · 5,000 images

Machyon841 img/s0 missing, 0 bogus

img2dataset, defaults706 img/s0 missing, 0 bogus

img2dataset, retries=3689 img/s0 missing, 0 bogus

Real-world faults · 5,000 images

Machyon586 img/s0 missing, 0 bogus

img2dataset, defaults259 img/s98 missing, 10 bogus

img2dataset, retries=3285 img/s10 bogus

Rate-limited CDN (max 48 in flight) · 3,000 images

Machyon300 img/s0 missing, 0 bogus

img2dataset, defaults2 img/s2,992 missing

img2dataset, retries=30 img/s2,997 missing

Slow link, 2.3 MB/s · 2,000 images

Machyon114 img/s0 missing, 0 bogus

img2dataset, defaults99 img/s0 missing, 0 bogus

img2dataset, retries=398 img/s0 missing, 0 bogus

High latency, 350 ms · 3,000 images

Machyon237 img/s0 missing, 0 bogus

img2dataset, defaults234 img/s0 missing, 0 bogus

img2dataset, retries=3239 img/s0 missing, 0 bogus

Local fault-injecting test CDN, every file checked byte for byte. Missing: rows that could have succeeded but have no file. Bogus: files that aren't the image. Full method and every scenario on the benchmarks page.

## Results

Measured on 2026-11-21 with Machyon 1.2.3 and img2dataset 1.47.0. Each figure is the median of three runs; the results file keeps all three.

| Scenario | Images | Tool | img/s | Missing | Bogus files | Wall time |
| --- | ---: | --- | ---: | ---: | ---: | ---: |
| Clean network, 80 ms RTT | 5,000 | Machyon | **841.0** | 0 | 0 | 6.0 s |
|  | 5,000 | img2dataset, defaults | 706.4 | 0 | 0 | 7.1 s |
|  | 5,000 | img2dataset, retries=3 | 688.9 | 0 | 0 | 7.3 s |
| Real-world faults | 5,000 | Machyon | **586.5** | 0 | 0 | 8.5 s |
|  | 5,000 | img2dataset, defaults | 259.2 | 98 | 10 | 18.8 s |
|  | 5,000 | img2dataset, retries=3 | 285.1 | 0 | 10 | 17.5 s |
| Rate-limited CDN (max 48 in flight) | 3,000 | Machyon | **299.7** | 0 | 0 | 10.0 s |
|  | 3,000 | img2dataset, defaults | 2.0 | 2,992 | 0 | 4.0 s |
|  | 3,000 | img2dataset, retries=3 | 0.4 | 2,997 | 0 | 7.0 s |
| Slow link, 2.3 MB/s | 2,000 | Machyon | **114.5** | 0 | 0 | 17.5 s |
|  | 2,000 | img2dataset, defaults | 98.6 | 0 | 0 | 20.3 s |
|  | 2,000 | img2dataset, retries=3 | 98.5 | 0 | 0 | 20.3 s |
| High latency, 350 ms | 3,000 | Machyon | **237.4** | 0 | 0 | 12.6 s |
|  | 3,000 | img2dataset, defaults | 234.3 | 0 | 0 | 12.8 s |
|  | 3,000 | img2dataset, retries=3 | 239.3 | 0 | 0 | 12.5 s |
|  |  | img2dataset, hand-tuned to 24 in flight | 231.2 | 0 | 0 | 13.0 s |

| Column | Meaning |
| --- | --- |
| **img/s** | Images written per second of wall-clock time, including process start-up |
| **Missing** | Rows that could have succeeded (the CDN served the image) but have no file |
| **Bogus files** | Files that exist but aren't the image: HTML error pages saved as images |
| **Wall time** | From starting the process to its exit |

No tool produced a **corrupt** file (right name, wrong bytes) in any scenario, so that column is left out.

## What the numbers say

- **Real-world faults.** Machyon was more than twice as fast, missed nothing and saved no bogus files. With its defaults, img2dataset lost 98 images to transient errors; `retries=3` recovered them. Both img2dataset configurations kept the 10 HTML "soft 404" pages as image files.
- **Rate-limited CDN.** At its defaults, img2dataset sent 256 requests at once into a CDN that allows 48, and lost 2,992 of 3,000 images to 429s. Machyon found the limit on its own. img2dataset can get all 3,000 too, once hand-tuned to 24 requests in flight, at 231 img/s.
- **Honouring `Retry-After` costs a little speed.** Since 1.0.2, Machyon sends nothing new to a host until its `Retry-After` wait is over. Against this CDN it received 41 429s, where 1.0.0 received 264, and finished at 300 img/s instead of 343: about 13% slower, with six times fewer requests refused.
- **Slow link and high latency.** When the network is the bottleneck, the tools converge. Machyon was ahead on the slow link (114 against 99 img/s). At 350 ms latency the two were level: Machyon 237 img/s, img2dataset 234 at its defaults and 239 with `retries=3`, all within the spread between runs.

## Method

**The server.** Both tools downloaded from the same local CDN, `benchmarks/fakecdn.py`. Each scenario sets its network conditions and faults:

| Scenario | Conditions |
| --- | --- |
| Clean network | 80 ms round trip, 160 ms connection handshake |
| Real-world faults | As clean, plus 2% slow responses (3 s), 1% 503s, 0.5% connections dropped mid-body, 0.2% stalls, 0.3% dead links (404), 0.2% HTML "soft 404" pages, 2% images served as `application/octet-stream`, 1% redirects |
| Rate-limited CDN | As clean, but more than 48 requests in flight are answered with 429 and `Retry-After: 1` |
| Slow link | As clean, with total bandwidth limited to 2.3 MB/s |
| High latency | 350 ms round trip, 700 ms handshake, 3% slow responses (4 s) |

**The tools.** Machyon ran with its defaults. img2dataset was given its fastest raw-download settings (no resizing, no re-encoding, no EXIF or hash work, 2 processes) and tested at its defaults and with `retries=3`; on the rate-limited CDN it was also hand-tuned to 8, 16 and 24 requests in flight, and the best result is shown.

Both tools downloaded the same real JPEGs (`--real-jpeg`), and every configuration ran three times; the tables and charts show the median run.

**The check.** After each run the harness compares every expected file with the original bytes and counts missing, corrupt and bogus files. Rows the CDN can never serve (dead links, soft-404s) are excluded from "missing" for every tool.

**The machine.** A 2-vCPU machine, shared with the CDN. Absolute numbers on your hardware and network will differ; the relative behaviour is what these scenarios are designed to show.

## Reproduce them

```bash
git clone https://github.com/DivyanshuSingh96/machyon && cd machyon
pip install -e ".[dev]"
python benchmarks/harness.py --impl machyon --scenario realistic --n 5000 --server="--real-jpeg --pregen 5000"
```

For img2dataset, install it in a separate environment and point the harness at it:

```bash
I2D_PYTHON=.venv-i2d/bin/python python benchmarks/harness.py --impl i2d --scenario realistic \
    --n 5000 --server="--real-jpeg --pregen 5000" --client="0 256 2"
```

Each run prints one JSON line in the same format as `benchmarks/results-2026-11-21.jsonl`, the file this page is generated from.

## Where img2dataset is the better choice

img2dataset is an excellent tool built for a different job: resizing, WebDataset and Parquet shards, captions, and distributed runs on Spark or Ray across hundreds of millions of images. If you need those, use it. Machyon is for getting every image of a list onto the machine you have, completely and verifiably, as a library you can embed or a command you can re-run.
