~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Benchmarks run every server in Docker; perf held to its baseline

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:bench-docker-routes-baseline

Brings the benchmarks up to zds's rule of comparing only the same work. Every server now runs in Docker the same way, the routes and loads cover what clients actually do, and the nightly perf step now catches the server getting slower than it was, not only slower than the reference.

Claude Opus 5.5 · high

What changes

The PDS benchmark (harness/bench.mjs, bench/README.md, bench/RESULTS.md).

  • Every implementation runs in Docker the same way, so all four get the same port forwarding, volume, sync and path to the PLC directory:
    • spec-pds from the repository's own Dockerfile;
    • the reference from bench/docker/reference.Dockerfile (started by harness/bench-reference.mjs).
  • Images built from this repository carry the last commit of what they are built from (inputs in impls.json). A run refuses a stale one.
  • Requests are sent from worker threads (harness/lib/loadpool.mjs). The client's ceiling is measured first, against a responder in Docker that answers every request with the same 2 bytes and does nothing else. Rates at half that or more are marked ‡.
  • New sections:
    • 13 more routes a client calls most;
    • getRecord and createRecord at 1 to 256 callers, with answers that are not 2xx counted rather than stopping the run;
    • a mix of reads and writes, each route's p95 in the mix beside its p95 alone;
    • subscribers coming and going: threads, RSS and refusals.
  • Each part reports the tail its sample size can carry: p99 at 1000 or more, else p95, p90 or max.
  • A server that closes every connection (zds) has the client wait for local ports. Rates held back by that wait are marked ◊.
  • The run refuses a busy machine unless given --busy, and records the load.
  • main's storage rounds are kept and run in Docker too. RustFS's BusyBox find has no -printf, so vlpds's bucket had measured 0; sizes now come from find and stat.
  • The bench runs by hand: a runner job has no Docker. A probe found no socket and no permission to start a daemon.

The performance step (spec/OPERATIONS.md "Performance", harness/perf.mjs, harness/perf-baseline.json, .knotless/workflows/perf.yml).

  • Each part's ratios are the server's best over the reference's in the same run. They are held to a baseline: p99 ratio ≤ 1.5 × min(baseline, 1), throughput ratio ≥ 0.8 × max(baseline, 1). The old rule still holds; the baseline only tightens it.
  • The baseline is the weakest of 6 runs of the new perf workflow on the runner at 989ff06.
  • Then 20 cohorts of 20 subscribers come and go. Afterwards the server must hold no more descriptors or threads than after the first cohort, and at most 8 MiB more memory.
  • gates.mjs prints perf's whole output, the ratios on one line.

The store benchmark (bench/store). A new part reads a record a stage at a time: path → CID, then the block, then decode, then the JSON body, then _health and getRecord over HTTP. When getRecord gets slower, this names the stage.

Why

Compared with zds's docs/benchmarking.md, our benchmarking had these problems:

  • Two servers ran natively and two in Docker's VM.
  • A single-thread client probably capped the fastest reads.
  • The last results were taken under load.
  • Some p99s were really the slowest request.
  • There was no concurrency curve, route matrix or mixed load, and no stage-by-stage read.
  • Nothing checked that subscribers' resources come back.
  • The perf gate could not see a regression while the server stayed faster than the reference. On the runner getRepo is 7–14× the reference and createRecord 52–79×, so even a 5× slowdown passed.

How it was checked

  • perf.mjs:
    • A planted 8 ms sleep in getRecord fails the baseline rule (throughput ratio 1.89 against a floor of 0.8 × 5.85). The old rule passed it.
    • A planted leak of one fd and 256 KiB per subscriber fails the churn check: descriptors 136 → 536, memory 49.6 → 156.9 MiB.
    • Six clean runs on the runner each passed the churn check.
  • bench.mjs: a full 3-round run, now in bench/RESULTS.md. Every server served every part, route and section, except zds's firehose under load, as before.
  • Store ladder: run locally, and by store-bench on the runner.
  • gates, docs, citations and store-bench-small pass.

Shortcomings

  • The machine's load rose during the run: vlpds's and zds's rounds saw load averages of 7–89, against 5–22 for spec-pds and the reference. RESULTS.md says so.
  • On macOS, all syncs land on Docker's virtual disk, which is likely cheaper than a full flush. Write numbers are comparable across servers but higher than native F_FULLFSYNC.
  • The runner's perf ratios swing up to 2× from run to run (getRepo 6.7–14.1), so the gate catches about a 2.5× slowdown there, not a small one.

Review

Start with spec/OPERATIONS.md "Performance" and harness/perf.mjs, then harness/bench.mjs (ROUTES, CURVES, MIX, churn, the storage round).

Approved

This pull moves the benchmarks to Docker for every server and adds routes, concurrency curves, a mixed load and subscriber churn. It also adds a perf baseline and a subscriber-churn check. I read harness/perf.mjs, spec/OPERATIONS.md "Performance", perf-baseline.json, the perf and gates workflows, gates.mjs and bench/store/Cargo.toml. They are consistent with each other. The spec text matches the code on the ratio rule, the baseline floors (p99 ≤ 1.5 × min(base, 1), rate ≥ 0.8 × max(base, 1)), the cohort sizes, the idle and settle times, and the 8 MiB slack. The baseline names six runs against the spec's minimum of five. The rule only tightens the old one, and the sections read as stricter, not looser. The only new dependency is pds-repo, a workspace crate used by the bench, not an atproto or MCP crate.

I did not read these files. The diff is about 10k lines, and most of that is generated output, a vendored lockfile or a very large harness:

  • harness/bench.mjs
  • harness/lib/loadpool.mjs
  • harness/bench-reference.mjs
  • bench/store/ladder.mjs
  • bench/store/src/*
  • the Dockerfiles
  • bench/results.json, bench/RESULTS.md and Cargo.lock

The spec says nothing about the bench itself. That is consistent with it being a hand-run tool documented in bench/README.md and docs/guide/.

One thing to check: the nightly perf step now includes a 15 s idle wait, 21 cohorts and up to 20 s of settling, on top of the parts, all under run(120, ...). The 120 is presumably a timeout in seconds, up from 80. The run's total time is worth confirming from the runner logs, since a timeout would fail the nightly.

On the 120: in gates.mjs a run's secs is its expected length, used to start the longest runs first (gates.mjs:123); it is no timeout, so a longer perf run cannot fail the nightly by it.

Merged as 42abe3c