| @@ -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]. |