Skip to content

Speed

Mutation testing runs the suite once for every mutant, so the gate’s speed comes from running fewer mutants, running each one for less, and spreading what is left over as many machines as the work needs. None of it changes a verdict: why a verdict can be trusted says what bounds each shortcut.

Running less

  • Only what a change reaches is mutated on a pull request (what a change reaches).
  • A proof cache keyed by content skips every unit an earlier run already proved, kept in the GitHub Actions cache, a directory, S3 or R2, Google Cloud Storage or Azure Blob Storage (ADR-0007, proofs and trust).
  • A pull request’s own earlier runs: a new push stands on the proofs its earlier runs made, and mutates only what they do not prove, unless proofs.ownScope is false (ADR-0081).
  • Pruning: on unchanged code, a mutator that has let no mutant through lately is skipped and its last result carried, and the scheduled full run audits it (ADR-0025).
  • Identical mutants run once: mutants that leave their file alike share one verdict, under Pest and the PHPUnit, PhpSpec, Codeception and Testo runners.
  • A static analyser kills what it rejects: Mago, PHPStan or Psalm checks each mutant, before its tests where that saves time, as staticCheck.before has it by default (ADR-0020, ADR-0077).
  • Coverage is measured again only for the tests whose inputs moved, and the map is kept beside the ledger (ADR-0023).
  • A sampled mode for huge repositories judges a sample of each tree’s units and its floor on the confidence interval of the estimate; new code and every tree at a floor of 100 are never sampled. Under sampling.auto, a pull request that reaches more than the threshold beyond its own lines samples by itself, and its plan says why (ADR-0020, ADR-0086).
  • Locally, subsumed mutants run last: the ledger learns which killed mutant subsumes which, and a local run under a budget shows a subsumed mutant’s kill as inferred, never as a proof (ADR-0079).

Running each mutant for less

  • Likely killers first: each mutant’s tests run in the order of which of them killed it before, so a kill comes sooner (ADR-0013).
  • Limits from each mutant’s own tests: a mutant is allowed a multiple of its covering tests’ time, not the whole suite’s, and, under pest.patch and the native runners, each of its tests a multiple of its own; timeouts.seconds, timeouts.multiple and shards.max can each be learned from earlier runs (ADR-0090, ADR-0073).
  • Warm workers: the PHPUnit runner, and Pest under pest.patch, fork each mutant’s run from a worker per process, which boots the autoloader and the bootstrap once (ADR-0070).
  • One schema per file under Pest: each file’s mutants are compiled into one schema, every mutant a switch, so a worker compiles the file once (ADR-0091).
  • Every core busy: a shard runs its work as a pool over the cores its process is allowed.

Spreading the work

  • Shards cut by learned cost: the plan cuts the units into shards of about the same expected cost, from how long each file took in earlier shards, and every build of a branch learns from the others (ADR-0006, ADR-0031).
  • A shard count from a target wall time, shards.target, which the plan warns about where it cannot meet it.
  • Every CI: the plan is rendered for GitHub Actions, GitLab CI, Bitbucket Pipelines, Azure DevOps, Buildkite, CircleCI and Jenkins, or as JSON for any other (running the gate in CI).
  • Survivors first: a new push to a pull request runs the last run’s survivors again in a job of its own beside its shards, an early signal the verdict does not judge (ADR-0020).
  • A doomed pull request stops early: once a confirmed survivor leaves a run no way to pass, run.failFast decides whether its shard fails at once or after judging every unit (ADR-0103).
  • Merge queues: a merge_group run is change-scoped from its base and carries from the default branch’s ledger, trusting no pull request’s own proofs. A group whose run reads inputs identical to its pull request’s passing run reuses that verdict (ADR-0022, ADR-0198).
  • An identical run is not run again: a pull request pushed again with the same tree, a re-land, a revert, and the push of a pull request merged as it was judged reuse the verdict of the earlier run that read every input identically: the files, the config, the gate’s release, PHP, the installed packages and the runner’s image. A push whose tree differs borrows the merged pull request’s results that still match their keys (reuse.identical, ADR-0198).

What a run saved

Every run says what it saved against a full run in one job: what reach and proofs spared, and what sharding saved in waiting and cost in runner time (ADR-0017). Locally, serve keeps the gate loaded between runs (local use).

The benchmark

bench.yml runs the gate against plain Infection and plain Pest on four pinned open-source projects: a cold full run, a warm full run, a replay of each project’s recent pull requests and an unchanged re-run, every arm three times on one GitHub-hosted machine, and the gate sharded across machines. Every scenario is shown, those where the gate is slower too. composer bench -- <project> runs the same harness locally, and the README shows the newest committed result (ADR-0017).