ADR-0154: The gate's hot paths are counted by Tally in every pull request
Status: Accepted Date: 2026-11-15 Amends: 0011: its table of the gates the package holds itself to, by one row
Context
The gate’s own work grows with the project it judges: the mutants of each
unit, the plan and its cut, the coverage map and the ledgers it reads and
writes, and the reports it renders. Unit tests built on
tests/Support/Growth.php keep the worst of it linear by comparing CPU time
at two sizes. CPU time on a shared runner moves by more than most
regressions, so those tests only tell linear from quadratic. A change that
makes a hot path twice as slow passes them.
Tally counts the instructions, cycles and memory of a benchmark under CodSpeed’s CPU simulation, which is built on Valgrind. With the same PHP build, the counts barely move from run to run, so expected numbers are committed beside each benchmark and checked like a test’s expected output. Tally runs only on Linux, x86_64 or aarch64, and needs no account; it uploads nothing.
Decision
-
phpstan/tallyis a dev dependency of the root project. It requires nothing but PHP 8.2, so it shares the rootcomposer.locklike every other tool the package uses; the package keeps no Composer project per tool. -
Benchmarks live in
tests/Bench, mirroringsrc, each class in a*Bench.phpfile named like it.tally.phpat the root names the directory and runs every case withmemory_limit=-1. A benchmark builds its input in its data provider, so the counted call is the work alone. -
Growth is held by a complexity class, size by expected numbers. Where the cost must not grow faster than its input, the benchmark runs at three sizes and states the class (
#[Linear],#[Linearithmic]), with Tally’s ±10 % growth tolerance. Elsewhere it holds#[Expected]numbers, with Tally’s default tolerance: ±2 % instructions, ±5 % cycles but at least 2,000, ±5 % memory. The first benchmarks:Benchmark What it counts Held to Mutator/Engine/EngineBenchthe default mutators making a file’s mutants and counting its sites linear in its methods Core/Plan/CutBenchcutting weighed units into shards, by size and to a target linear in the units Core/Coverage/CoverageMapBenchjoining two maps, writing a map’s text linear in the lines Core/Proof/LedgerJsonBenchwriting a ledger’s text, decoding a ledger linear in the proofs, which come from a few runs: retention orders the instants of their runs, never the proofs Core/Report/ReportBenchthe JSON report and the sticky comment of a verdict linear in the mutants Adapter/Outbreak/ReportAnswerBenchreading the outline outbreak.so answers of a coverage report linear in the tests -
The
tallyjob runstally runon every pull request whose change reaches the program, aschecksdoes: tally.yml, which ci.yml calls, so its check istally / tally. It runs onubuntu-24.04, a fixed image, with PHP 8.5 andposix, and keeps its results as thetally-resultsartifact. A case that is slower than its numbers or its class, or is not measured, fails the job. A new case passes until its numbers are accepted. -
Expected numbers come from CI, never from a laptop. The counts depend on the PHP build, its patch release, its extensions and the runner image. A pull request that adds or changes a benchmark takes its numbers from its own run:
gh run download <run> -p 'tally-*' -D tmp/tally, thenvendor/bin/tally accept tmp/tally. -
The job is a required check once every case holds its numbers.
-
ADR-0011’s table of the toolchain gains this row:
Piece In the in-house project Here Why Tally none Added The gate’s hot paths are counted on every pull request, so a slowdown is caught by its instructions, not guessed from noisy times.
Alternatives considered
| Alternative | Why not |
|---|---|
A Composer project of its own under tools/tally | Tally requires nothing that conflicts with the root’s dependencies, and the package keeps no tool apart. |
More Growth tests | They compare CPU time, which tells only a class of growth apart, and only roughly. |
| phpbench with timings | Timings on a shared runner move by more than the regressions worth catching. |
| Expected numbers measured locally | Tally does not run on macOS, and counts from another build or image differ. |
Consequences
- Updating PHP’s patch release in CI, or the runner image, moves the counts of many cases at once; their numbers are accepted again from that run.
- The
Growthunit tests stay: they run everywhere the suite does, including on a laptop.