The performance gate
Every pull request that changes what the server or the sync service is
built from runs the perf job of CI, a required part of conclusion. It
also runs on every push to main, and the release workflow runs it on the
release commit before the release is drafted. The job measures the release
builds of ferroterm and ferroterm-sync with
ferrohealth-perf,
the performance gate every FerroHEALTH server shares. It fails when a
service is busy at rest, or slower, heavier or busier under load than the
build of its base, measured beside it on the same runner in the same job.
.github/workflows/perf.yml pins the tool’s version.
Why the head is judged against its base
GitHub’s hosted runners differ: two runners that report the same CPU model and memory can measure one commit a quarter or more apart in latency and CPU per request, so a baseline stored from one machine fails unchanged code on another, and the gate keeps none. It builds the base of the change and the change itself, the head, runs both on one runner, and judges the head over the base. The difference between machines reaches both alike and cancels.
The base is:
- for a pull request, the merge base of the commit CI checks out with the pull request’s base branch;
- for a merge group, its base on
main; - for a push to
main, the commit before the push; - for the release commit and a manual dispatch, the previous release tag.
What it runs
scripts/perf/gate.sh build builds the release server, sync service and
fixture writer of the base, from git archive of the base commit under
target/perf-base/, and of the head. A base must define the server and the
sync service; a base without the fixture writer builds the two services
alone. scripts/perf/gate.sh run starts two instances of each side. Each
instance writes its own copy of the scaled synthetic SNOMED CT edition of
the testkit, 50,000 invented concepts, with its side’s ferroterm-fixture snomed-scaled, the head’s for a base without one. It starts a server over
that edition and its side’s e2e CodeSystem fixtures, with its admin
listener on: the head’s on ports 8080 and 8081 and on 8082 and 8083, the
base’s on 8090 and 8091 and on 8092 and 8093. Against each server it starts
a sync service with a daily schedule whose next run is twelve hours away:
the head’s on 8181 and 8184, the base’s on 8191 and 8192. Then it runs
ferrohealth-perf ab once per service, with both instances of each side:
- Idle. No request for 60 seconds. The head’s CPU time must stay under 2 % of one core. The limit is absolute and compared with nothing. Neither service holds a database, so the gate counts no transactions.
- Load, in pairs. Four pairs of load phases, each phase 50 requests a
second after a 10-second warm-up, open loop, against one side: 180
seconds for the server, so each of its single-request groups holds 1,000
samples and its p99 rests on the 10 slowest of them, and 60 seconds for
the sync service, whose two groups hold 1,500 each. The first two pairs take each side’s first instance and the next
two its second, so each instance meets both sides leading. The two phases of a pair run at once, the arrivals of one side half
an interval after the other’s, so both sides meet the runner in the same
state; run one after the other, the runner’s speed moved by up to a third
between phases and put an unchanged head up to a third off its base.
For the server (
perf/server/plan.toml):$lookup,$validate-codeon a code system and on an ECL value set,$expandwith a text filter, two ECL expansions,$translateover the implicit ICD-10 map and$subsumes, through the R4 base. For the sync service (perf/sync/plan.toml):GET /runsand the readiness probe. Every request must be answered with the status the plan names.
Then the script starts a head sync service whose schedule is
every = "1ms", the shortest interval the service accepts, so its
scheduler starts each run the moment the last one ends, and runs the idle phase of perf/sync/busy-loop.toml against it. That
run must fail on idle CPU, or the job fails: it proves the gate still
catches a background worker that never waits.
Reading the report
Each load metric (throughput, latency p50, p95 and p99 per group, peak
memory and CPU time per request) is judged on the median over the pairs of
the head’s value over the base’s in that pair. Its noise floor is the
widest of the two sides’ spread, how far a side’s worst phase strayed from
its median, and the spread of those pair ratios. Two instances of one build
on one runner can differ for a whole run. With two instances a side, that
difference reaches only the pairs on one instance, so it widens the floor
and does not fail the head; a regression reaches both head instances, so
every pair. A metric breaches when the median ratio is worse than the
larger of its tolerance and that floor; the tolerances are each plan’s [tolerance] table: latency
and CPU 25 %, throughput 20 %, memory 20 %. It fails only when the head also
breaches against the base in most of the pairs, so a stall in one phase
clears and a regression, which repeats in every pair, fails.
The job summary holds one report per service: the outcome, the base
commit, the head’s idle limit, and per metric the base, the head, their
ratio, the tolerance, the floor, the threshold and in how many pairs the
head breached. Requests the head answered with another status are listed
and fail the gate; those the base answered with another status, such as a
route the change adds, are notes, and a metric only one side measured is
noted and not judged. Each attempt uploads its reports as
perf-report-attempt-<n>: the JSON reports under target/perf/ with every
phase’s histograms, the eight services’ logs and the base commit, so
ferrohealth-perf compare --report target/perf/server/latest.json judges a
report again without a server.
The tool exits 0 for a pass, 1 for a breach or a request answered with another status, and 2 for a run it cannot judge: a phase whose generator could not hold its rate, whose second half differs from its first, or that stalled, and a base that fell behind the schedule.
Latest numbers
These numbers come from the gate’s first run on two instances per side and
ferrohealth-perf 0.22.0, in the pull request that moved it there (#1528,
commit 0cfd5c7f). The runner was a 4-vCPU hosted runner, an AMD EPYC
9V45 with 15 GiB of memory, holding 50 requests per second. Each figure is
the head’s median over its judged pairs, with the base beside it, and the
ratio is the median over the pairs of the head’s value over the base’s.
Both builds are the same code, so the columns show how close two arms on
one runner come. Latencies are in milliseconds.
The server needed five pairs to get four it could judge: in one, the
largest group’s p50 interval was too wide to tell. In the two server pairs
on each side’s second instance, every group ran slower than in the three
on its first, in both sides alike: subsumes p50 was 0.13 to 0.18 ms on
the first instances and 0.28 to 0.31 ms on the second. Both arms moved
together, so the pair ratios held near 1.
| Server group | p50 | p95 | p99 | Base p50 / p95 / p99 |
|---|---|---|---|---|
lookup | 0.27 | 0.39 | 0.48 | 0.27 / 0.39 / 0.49 |
validate-code | 0.31 | 0.46 | 0.55 | 0.31 / 0.48 / 0.72 |
expand-filter | 1.70 | 1.97 | 2.59 | 1.71 / 2.00 / 2.47 |
ecl | 0.42 | 0.53 | 0.68 | 0.42 / 0.53 / 0.62 |
translate | 0.42 | 0.52 | 0.60 | 0.41 / 0.52 / 0.59 |
subsumes | 0.23 | 0.33 | 0.53 | 0.23 / 0.32 / 0.41 |
| Sync group | p50 | p95 | p99 | Base p50 / p95 / p99 |
|---|---|---|---|---|
runs | 0.12 | 0.19 | 0.34 | 0.12 / 0.19 / 0.35 |
readiness | 0.11 | 0.17 | 0.39 | 0.11 / 0.17 / 0.38 |
| Service | CPU per request | Peak memory | Idle CPU | Idle memory |
|---|---|---|---|---|
| server | 0.43 ms (base 0.43) | 98.3 MiB (base 100.1) | 0.0 % | 95 MiB |
| sync | 0.070 ms (base 0.068) | 16.6 MiB (base 16.7) | 0.0 % | 16 MiB |
The widest noise floor was 1.86 on the server and 1.47 on the sync service, both on a p99. The self-test’s sync service, whose schedule never waits, used 7.3 % CPU at idle against the 2 % limit, so the gate failed it as it should.
Retries
Some runners stall every route for a whole job: on an AMD EPYC 9V74 the
tails reach 100 to 300 ms while the p50 holds. A
phase where every route’s p99 is over ten times its p50 at once is a
stalled runner: it is reported, left out of the judgement, and the run
exits 2. An attempt that ends with exit 2 runs again on a fresh runner on
any CPU model, since a run that cannot be judged says nothing about the
code. An attempt that ends with exit 1 runs again only on a CPU model the
perf workflow lists in STALL_PRONE. At most two retries run, and the gate
passes when the last attempt passed. A breach on any other model fails at
once. The job summary names each attempt’s CPU model, its verdict and why
a retry ran.
Changing a plan or the tolerances
The plans are the head’s: a change to perf/server/plan.toml or
perf/sync/plan.toml is measured on both sides in the same pull request. A
tolerance moves only in a pull request that says why.