Aegis

Benchmarks and soak tests

What Aegis measures about its own performance and stability, how to run it, and how to read the results. Everything here runs in .github/workflows/perf.yml on GitHub-hosted Ubuntu runners (2–4 vCPUs, shared). Those machines are noisy, so treat the numbers as rough and look at trends, not single runs.

Status: benchmarks run on every PR and push to main; on a PR they are compared with the base commit on the same runner, and a regression only warns. A 5-minute soak runs on every push to main, a 60-minute soak nightly. The numbers in the tables below are a snapshot from one CI run each, not targets or guarantees. They say nothing about production hosts. See What is not measured.


1. Benchmarks (benchmarks/)

Benchmark What it measures Kind
event_bus/publish Publishing one event on the in-memory bus with one subscriber Criterion
projection/apply_event Folding one event into the in-memory projection Criterion
event_store/append Appending one event to a file-backed SQLite store (opened like the daemon: WAL, five connections, a sync listener updating a projection) Criterion
event_store/replay_12020 Reading back a realistic 12,020-event history (20 apps × 50 deployments) in order Criterion
projection/rebuild_12020 Rebuilding the projection from those events in memory Criterion
projection/load_and_rebuild_12020 Both, as the daemon does on every start Criterion
proxy/direct/sequential, proxy/ingress/sequential One small GET over a kept-alive HTTP/1.1 connection, straight to an app and through the built-in proxy (runtime/ingress) Criterion
proxy/direct/concurrent_64, proxy/ingress/concurrent_64 64 GETs over 8 kept-alive connections at once, both ways Criterion
deploy_saga/first_deploy, deploy_saga/direct_port Whole deployments of a tiny app (python3 -m http.server) through the real deploy saga: copy, build, package, start, health check, stop the previous release Timing harness
deploy_saga/behind_proxy The same with a domain on the proxy: side-by-side start, health check, switch, drain, stop Timing harness
deploy_saga/rollback_behind_proxy Rollbacks behind the proxy Timing harness

The proxy overhead is the difference between the ingress and direct rows.

The deploy saga harness is not a Criterion benchmark. It runs each scenario AEGIS_BENCH_DEPLOYS times (default 8, 15 in CI), prints min/median/p95/max and writes target/bench-results/deploy_saga.json. It polls health checks every 20 ms instead of the daemon’s 500 ms, so the numbers follow the saga’s own work and the app’s start-up rather than the poll interval; real deployments take up to 500 ms longer (the soak’s deploy row shows them with the daemon’s defaults). It runs on Unix only and does nothing under cargo test.

Running locally

cargo bench -p aegis-benchmarks                              # everything
cargo bench -p aegis-benchmarks --bench event_throughput     # one file
cargo bench -p aegis-benchmarks --bench proxy_overhead -- ingress   # a filter
AEGIS_BENCH_DEPLOYS=20 cargo bench -p aegis-benchmarks --bench deploy_saga

# The report CI produces, compared with an earlier bench-results.json:
python3 scripts/bench_report.py --criterion-dir target/criterion \
  --extra target/bench-results/deploy_saga.json \
  --baseline old/bench-results.json --out-json bench-results.json --out-md bench-report.md

Criterion keeps its own history in target/criterion, so a second local run also prints the change against the first.

How CI compares

Comparing two runs on different GitHub runners doesn’t work: the same commit measured twice, minutes apart on two runners, came out 17–83% slower on the second for every Criterion benchmark (see section 3). So a PR is compared with its base commit on the same runner, in the same job:

  1. The Benchmarks job checks out the PR’s base commit in a git worktree and runs its benchmarks with scripts/run-benchmarks.sh (sharing the target directory, so only what differs is rebuilt), then runs the PR’s benchmarks the same way. Benchmarks the base doesn’t have are reported as new.
  2. Criterion runs with --warm-up-time 1 --measurement-time 4 (8 s for the replay benchmarks), then the deploy saga harness (15 deployments per scenario).
  3. scripts/bench_report.py compares the medians. A benchmark more than 30% slower than on the base commit is flagged REGRESSION in the job summary and as a warning annotation on the run. The job still passes. If the PR changes benchmarks/ itself, the summary says so, since changed benchmarks aren’t like for like.
  4. The summary, bench-results.json, bench-report.md and the raw results of both runs (bench-runs/base, bench-runs/head) are uploaded as the bench-results-<run id> artifact (kept 30 days).

