Skip to content

Benchmark methodology

The release claim is about the modes that have a direct competitor API:

  • values parsing: adotenv::parse_values against each competitor’s in-memory value parser;
  • file loading: adotenv::load::load_values against each competitor’s value-loading API;
  • memory: the peak heap, retained heap and allocation count of those results.

It does not claim superiority for lossless documents, edits, formatting, sorting, reference inspection or resolution. Those APIs retain exact source spans, token structure or expansion state that the compared libraries do not expose; no like-for-like competitor cell exists. Internal workloads are still covered by the deterministic instruction/cycle gate and the memory gate.

The retained-heap result for 1.4.1 is a documented no-loss result, not a strict win. parse_values returns BTreeMap<String, String>. At small sizes the maps are byte-identical to the competitors; at larger sizes the map is already at the compact-tree floor. A strict retained result requires a different public values representation. The compact API provides that representation as of 1.5.0.

The compact evaluation uses parse_values_compact and load_values_compact with the same fixtures and competitors. The 1.5.0 memory run (release candidate 0a9fc92) records strict non-empty retained-heap wins, zero-byte ties on empty inputs, and strict peak/allocation wins in all values/load cells; the speed run is post-release evidence from 79937cc. See RESULTS-1.5.0.md. It does not replace the 1.4.1 map-based claim.

Pinned versions:

Competitor Version Values API Load API
dotenvy 0.15.7 yes yes
dotenv 0.15.0 no yes
dotenvs 0.2.2 yes yes
dotenv-parser 0.1.3 yes no
dotenv-flow 0.16.2 no yes

dotenv-ng 1.0.0 is deferred because its loader/CLI surface does not compare without semantic ambiguity.

Only the conservative Portable shapes plain, long-line and empty are used. Quoted/escaped, duplicate, malformed, multiline, CRLF/BOM, references and realistic mixed inputs are reported as unsupported because the libraries disagree on their semantics. See SCENARIOS.md.

Fixtures are generated deterministically from a size and shape. Sizes are 8, 128, 1,000, 10,000 and 100,000 declarations. Every memory row records the exact SHA-256 of the generated source, and the scenario catalogue lists all comparable fixture hashes. Speed benchmark names include the shape and size; the same fixture generator and hashes apply.

Speed is measured with Criterion in release mode, using the pinned competitor adapters and output validation before timing. The published command is:

Terminal window
cargo run -p adotenv-xtask -- queue-speed \
--host "$ADOTENV_BENCH_HOST" \
--remote-root "$ADOTENV_BENCH_ROOT" \
--out docs/benchmarks/speed.txt --sync

The raw file uses Criterion’s bencher output:

test competitor_values/adotenv/plain/128 ... bench: ... ns/iter (+/- ...)

A median/estimate and its reported spread are the unit of comparison. The release summary compares the adotenv line with the best competitor line for the same mode, shape and size. The 1.5.0 compact run adds an adotenv-compact line to the same values/load cells and compares it with the same best competitor; the 1.6.0, 1.7.3 and 1.8.0 runs also measure adotenv-compact-entries in values cells. Criterion wall time is publication evidence; it is not a PR gate.

adotenv-bench’s memory binary measures one case in a fresh process. A counting global allocator records:

  • peak_heap_bytes: maximum live heap above the pre-operation baseline (using deterministic logical live-byte deltas on realloc);
  • retained_heap_bytes: live heap while the result is held;
  • heap_after_drop_bytes: live heap after dropping the result;
  • allocations: successful alloc, alloc_zeroed and realloc calls above the baseline (counted once per call; 1.7.3 is the first versioned snapshot after the realloc double-counting fix, while historical snapshots through 1.6.0 predate it);
  • rss_before_bytes, rss_peak_bytes, rss_after_bytes: Linux RSS where available.

The operation is the public API under test (values, document, load or resolve). The counting allocator makes heap and allocation results independent of host wall-clock noise. The fixture and the empty baseline are measured in the same process, so retained values are not inflated by fixture source storage that is still owned by the test driver.

Memory publication runs use the release binary, not a debug build. The xtask memory and xtask queue paths build release binaries automatically.

The source-level deterministic memory gate compares a fresh run with docs/benchmarks/memory.jsonl:

  • allocations must match exactly;
  • peak and retained heap may grow by at most the larger of 5% or 64 bytes;
  • heap_after_drop_bytes must not exceed the baseline (zero leak);
  • a changed or missing fixture SHA-256 fails the gate.

Both baselines are updated only for an intentional, reviewed code change with fresh fingerprints. Do not update them merely to make a failing gate pass. Refresh the map and compact memory matrices from the same code SHA, update both JSONL/Markdown/fingerprint sets, and verify all gates. CI runs the same gate against compact-memory.jsonl for both --implementation adotenv-compact and --implementation adotenv-compact-entries; empty compact cells are zero-byte ties and allocation counts must still match exactly.

adotenv-bench/benches/det_parse.rs runs four map-parsing cells, four compact values parsing cells, four compact entries parsing cells and two compact-loading cells under Valgrind Callgrind through gungraun. The gate compares a freshly built merge base with the PR in the same run and fails on Ir above +2% or estimated cycles above +5%. Branch counters are diagnostic only. This is the load-immune CI gate; Criterion is not used for PR pass/fail.

bench-smoke exercises the deterministic harness and the memory gate on every PR. det-perf runs the base/head instruction/cycle comparison.

Publication runs use a dedicated quiet Linux reference host reached over SSH through a single-slot serialized pueue queue (default group bench, one parallel slot, configured via ADOTENV_BENCH_HOST, ADOTENV_BENCH_GROUP and optional PUEUE_CONFIG_PATH / ADOTENV_BENCH_USER). Work is serialized and no host-wide CPU, swap or other projects’ queue/CI settings are changed.

Every result directory includes a fingerprint sidecar with:

  • OS and architecture;
  • CPU model and CPU count;
  • kernel;
  • Rust compiler version;
  • hyperfine version; Criterion and dependency versions are pinned in Cargo.lock;
  • the adotenv git SHA used for the benchmark binary;
  • one-minute load average at the run.

Publication checks the fingerprint matches the intended host and records the load. A run on a noisy or different host is not comparable and must not be used for a release claim.

  • Criterion reports an estimate and spread; do not compare single samples.
  • Very small cells are dominated by fixed setup costs. They remain in the matrix and are reported as wins only when the measured ordering is strict.
  • Memory heap and allocation counts are deterministic on the reference Linux host. RSS is advisory and may vary with the allocator and page cache.
  • A retained-memory tie is recorded as a tie. It is not converted to a win by dropping the cell or changing the metric.
  • Load average is recorded, not used to silently filter a run.