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

A reproducible benchmark beside other PDSes: the reference, vlpds and zds

Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:bench
bench/impls.jsonnew+36−0
@@ -0,0 +1,36 @@
{
"implementations": {
"spec-pds": {
"source": "this repository, at the commit checked out",
"toolchain": "stable",
"build": ["rustup", "run", "stable", "cargo", "build", "--release", "-p", "pds"]
},
"reference": {
"source": "@atproto/pds 0.5.55 through @atproto/dev-env 0.6.26, from npm, pinned by harness/package-lock.json",
"build": ["npm", "ci", "--no-audit", "--no-fund"],
"cwd": "harness"
},
"vlpds": {
"source": "https://github.com/jazware/vlpds, its release image",
"release": "v1.3.0",
"commit": "91fa452993865b2f91ff5ed5b87fc28356796d0c",
"image": "ghcr.io/jazware/vlpds@sha256:e1aca7934017bb757ef3717bbd964ae758cf704dc623703262c512fd462c0477",
"needs": ["rustfs"]
},
"zds": {
"source": "https://tangled.org/zat.dev/zds, built from source with its own Dockerfile, for this machine's architecture",
"repo": "https://tangled.org/zat.dev/zds",
"release": "v0.7.8",
"commit": "cef2c63d7d6d7dd87b90100566307e9aa8a4d170",
"dockerfile": "Dockerfile",
"tag": "spec-pds-bench-zds:cef2c63"
}
},
"images": {
"rustfs": {
"about": "RustFS, the S3 store vlpds's rounds use; passed vlpds-bucket-probe (bench/README.md)",
"release": "rustfs/rustfs:1.0.4",
"image": "rustfs/rustfs@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2"
}
}
}
bench/README.mdnew+164−0
@@ -0,0 +1,164 @@
# The PDS benchmark
`harness/bench.mjs` runs the same workload against several PDS implementations,
one at a time, on one machine, and writes the tables in
[`RESULTS.md`](RESULTS.md) (its raw numbers in `results.json`). Everything it
runs comes from this repository and the pins in [`impls.json`](impls.json):
nothing on the machine is set up by hand.
## What runs, pinned
| implementation | from | pinned by |
|---|---|---|
| spec-pds | this repository, `cargo build --release -p pds` | the commit checked out |
| reference | `@atproto/pds` 0.5.55 through `@atproto/dev-env` 0.6.26, from npm | `harness/package-lock.json` |
| vlpds | its release image `ghcr.io/jazware/vlpds`, v1.3.0 (commit `91fa452`) | image digest in `impls.json` |
| RustFS (vlpds's S3 store) | `rustfs/rustfs` 1.0.4 | image digest in `impls.json` |
| zds | `tangled.org/zat.dev/zds` v0.7.8, built by `--setup` with its own `Dockerfile` for this machine's architecture, tagged `spec-pds-bench-zds:cef2c63` | repository URL and commit `cef2c63` in `impls.json` |
zds's published image (`atcr.io/zat.dev/zds:latest`) is amd64 only and
predates v0.7.8, so the bench builds its own from the pinned commit. The
Dockerfile fetches Zig 0.17.0 (checked against its SHA-256) and zds's Zig
dependencies (pinned by hash in its `build.zig.zon`) while it builds.
vlpds keeps all its data in an S3 bucket and needs strongly consistent
conditional writes (`If-None-Match: *`, `If-Match`) from it. The store is
**RustFS**, chosen by running vlpds's own `vlpds-bucket-probe` (in the vlpds
image) against it on a Docker network: all six correctness checks
(`conditional_create`, `compare_and_swap`, `race_create`, `race_cas`,
`list_read_delete`, `multipart`) passed, verdict `SAFE for vlpds`. RustFS was
the first candidate tried, ahead of Garage and SeaweedFS, so those were not
probed. MinIO, the store vlpds's docs name for tests, publishes no images any
more. To probe it again:
```sh
docker network create probe
docker run -d --name probe-s3 --network probe --network-alias s3 -e RUSTFS_ACCESS_KEY=probeaccess1 -e RUSTFS_SECRET_KEY=probesecret1234567890 <rustfs image from impls.json>
# make the bucket `vlpds` (any S3 client), then:
docker run --rm --network probe -e VLPDS_S3_ENDPOINT=http://s3:9000 -e VLPDS_S3_BUCKET=vlpds -e VLPDS_S3_REGION=us-east-1 \
-e VLPDS_S3_ACCESS_KEY=probeaccess1 -e VLPDS_S3_SECRET_KEY=probesecret1234567890 \
--entrypoint vlpds-bucket-probe <vlpds image from impls.json>
```
## Prerequisites
| what | version used for `RESULTS.md` | why |
|---|---|---|
| macOS or Linux, 8+ cores, 16+ GiB | macOS 26.5.2, Apple M1 Pro, 32 GiB | |
| Node | 24 (24.22.1) | the bench client, the reference PDS, the PLC directory |
| npm | 11 (11.19.1) | installs the reference from `harness/package-lock.json` |
| rustup | 1.28+ (1.29.1) | builds spec-pds on `stable` (setup installs the toolchain) |
| Docker | 28 (Docker Desktop 28.0.1; its Linux VM 8 CPUs, 7.7 GiB) | runs vlpds, RustFS and zds, and builds zds's image; `host.docker.internal` must reach the host |
| git | any recent (2.50.1) | fetches zds at its pinned commit |
| sccache | optional (0.19.0) | `export RUSTC_WRAPPER=sccache` before setup makes rebuilds faster |
Setup needs the network (crates.io, npm, Docker Hub, ghcr.io, tangled.org,
ziglang.org); the bench itself talks only to loopback and Docker's local
network.
## Commands
From a clone of this repository:
```sh
cd harness
node bench.mjs --setup # build and pull everything pinned
node bench.mjs --rounds 3 --json ../bench/results.json # run; Markdown tables on stdout
```
or both at once, from the repository's root: `just bench`. Then copy the
tables into `RESULTS.md`. `node bench.mjs --report ../bench/results.json`
prints them again from a saved run. In every table the reference comes
first, the baseline the others are read against.
`--setup`:
1. checks Node 24+, rustup, npm, git and a running Docker daemon, and stops
with a message naming whatever is missing;
2. builds **spec-pds** (`rustup run stable cargo build --release -p pds`);
3. installs the **reference** (`npm ci` in `harness/`);
4. unless Docker has the image `spec-pds-bench-zds:cef2c63` already, fetches
**zds** at its pinned commit into `bench/vendor/zds` (gitignored) and
builds that image with zds's own `Dockerfile` (`docker build`, a few
minutes the first time);
5. pulls the **vlpds** and **RustFS** images by digest, unless Docker has
them already.
It is idempotent: run again, it pulls and builds no image it has and cargo
has nothing to rebuild. A run refuses to start if an image it needs or
spec-pds's binary is missing. `--impls spec-pds,vlpds` runs only some;
`--rounds N` sets the rounds.
## What it measures
Each round is a fresh server on fresh data, registering accounts with a fresh
in-memory PLC directory (`@did-plc/server`) run by the bench. For vlpds, a
round also makes a fresh Docker network, RustFS container and volume, and
vlpds container (its cache on a volume of its own); for zds, a fresh container
with its database and blobs on a fresh volume. They are made before the
start clock and removed after the round. The server is warmed first, each
part at a tenth of its size on accounts of its own; then the parts run in
order:
| part | requests per round | at once | what |
|---|--:|--:|---|
| createAccount | 40 | 4 | no invite codes; includes the PLC registration |
| createRecord | 1000 | 16 | ~100-byte records over the 40 accounts |
| applyWrites | 200 | 8 | 10 creates per call |
| getRecord | 2000 | 16 | records written by createRecord |
| listRecords | 1000 | 16 | `limit=50` |
| getRepo | 100 | 8 | ~75 records per repo |
| uploadBlob | 100 | 8 | 64 KiB, `application/octet-stream` |
| firehose | 100 writes | 20 subscribers | `putRecord`s one after another; latency is write sent → commit received |
Per part: throughput (requests answered per second; for the firehose,
commits delivered to subscribers per second), p50 and p99 of request times,
as the best and the median of the rounds. Per server: start time (spawning
the server, or `docker start` of its container, to the first answered
`describeServer`), its RSS 2 s after start (idle) and the most sampled
through the round (peak): `ps` for a native process, `docker top` inside the
container for vlpds and zds (the `vlpds` process, not its `tini`; the `zds` process).
vlpds's store's RSS is sampled the same way and reported in a table of its
own.
## Fairness rules
- One server at a time; nothing of one is running while another is measured.
- Each on its own defaults for a single-node local setup, changing only what
a local benchmark needs: rate limits off, no invite codes, the bench's PLC
directory, a loopback URL, and nothing sent off the machine. vlpds runs as
its docs' single-node `tiny` profile; zds as its deployment docs run it
(database and blobs under `/data`), with no general rate limits to turn
off, so its one limit the workload hits, 4 full `getRepo` exports at once,
is raised to the 8 the workload runs. Each adapter's `info()` records its
exact configuration and durability, kept in `results.json`, and
`RESULTS.md` lists them.
- The same workload, warm-up and number of rounds (three) for every server.
- A part a server cannot serve is not dropped: its table says why.
## Adding an implementation
1. **Pin it** in `impls.json` under `implementations`: either a `build`
command run in this repository (with `toolchain` for Rust); or an `image`
by digest (`name@sha256:…`) with its `release` and `commit`; or a `repo`
and `commit` with the `dockerfile` in it to build and the image `tag` to
give it (setup clones it into `bench/vendor/<name>`); and `needs`, the
images it uses beside it, each under `images` by digest.
2. **Write its adapter** in `ADAPTERS` in `harness/bench.mjs`:
`start({ port, plcUrl, dataDir, log, aux })` answering `{ url, stop }`
plus `pid` (native) or `rssKiB()` (in a container); `info()` (version,
commit, source, storage, durability, configuration); optionally
`setup({ port, plcUrl, dataDir, log })` for what it needs before it starts
(answering `{ name, teardown }`, and `rssKiB` when what it started has
memory of its own to report), `accountBody(i, tag)` (handles under its
domain, invite codes), and `unsupported`, each part it cannot serve with
why.
3. Run `node bench.mjs --setup`, then `node bench.mjs --impls <name> --rounds 1`
to try it, then the full run.
## Results depend on the machine
Absolute numbers depend on the CPU, the disk and its sync behaviour, the OS,
Docker's VM and whatever else runs. `RESULTS.md` records the machine, the
load on it, every pinned version, commit and digest it ran, and the caveats;
compare runs only on the same machine.
bench/results.jsonnew+824−0
824 lines changed: not loaded until asked for.
bench/RESULTS.mdnew+339−0
@@ -0,0 +1,339 @@
# Benchmark: the reference PDS, spec-pds, vlpds and zds
`harness/bench.mjs`, run with `node bench.mjs --setup && node bench.mjs --rounds 3 --json ../bench/results.json`
from a clean state (see [README.md](README.md)): three rounds per
implementation, one implementation at a time, each round a fresh server on
fresh data, registering with a fresh in-memory PLC directory
(`@did-plc/server`) run by the bench. Every round warms the server the same
way first (each part at a tenth of its size, on accounts of its own), then
runs the parts in order. The raw numbers of every round, and every server's
recorded configuration, are in `bench/results.json`.
The workload is `harness/perf.mjs`'s, plus `applyWrites` and `listRecords`:
| part | requests per round | at once | what |
|---|--:|--:|---|
| createAccount | 40 | 4 | no invite codes (`.test` handles, zds's default domain too; vlpds: under its handle domain `vlpds.test`) |
| createRecord | 1000 | 16 | ~100-byte records over the 40 accounts |
| applyWrites | 200 | 8 | 10 creates per call |
| getRecord | 2000 | 16 | records written by createRecord |
| listRecords | 1000 | 16 | `limit=50` |
| getRepo | 100 | 8 | each repo holds ~25 records from createRecord plus ~50 from applyWrites |
| uploadBlob | 100 | 8 | 64 KiB, `application/octet-stream` |
| firehose | 100 writes | 20 subscribers | `putRecord`s one after another; latency is write sent → commit received by a subscriber |
Throughput is requests answered per second over the part (for the firehose,
commits delivered to all subscribers per second, bounded by the sequential
writes). p50/p99 are of the round's request times. "Best" is each column's
best round (most per second, least ms); "median" is the median round.
## Machine and versions
- Apple M1 Pro, 8 cores, 32 GiB, macOS 26.5.2 (arm64), APFS on the internal
SSD. Docker Desktop 28.0.1, its Linux VM given 8 CPUs and 7.7 GiB.
- Node v24.22.1 (bench client and the reference); rustc 1.99.1 (spec-pds).
- Pins, as `bench/impls.json` has them and `results.json` records:
- **spec-pds**: this repository at `01e1909` (branch `bench`; the server
as at that commit, the bench's own changes for zds on top),
`cargo build --release -p pds`; workspace version 0.0.0.
- **reference**: `@atproto/pds` 0.5.55 from npm, started through
`@atproto/dev-env` 0.6.26's `TestPds` as `perf.mjs` does, pinned by
`harness/package-lock.json`.
- **vlpds**: release v1.3.0 of `jazware/vlpds`, commit
`91fa452993865b2f91ff5ed5b87fc28356796d0c`, its release image
`ghcr.io/jazware/vlpds@sha256:e1aca7934017bb757ef3717bbd964ae758cf704dc623703262c512fd462c0477`
(linux/arm64 here).
- **RustFS** 1.0.4, vlpds's S3 store:
`rustfs/rustfs@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2`.
It passed `vlpds-bucket-probe` (from the vlpds image): all six
correctness checks, `SAFE for vlpds`; its segment-shaped PUT
(`put_create_64kib`) measured 7.3 ms p50 / 11.2 ms p99 from inside Docker.
- **zds**: release v0.7.8 of `tangled.org/zat.dev/zds`, commit
`cef2c63d7d6d7dd87b90100566307e9aa8a4d170`, built by `--setup` with its
own `Dockerfile` (Zig 0.17.0, `-Doptimize=ReleaseSafe`, target
`aarch64-linux-gnu`) into `spec-pds-bench-zds:cef2c63`, image
`sha256:124944cbbdf8e0b5877885ec14dfe421ec8b42f7508761a6281e090b882dcd31`,
linux/arm64. Its published image (`atcr.io/zat.dev/zds:latest`) is amd64
only and predates v0.7.8, so it was not used.
### How vlpds was configured
As its docs run a single node: the release image's `tiny` profile
(`deploy/ansible/roles/vlpds/defaults/main.yml` at v1.3.0, the profile
`docs/operations/deploy.md` describes for one node): a 2560 MiB container
memory limit (`--memory 2560m --memory-swap 2560m`, which sizes its caches),
`--stop-timeout 90`, `VLPDS_NODE_ID=single`, `VLPDS_SHARDS=1`,
`VLPDS_LEASE_TTL_MS=60000`, `VLPDS_SLATEDB_MANIFEST_POLL=60s`, a 4096 MiB SST
disk cache on a Docker volume, and tiny's firehose, backfill and export sizes
(`--firehose-ring-mb 64`, live ring 32, merge queue 32, max lag 64, backfill
cache 32 / read-ahead 16, 4 backfills, 4 exports, MST node cache 64, 1
firehose thread). Threads are its defaults (I/O = the 8 cores the VM shows,
workers = 4). `VLPDS_PLC_MODE=directory` with a fresh secp256k1 rotation key,
and fresh random JWT secret, admin and internal tokens and KEK each round
(not `--dev-mode`). The bench's own changes, as for the other two: rate limits
off (`VLPDS_NO_RATE_LIMITS`), invites not required (its default), the bench's
PLC directory (`http://host.docker.internal:<port>`), a loopback URL
(`VLPDS_PUBLIC_URL=http://127.0.0.1:<port>`), and nothing sent off the
machine (`--crawlers=` for no relays, `--asn-lookup off`). Each round runs on
a Docker network of its own with a fresh RustFS container and volume, and the
bucket made through the S3 API; vlpds's container and RustFS's are made before
the start clock and removed, with their volumes and network, after the round.
### How zds was configured
As its deployment runs it (`docs/deployment.md`, `fly.toml`), on its
Dockerfile's `ENV` (`ZDS_HOST=0.0.0.0`, `ZDS_PORT=2583`,
`ZDS_DB=/data/zds.sqlite3`) with `ZDS_BLOBSTORE_PATH=/data/blobs`, `/data` a
fresh Docker volume each round; a fresh secp256k1 `ZDS_PLC_ROTATION_KEY`,
`ZDS_JWT_SECRET` and `ZDS_ADMIN_TOKEN` each round; no memory limit (its
deployment's 1 GiB is the Fly VM's, not a zds setting). zds has no dev mode.
Its defaults kept: handle domains `.test`, invites not required, permissioned
data off, mail provider `comail` (createAccount sends no mail, and with no
Comail key nothing is sent). The bench's own changes: its PLC directory
(`ZDS_PLC_DIRECTORY=http://host.docker.internal:<port>`), a loopback URL
(`ZDS_PUBLIC_URL=http://127.0.0.1:<port>`, from which it derives
`did:web:127.0.0.1%3A<port>`), no relays asked to crawl (`ZDS_CRAWLERS=`, in
place of bsky.network and vsky.network), and
`ZDS_MAX_CONCURRENT_REPO_EXPORTS=8`. zds has no general rate limits to turn
off; its cap on full `getRepo` exports at once (4 by default, a 429 past it)
is the one limit the workload hits, and it is raised to the 8 the workload
runs at once. Its container is made before the start clock and removed, with
its volume, after the round; zds is its container's PID 1 with no `SIGTERM`
handler, so the bench kills it rather than wait out `docker stop`.
## Results
### Summary
Each part's requests per second (the firehose: commits delivered per second), start time and memory; each the best round. Detail follows.
| | reference | spec-pds | vlpds | zds |
|---|--:|--:|--:|--:|
| createAccount per s | 70 | 55 | 48 | 7 |
| createRecord per s | 309 | 378 | 718 | 539 |
| applyWrites per s | 159 | 294 | 409 | 390 |
| getRecord per s | 1085 | 16465 | 4991 | 3149 |
| listRecords per s | 720 | 7715 | 4175 | 2115 |
| getRepo per s | 512 | 4276 | 1926 | 815 |
| uploadBlob per s | 395 | 419 | 167 | 356 |
| firehose per s | 4324 | 3570 | 2448 | 1087 |
| start ms | 2386 | 37 | 1184 | 228 |
| idle RSS MiB (median) | 398.9 | 13.6 | 165.4 | 16.7 |
| peak RSS MiB | 608.4 | 73.7 | 384.7 | 49.2 |
### createAccount
40 requests, 4 at once.
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) |
|---|--:|--:|--:|--:|--:|--:|
| reference | 70 | 70 | 51.9 | 52.2 | 73.8 | 74.5 |
| spec-pds | 55 | 53 | 66.7 | 68.6 | 95.9 | 104.5 |
| vlpds | 48 | 42 | 79.5 | 91.3 | 116.5 | 135.3 |
| zds | 7 | 7 | 467.8 | 486.9 | 1186.3 | 1375.5 |
### createRecord
1000 requests, 16 at once.
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) |
|---|--:|--:|--:|--:|--:|--:|
| reference | 309 | 306 | 51.5 | 51.9 | 60.7 | 62.4 |
| spec-pds | 378 | 369 | 42.1 | 42.7 | 69.7 | 72.9 |
| vlpds | 718 | 681 | 16.7 | 17.6 | 56.2 | 59.7 |
| zds | 539 | 535 | 22.1 | 23.6 | 98.4 | 101.7 |
### applyWrites
200 requests, 8 at once.
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) |
|---|--:|--:|--:|--:|--:|--:|
| reference | 159 | 157 | 49.8 | 50.9 | 56.0 | 59.9 |
| spec-pds | 294 | 281 | 26.2 | 27.9 | 42.3 | 47.1 |
| vlpds | 409 | 361 | 15.7 | 17.3 | 45.3 | 48.9 |
| zds | 390 | 389 | 16.6 | 17.9 | 49.5 | 51.7 |
### getRecord
2000 requests, 16 at once.
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) |
|---|--:|--:|--:|--:|--:|--:|
| reference | 1085 | 1081 | 14.4 | 14.6 | 18.3 | 22.5 |
| spec-pds | 16465 | 15315 | 0.8 | 0.9 | 4.9 | 5.4 |
| vlpds | 4991 | 4802 | 2.2 | 2.2 | 22.5 | 24.4 |
| zds | 3149 | 3052 | 3.7 | 3.8 | 23.7 | 28.7 |
### listRecords
1000 requests, 16 at once.
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) |
|---|--:|--:|--:|--:|--:|--:|
| reference | 720 | 712 | 21.2 | 22.1 | 29.4 | 32.9 |
| spec-pds | 7715 | 7362 | 1.6 | 1.7 | 10.3 | 10.3 |
| vlpds | 4175 | 2759 | 3.6 | 4.4 | 9.7 | 25.3 |
| zds | 2115 | 2111 | 5.7 | 5.8 | 28.1 | 28.3 |
### getRepo
100 requests, 8 at once.
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) |
|---|--:|--:|--:|--:|--:|--:|
| reference | 512 | 498 | 15.3 | 15.5 | 18.3 | 19.0 |
| spec-pds | 4276 | 4072 | 1.8 | 1.9 | 2.5 | 2.7 |
| vlpds | 1926 | 1750 | 3.7 | 4.1 | 6.6 | 10.4 |
| zds | 815 | 745 | 7.8 | 8.4 | 27.9 | 28.7 |
### uploadBlob
100 requests, 8 at once.
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) |
|---|--:|--:|--:|--:|--:|--:|
| reference | 395 | 378 | 17.0 | 17.3 | 26.1 | 31.3 |
| spec-pds | 419 | 383 | 14.8 | 16.1 | 38.1 | 40.1 |
| vlpds | 167 | 142 | 38.4 | 50.5 | 82.9 | 86.2 |
| zds | 356 | 326 | 15.4 | 17.8 | 44.1 | 52.4 |
### firehose
100 putRecords one after another, 20 subscribers; times from sending a write to a subscriber having its commit, throughput in commits delivered per second.
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) |
|---|--:|--:|--:|--:|--:|--:|
| reference | 4324 | 4179 | 131.7 | 140.6 | 316.3 | 326.4 |
| spec-pds | 3570 | 3226 | 5.8 | 6.2 | 8.6 | 11.9 |
| vlpds | 2448 | 1643 | 9.5 | 11.9 | 34.0 | 36.9 |
| zds | 1087 | 944 | 27.0 | 30.9 | 75.3 | 89.7 |
### Start time and memory
Start: from spawning the server to its first answered `describeServer`, on an empty data directory. Idle RSS: 2 s after start, before any request. Peak RSS: the most sampled (every ~100 ms) through the warm-up and the workload.
| impl | start ms (best) | start ms (median) | idle RSS MiB (median) | peak RSS MiB (best) | peak RSS MiB (median) |
|---|--:|--:|--:|--:|--:|
| reference | 2386 | 2432 | 398.9 | 608.4 | 644.5 |
| spec-pds | 37 | 39 | 13.6 | 73.7 | 79.0 |
| vlpds | 1184 | 1235 | 165.4 | 384.7 | 392.9 |
| zds | 228 | 302 | 16.7 | 49.2 | 49.9 |
Not in the table above: what a server needs running beside it, its RSS sampled apart (the sum over its container's processes, from `docker top`, as fast as that answers).
| impl | beside it | idle MiB (median) | peak MiB (best) | peak MiB (median) |
|---|---|--:|--:|--:|
| vlpds | RustFS | 176.6 | 248.9 | 250.0 |
vlpds's and zds's RSS are those of their `vlpds` and `zds` processes inside
their containers, from `docker top` (ps in Docker's VM); RustFS's is counted
apart, in the table just above, and not in vlpds's figures. zds needs nothing
beside it.
## Not run
The other implementations first in scope (Cocoon, millipds, rsky-pds,
pds.js) were dropped by the user's change of scope before any were cloned or
built. `bench.mjs` takes them as adapters, each pinned in
`bench/impls.json` (README.md, "Adding an implementation").
All four servers served every part.
## Caveats
- **vlpds and zds run in Docker's Linux VM; the reference and spec-pds
natively on macOS.** Every request to either crosses Docker Desktop's port
forwarding from the host into the VM, and both reach the PLC directory back
through `host.docker.internal` (vlpds its store over a Docker network too).
That adds latency the native servers don't pay, most visible on the small,
fast reads (getRecord p50 2.2 ms for vlpds and 3.7 ms for zds against
spec-pds's 0.8 ms) [INFERENCE: the forwarding cost was not measured
apart]. Their start times are from `docker start` of an already created
container to the first answered `describeServer`; vlpds's includes the
~1 s its log shows it waits to acquire its shard's lease, zds's (228–323 ms)
its SQLite migrations on an empty database.
- **Durability differs, and differently for each.**
- spec-pds syncs every answered write before answering (group-committed,
`spec/DURABILITY.md`) with Rust's `File::sync_all`/`sync_data`, which on
macOS is `fcntl(F_FULLFSYNC)`: a flush through the drive's cache.
- The reference keeps its data in SQLite in WAL mode with better-sqlite3's
default `synchronous=FULL` and `fullfsync=0`, so it calls plain
`fsync(2)` on each commit, which on macOS does **not** flush the drive's
cache, and writes blobs with `fs.writeFile` and never syncs them.
- vlpds answers a write once the log segment holding it (and every earlier
one) is PUT to the bucket, and uploadBlob once the blob is PUT there; its
local disk is only a cache. RustFS, in its default `strict` mode, fsyncs
object data, `xl.meta` and the commit renames' directories before
answering a PUT.
- zds keeps everything in one SQLite database (SQLite 3.53.0, bundled by
zqlite and compiled with no `SQLITE_DEFAULT_*` flags) on one connection:
`PRAGMA journal_mode=WAL` and nothing else, so `synchronous` stays at its
compiled-in default, `FULL`, and each commit fsyncs the WAL;
`fullfsync` is a macOS-only pragma and does not apply on Linux. Blobs
are written with `fopen`/`fwrite`/`fclose` to a temporary file and
renamed into place, never fsynced (`src/storage/blobstore.zig`), so an
uploadBlob answer does not mean the blob's bytes are on disk.
- vlpds's and zds's syncs are on the Docker VM's virtual disk, and whether
Docker Desktop passes those flushes through to the Mac's drive as
`F_FULLFSYNC` was not established [INFERENCE: likely weaker than
spec-pds's]. So none of the other three's write numbers are paid for
with spec-pds's guarantee.
- **vlpds's writes are batched across requests.** Every write on the node goes
into one log, group-committed into segments; with 16 or 8 requests in
flight one segment PUT (7–11 ms to RustFS here) answers many. That is likely
where its createRecord and applyWrites lead comes from (p50 16–18 ms
against spec-pds's 42 ms); spec-pds group-commits too, but pays a
`F_FULLFSYNC` per group [INFERENCE from the two designs; not profiled].
- **zds's createAccount is slow and serial** (7 per second, p50 468–588 ms
with 4 at once). One at a time, outside the bench, each took ~140–180 ms;
four at once queue behind each other, as if account creation (a
100,000-round PBKDF2-SHA256 password hash, the signing key, the PLC
genesis operation, the first commit) ran one at a time under its store
lock [INFERENCE from the timings and its source; not profiled]. Its
writes after that (createRecord p50 22 ms, applyWrites 17 ms) are close to
vlpds's.
- **zds's limit raised.** Its default cap of 4 full `getRepo` exports at once
answers the workload's 8 at once with 429 `RateLimitExceeded`; it was
raised to 8 (`ZDS_MAX_CONCURRENT_REPO_EXPORTS`), as rate limits are off for
the others. Its other caps (32 subscribeRepos connections, 4 cursor
backfills) are above what the workload uses.
- **vlpds's uploadBlob varied** (167 and 142 per second best and median):
each 64 KiB blob is one PUT to RustFS, and its p99 (83–86 ms) is the
store's, under the load below.
- **Storage engines.** spec-pds: its own append-only logs and files in
`PDS_DATA_DIR` (`spec/STORE.md`), blobs as files. The reference: SQLite
(better-sqlite3), one service DB, a sequencer DB, a DID-cache DB and one DB
per account; blobs on local disk. vlpds: everything in the bucket — log
segments, SlateDB state for its one shard, blobs — on RustFS with one drive
on a Docker volume. zds: one SQLite database for every account (record
bodies as DAG-CBOR blocks), blobs as files, both on a Docker volume.
- **Settings.** All four with rate limits off (zds: none to turn off, its
export cap raised) and invite codes not required. The reference runs in
dev-env's `devMode`, as `perf.mjs` runs it. spec-pds with
`PDS_DID_CACHE_SECS=0` as `perf.mjs` (`lib/env.mjs`) gives it. vlpds not in
`--dev-mode`, with real secrets; zds has no dev mode.
- **Memory is not like-for-like.** spec-pds's and the reference's RSS are
from `ps` on macOS; vlpds's and zds's from `ps` inside Docker's Linux VM,
vlpds's under a 2560 MiB container limit its caches size themselves from,
zds's with no limit. RustFS's 177–250 MiB is on top of vlpds's. The PLC
directory runs in the bench's process and is counted for none. The
reference's RSS includes the Node runtime and dev-env's module graph; its
start time is a cold Node start importing `@atproto/dev-env`.
- **createAccount** includes the PLC operation to the local directory for all
four; vlpds's and zds's go from the VM back to the host.
- **zds's image came from the build cache.** `--setup` fetched zds at its pin
into a fresh `bench/vendor/zds` and ran `docker build`, but BuildKit's layer
cache still held an exploratory build of the same commit (the shared
builder cache was not pruned, as other work on this machine uses it), so
the build took ~25 s and produced the same image
(`sha256:124944cb…`); built without that cache it took ~4 minutes here.
- **The machine was not idle.** Other agents' work was running on it (load
average ~16 at the start of the run, ~12 at its end, on 8 cores); every
round ran under it, so absolute numbers are lower and noisier than on an
idle machine. Best-of-three is reported for that reason, as `perf.mjs`
does. The reference's firehose shows it: p50 131–141 ms in this run, against
5.8 ms in a round of the last one.
- One client process drives every server; at spec-pds's read rates
(getRecord ~15–16k/s) the Node client is likely part of the bottleneck
[INFERENCE].
harness/bench.mjsnew+755−0
755 lines changed: not loaded until asked for.
harness/package-lock.json+1−0
@@ -9,6 +9,7 @@
"@atproto/dev-env": "0.6.26",
"@atproto/identity": "0.5.23",
"@atproto/oauth-client-node": "0.5.16",
"@aws-sdk/client-s3": "3.1164.0",
"@modelcontextprotocol/conformance": "0.2.0-alpha.12",
"ajv": "8.20.0"
}
harness/package.json+1−0
@@ -7,6 +7,7 @@
"@atproto/dev-env": "0.6.26",
"@atproto/identity": "0.5.23",
"@atproto/oauth-client-node": "0.5.16",
"@aws-sdk/client-s3": "3.1164.0",
"@modelcontextprotocol/conformance": "0.2.0-alpha.12",
"ajv": "8.20.0"
}
.gitignore+1−0
@@ -2,3 +2,4 @@
/harness/node_modules
.DS_Store
/harness/spaces/node_modules
/bench/vendor
Justfile+4−0
@@ -33,3 +33,7 @@ perf: build
test:
{{cargo}} test --no-run
if [ -d /dev/shm ] && [ "$(df -Pk /dev/shm | awk 'NR==2 {print $4}')" -ge 49152 ]; then export TMPDIR=/dev/shm; fi; {{cargo}} test -- --nocapture
# The PDS benchmark (bench/README.md): build every implementation at its pin (bench/impls.json), then three rounds of each, one at a time.
bench:
cd harness && node bench.mjs --setup && node bench.mjs --rounds 3 --json ../bench/results.json
README.md+11−0
@@ -168,6 +168,17 @@ cd spaces && npm ci
node compare.mjs --seed 1 -- ../../target/release/pds serve
```
`harness/bench.mjs` benchmarks the server beside other PDSes on this
machine, one at a time: perf's workload with `applyWrites` and
`listRecords`, each part's throughput, p50 and p99, and each server's start
time and memory. Each implementation is an adapter in it, pinned in
`bench/impls.json`; `bench/README.md` says how to run and extend it, and
`bench/RESULTS.md` holds the last results, with the machine and every caveat.
```sh
cd harness && node bench.mjs --setup && node bench.mjs --rounds 3 --json ../bench/results.json
```
## Checks
Besides the harness and the tests, the source itself is held to these, the