The whole job takes about 10–15 minutes with a warm cache.

Pushes to main run the benchmarks once and save bench-results.json in the Actions cache (bench-baseline-main-*). Pushes and manual runs compare with the latest saved main results, but because that is another runner the comparison is informational: only differences beyond 2x are marked, and never as warnings. The saved results are the record of how the numbers move over time.

To compare with a particular earlier run (still across runners), start the workflow by hand with that run’s id: gh workflow run perf.yml --ref my-branch -f benchmarks=true -f soak_minutes=0 -f baseline_run_id=<run id>.

Within one runner, run-to-run noise is much smaller, but the deploy saga and proxy numbers still move by 10–20% and a noisy neighbour can hit one half of the A/B and not the other. A real regression shows up again on the next push; a single flag often doesn’t.

Making it blocking. Set the repository variable BENCH_FAIL_ON_REGRESSION to true (Settings → Secrets and variables → Actions → Variables) and the job fails when a PR flags a regression (only same-runner comparisons can fail it); then make the Benchmarks check required in the branch protection rules. Change the threshold with BENCH_REGRESSION_THRESHOLD (e.g. 0.5 for 50%). A dedicated (self-hosted) runner would make the numbers much steadier before doing either.

If the cache entry has expired (GitHub evicts entries unused for 7 days), pushes to main show absolute numbers only until the next push saves one.


2. Soak test (scripts/soak.sh)

The soak test runs the real release build of aegis-daemon on Linux for a set time and checks that it stays correct and doesn’t leak:

  1. Starts the daemon with the web API and the built-in proxy on local ports.
  2. Registers a copy of examples/node-app (its response carries a version tag), maps the domain soak.test to it on the proxy (TLS off) and deploys it.
  3. Sends steady HTTP load through the proxy: by default 100 requests/s over 8 kept-alive connections, from scripts/soak_load.py (Python standard library, nothing installed). A request fails on a connection error, a 5 s timeout or any status but 200.
  4. Every 20 s runs the next operation of a cycle over the HTTP API: deploy, resource-limit change, deploy, rollback, app restart, deploy, limit change. Limit changes alternate between two CPU/memory/pid limits and need a cgroup backend. Run as root on cgroup v2, the script creates /sys/fs/cgroup/aegis-soak-<pid> with the cpu, memory and pids controllers and points resources.cgroup_root at it (on GitHub’s runners the daemon’s own service cgroup has no delegated controllers); set SOAK_CGROUP_ROOT to use another directory. Without a backend, limit changes are recorded as skipped.
  5. Restarts the daemon once at 75% of short runs, every 20 minutes in long ones.
  6. Every 5 s samples the daemon’s RSS, open fds, threads and zombie children, the database and WAL size, the app log directory, the whole data directory and the daemon log, plus the live app’s pid, RSS and restart count.

At the end scripts/soak_report.py writes report.md and summary.json.

When it fails

Check Default threshold Variable
Failed requests during deploys, rollbacks, limit changes and steady state more than max(5, 0.05% of those requests) SOAK_MAX_FAILED_REQUESTS, SOAK_MAX_FAILED_RATIO
Any operation fails (deploy not Success, rollback or restart error, app not serving again within 60 s of an app or daemon restart) any —
The daemon exits on its own, or isn’t running at the end any —
App crashes (ProcessCrashed events) more than 0 SOAK_MAX_APP_CRASHES
RSS leak: over one daemon lifetime of ≥ 2.5 min, after a 20% warm-up, the least-squares trend grows by more than 16 MiB and faster than 20 MiB/h and the last third’s median is above the first third’s — SOAK_RSS_MAX_GROWTH_MB, SOAK_RSS_MAX_SLOPE_MB_PER_H, SOAK_MIN_SEGMENT_SECS
fd leak: the same trend for open fds grows by more than 20 — SOAK_FD_MAX_GROWTH
ERROR lines in the daemon log any SOAK_ALLOWED_ERRORS (a regex of lines to ignore)

Failed requests during an app restart or a daemon restart (plus 2 s, SOAK_RECOVERY_GRACE_MS) are counted and reported but don’t fail the run: neither is zero-downtime today. A restart stops the process before starting it again, and the proxy runs inside the daemon, so a daemon restart takes the app’s traffic down until the daemon is back and has restarted the app.

