# LMDB Copy Backpressure

A controlled synthetic observation, not a backup throughput benchmark or durability test.
Source: LMDB 0.9.33, commit 3a29a24777c82a0165de813ae696a5068b5add30.
Upstream is under OpenLDAP Public License 2.8; obtain it separately. The runner
checks the SHA-256 hashes of all four compile inputs and LICENSE before compiling.

## Run

Requires Linux, C11 compiler, pthreads and Python 3 standard library. Keep probe.c,
run.py, test_run.py and results.json together. Use an executable temporary filesystem
with at least 32 MiB free. The recorded run used /dev/shm, not a durable disk.

```sh
python3 run.py --lmdb /path/to/lmdb --output results.json
python3 -m unittest -v test_run.py
```

Only fresh temporary databases are used. The runner removes them on success or
failure and enforces a 30-second deadline per process. Do not run the probe in a
working database directory; its source/ and backup/ directories must not exist.
No dependencies are installed. Results include compiler/platform and code hashes.
Do not use Python optimization flags, because validation uses assertions.

## Method

Eight 16 KiB values, 64 warm-up overwrites, 256 attempted writes and 64 writes after
copy completion. Cross two map sizes (1/2 MiB), plain/compact output and completed/
paused receiver schedules; repeat each three times. Pause after reading three
pages from a one-page pipe so plain copy has released its initial metadata writer
lock. Remaining output cannot fit in the pipe. No sleep-based synchronization.

The native oracle checks every source and restored value, key count and lengths;
the failed write is absent from the source view. After draining, join and require
copy success before checking the backup. The compact implementation has its own
output thread in addition to the calling copy thread. Source map size stays fixed.

Extent means (last committed page number + 1) times page size. Backup bytes are
bytes transferred to a new data.mdb, not compressed or physically allocated bytes.
The paused case is not a measurement of actual network speed. Default LMDB commit
settings remain enabled; backup output is not explicitly fsynced. Reopening checks
readability and snapshot bytes, not crash survival or a production restore workflow.
Exact counts depend on geometry and workload. Repetitions are repeatability checks,
not independent field samples. Three source families were reviewed: Chu's 2011
paper (sections 3.2/4.2), pinned API header/copy implementation and mdb_copy manual.

Analysis: https://hesela.com/analyses/lmdb-readers-page-reuse-map-full/#backup-pressure