A 5-minute run can only catch fast leaks; the nightly 60-minute run has three 20-minute daemon lifetimes to judge.

Running it

cargo build --release -p aegis-daemon
DURATION_MIN=5 OUT_DIR=soak-report scripts/soak.sh            # as yourself: no limits
sudo -E env "PATH=$PATH" DURATION_MIN=60 scripts/soak.sh      # with cgroup limits

It needs Linux, curl, python3 and node, and free local ports 18080, 18443, 18520 and 50251 (PROXY_HTTP_PORT, PROXY_HTTPS_PORT, WEB_PORT, GRPC_PORT). Other knobs: LOAD_RATE, LOAD_WORKERS, OP_INTERVAL_SECS, SAMPLE_SECS, DAEMON_RESTART_EVERY_SECS.

In CI

Trigger Duration
Push to main 5 min
PR labelled soak (and later pushes to it) 5 min
Nightly (schedule, 03:23 UTC) 60 min
workflow_dispatch soak_minutes input (default 60, at most 300)

For example gh workflow run perf.yml --ref main -f soak_minutes=180. Runs of the same kind on the same branch don’t pile up: a newer PR push cancels the older run.

Reading the report

The job summary shows report.md; the soak-report-<minutes>min-<run id> artifact has it with the raw data:

In report.md:


3. Measured numbers

A snapshot from CI on GitHub-hosted ubuntu-latest (4 vCPUs) on 2026-10-16, while this was set up. They are one run each on a shared VM, not targets or guarantees; the linked runs have the full reports.

Benchmarks (run 38945922650, the same commit measured twice on one runner; the second column is the change between the two, i.e. the noise):

Benchmark Median Same code, 2nd run
event_bus/publish 1.07 µs -0.6%
projection/apply_event 783 ns -0.6%
event_store/append (fsync per event) 1.51 ms (~660 events/s) -4.2%
event_store/replay_12020 40.8 ms (~295k events/s) -2.1%
projection/rebuild_12020 8.9 ms (~1.35M events/s) -1.2%
projection/load_and_rebuild_12020 (daemon start-up work) 52.4 ms -1.1%
proxy/direct/sequential 65 µs -1.2%
proxy/ingress/sequential 96 µs -6.3%
proxy/direct/concurrent_64 703 µs (~91k req/s) -2.4%
proxy/ingress/concurrent_64 1.44 ms (~44k req/s) -1.7%
deploy_saga/direct_port (median of 15) 104 ms -1.7%
deploy_saga/behind_proxy (median of 15) 105 ms +0.9%
deploy_saga/rollback_behind_proxy (median of 15) 75.5 ms -1.0%

So the proxy added about 30–40 µs to a small keep-alive request and halved the throughput of 8 busy connections in this setup (client, proxy and app share 4 vCPUs). On a different runner the same commit measured 17–83% slower across the board (run 38941452417 vs run 38942694776), which is why PRs are compared on one runner.

Soak, 5 minutes (run 38941452761, passed): 30,810 requests through the proxy at 100/s, p50 0.41 ms, worst 1-second p99 35 ms. 7 deploys, 2 rollbacks, 2 app restarts, 4 limit changes (cgroup v2) and 1 daemon restart: no failed request outside restarts; 6 failed requests (HTTP 502) during the two app restarts and 8 (connection closed) during the daemon restart. Deploys took 694 ms (median, the daemon’s 500 ms health polls included), rollbacks 542 ms, an app restart 132 ms, a daemon start 116 ms until /healthz answers. Daemon RSS about 38–40 MiB.

Soak, 15 minutes (run 38942415671, failed): 90,803 requests, none failed outside the 6 app restarts (15 HTTP 502s during them); 21 deploys, 6 rollbacks, 13 limit changes. RSS grew 38 → 41 MiB (about 10 MiB/h, under the threshold). It failed on open fds: 21 → 56. The fd snapshots show why: the daemon keeps the log file of every app process it has started open after the process ends (runtime/process keeps each process’s LogFile for the daemon’s lifetime), one more fd per deploy, rollback or restart. The 5-minute soak is too short to cross the threshold; the nightly 60-minute soak will fail on it until that is fixed.


What is not measured