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

zat.dev/zds

atproto pds · mirror of https://tangled.org/zat.dev/zds

0
0
252 lines · 11.7 KB Raw History

benchmarking

Benchmark notes should separate behavior domains and only compare equivalent work. If a measurement does not exist for the same unit of work, keep it out of the comparison table instead of filling the cell with a nearby but different operation.

references

  • ZDS: bench/main.zig
  • Tranquil: crates/tranquil-store/benches/metastore.rs
  • Official PDS: packages/pds/src/actor-store/record/reader.ts

current matrix

The active apples-to-apples matrix is intentionally small:

  • apply one record commit
  • current record CID lookup

Adjacent probes are tracked separately:

  • record-index list
  • full record materialization
  • blob/block put and get
  • repo export
  • sync event delivery

ZDS, Tranquil, and the official PDS have matching single-caller numbers for apply-one-record and current-CID lookup. ZDS and Tranquil also have direct 10/100 caller concurrency curves. Official-PDS batch probes stay outside the main matrix until they are measured through the same unit of work.

Current local comparison. The Tranquil rows are from a fresh local metastore run on June 18, 2026. The ZDS write row was remeasured after completing the lazy-MST adoption in the repo write path.

operationcallerszdstranquilnote
apply one record commit11598 ops/s, p95 0.65 ms267 ops/s, p95 4.13 msZDS no longer eagerly loads the whole repo CAR
apply one record commit102313-2525 ops/s, p95 11.2-12.2 ms503 ops/s, p95 26.1 msZDS row is repeated-run range
current CID lookup1523k ops/s, p95 2 us116k ops/s, p95 12.6 usZDS ahead
current CID lookup10319.7k ops/s, p95 8 us294.6k ops/s, p95 54 usboth use record-index lookup

Tranquil's built-in 1000-caller metastore row currently trips handler backpressure in the benchmark harness. Keep it out of the table until the harness handles backpressure as a measured result.

ZDS write authoring uses zat.mst.Mst.loadLazy with a SQLite-backed repo_blocks reader. This avoids reading every stored repo block into a CAR before each write while preserving the signed commit, MST update, record index, and sync event behavior.

read path

ZDS follows the official PDS read shape for getRecord and listRecords: read the current record index row, fetch matching repo_blocks bytes, decode DAG-CBOR, and render JSON for the XRPC response. Tranquil's metastore list_records is a different unit of work because it returns only rkeys and CIDs. Keep those rows separate.

Current ZDS read breakdown on this machine:

operationcallersopsresult
current CID lookup1010000222k ops/s, p95 225 us
current CID lookup10020000211k ops/s, p95 887 us
index + block fetch1010000128k ops/s, p95 11 us
index + block fetch10020000121k ops/s, p95 15 us
full getRecord101000038.4k ops/s, p95 173 us
full getRecord1002000038.1k ops/s, p95 11.7 ms
full listRecords, limit 50101000021.1k ops/s, p95 57 us
full listRecords, limit 501002000019.5k ops/s, p95 78 us

Adjacent Tranquil list comparison:

operationcallerszdstranquilnote
list records, limit 50122.5k ops/s, p95 58 us32.9k ops/s, p95 37 usZDS full materialization; Tranquil index-only
list records, limit 501018.2k ops/s, p95 97 us38.9k ops/s, p95 271 usnot same unit of work
list records, limit 5010021.5k ops/s, p95 60 us38.5k ops/s, p95 2.75 msnot same unit of work

The official PDS probe on the same machine reports:

operationresult
apply one record commit448 ops/s, p99 4.0 ms
current CID lookup3.1k ops/s, p99 511 us
full getRecord3.0k ops/s, p99 525 us
full listRecords, limit 50635 ops/s, p99 2.4 ms

The official PDS batched CID lookup probe reports:

batch shapeconverted throughputbatch p99
10 callers x 100 lookups3.3k lookups/s317 ms
100 callers x 20 lookups3.2k lookups/s630 ms

For tiny records, DAG-CBOR decode and JSON rendering are below useful timer resolution. Larger records and index-only list probes are tracked as separate comparison gaps instead of being folded into the current table.

permissioned data

Permissioned-data measurements should stay separate from the existing repo, blob, sync, and HTTP route matrices. The experimental com.atproto.space.* surface has its own storage model, actor-local space state, writer repo state, record oplogs, credentials, and ranged blob reads, so mixing it into the public repo tables would hide the actual access pattern.

The first benchmark slice should be small and diagnostic rather than exhaustive:

  • seed one self-owned private space and one writer repo.
  • measure listSpaces, listMembers, record write, record read, listRecords, listWriters, full-state getRepo STAR construction and verification, listRepoOps catch-up, listBlobs, and getBlob separately.
  • report p50/p95/p99/max for the concurrent paths, but keep write, read, blob, and oplog rows separate.
  • compare to Daniel's permissioned-data branch only after we can run that PDS locally with the same seeded work.

The question for this slice is simply whether any route has an obviously bad query shape, full-table scan, unnecessary blob materialization, or avoidable global lock hold. It does not need to become a giant protocol benchmark suite.

HTTP route path

just bench http starts a local ReleaseFast ZDS server and measures a seeded route matrix with ApacheBench. These numbers include HTTP request parsing, routing, response serialization, auth/session work, httpz connection handling, and whatever endpoint work the route performs. Keep them separate from the storage microbenchmarks above.

The current harness covers public metadata, OAuth metadata, session/account reads, preference reads, repo reads, sync reads, blob reads, and repo CAR reads. It deliberately does not loop over stateful write endpoints such as createRecord, applyWrites, uploadBlob, or passkey registration because a static ApacheBench body would mostly measure duplicate/error paths after the first request.

just bench websocket-churn covers the WebSocket lifecycle separately. It repeatedly opens and closes cohorts of subscribeRepos clients at the server's live-connection limit, then checks that detached connection workers return to the baseline thread count. A warm second round also guards against renewed, unbounded RSS growth while allowing the allocator to retain its first-round high-water capacity.

Current local route baseline after adopting httpz, with 5000 requests at concurrency 50 for normal routes and 500 requests at concurrency 10 for the larger blob/CAR routes:

routehttpz
/15.0k req/s, p95 10 ms
/favicon.svg40.2k req/s, p95 1 ms
/og-image11.6k req/s, p95 5 ms
/xrpc/_health31.9k req/s, p95 1 ms
/.well-known/did.json38.9k req/s, p95 1 ms
/.well-known/atproto-did38.5k req/s, p95 1 ms
OAuth metadata/JWKS35.6k-37.0k req/s, p95 2 ms
oauth/authorize JSON4.4k req/s, p95 28 ms
describeServer38.7k req/s, p95 1 ms
createSession7.4k req/s, p95 20 ms
getSession23.8k req/s, p95 6 ms
getServiceAuth24.5k req/s, p95 5 ms
account/security reads20.5k-34.9k req/s, p95 4-7 ms
getPreferences32.0k req/s, p95 5 ms
resolveHandle23.9k req/s, p95 2 ms
describeRepo39.0k req/s, p95 1 ms
getRecord30.0k req/s, p95 5 ms
listRecords, limit 5026.2k req/s, p95 6 ms
listMissingBlobs27.6k req/s, p95 6 ms
sync JSON reads24.1k-39.4k req/s, p95 1-4 ms
sync.getBlob34.5k req/s, p95 1 ms
sync.getBlob HEAD34.8k req/s, p95 1 ms
sync.getRepo37.9k req/s, p95 below 1 ms
sync.getRepo HEAD36.6k req/s, p95 below 1 ms

The separate permissioned-data scenario (just bench space) covers space discovery, management-policy reads, record writes and reads, writer/oplog enumeration, full repo STAR construction and verification, referenced-blob enumeration, and blob serving. Keep it separate from public-repo benchmarks because the storage and commit formats are intentionally different.

The only pre-httpz route numbers currently available are the original narrow route set, run against commit 4841aec with the same four probes:

routepre-httpzhttpz
/xrpc/_health34.1k req/s, p95 3 ms34.5k req/s, p95 3 ms
describeServer38.4k req/s, p95 1 ms39.3k req/s, p95 1 ms
getSession19.9k req/s, p95 8 ms20.8k req/s, p95 6 ms
listRecords, limit 5019.8k req/s, p95 11 ms22.4k req/s, p95 7 ms

traffic model

For roughly 100 hosted accounts, useful benchmarks should mirror real traffic:

  • clients call getSession, preferences, profiles, timelines, and proxied appview routes repeatedly while open.
  • apps call createRecord, applyWrites, getRecord, and listRecords.
  • media posts call uploadBlob before record creation.
  • relays and tools call sync endpoints, repo export, and blob reads.
  • the landing page reads residents, record counts, recent records, and profile blobs.

This traffic model is the basis for future route-mix benchmarks and per-route latency instrumentation. Keep those measurements separate from isolated storage microbenchmarks.

startup and deployment interruption

Run just bench startup 5 10000 for a ReleaseSafe build (the production optimization mode) and five samples per scenario. Build time is excluded. tools/startup_bench.py measures subprocess launch to the first HTTP 200 health response with status: ok. It emits JSON with platform, binary SHA-256, individual samples and min/median/max. Polling adds up to roughly 5 ms plus HTTP request overhead; these are warm-filesystem runs, not cold VM boots.

The lanes separate fresh schema creation, empty existing-database restart, and history-shaped restart. The history fixture has 10,000 commits, 60,000 blocks with 4 KiB payloads, 10,000 sequence events with 4 KiB payloads, and 2,000 unversioned tree blocks which match neither records nor commits. It is a synthetic SQLite workload, not a signed repository or an API throughput benchmark. Increase the second argument to examine scaling.

For an existing local SQLite backup, run:

uv run tools/startup_bench.py --snapshot /path/to/backup.sqlite3 --runs 5

The source is opened read-only and copied with SQLite's backup API before every sample. The server only opens disposable copies. Runs bind to loopback, disable crawler notifications, discard inherited ZDS_* configuration, and clean up child processes and temporary data. Output exports stage durations, not server logs or account data. Use local backups rather than a production database path.

Startup logs report storage_ms, account_setup_ms, and http_init_ms. They measure storage initialization, account bootstrap/announcement setup, and HTTP server construction respectively. Storage also reports migrations_ms and sequence_ms to separate those two phases. The existing "listening" message precedes server.listen(); HTTP health remains the authoritative readiness measurement.

For production rollouts, record both process stage timings and an external health probe across replacement. Compare failure windows separately from healthy response latency. A single machine with a local SQLite volume has a deployment interruption even when application startup is fast; avoid extra restarts solely to publish benchmark notes.

The startup optimizations behind these lanes, with their before and after measurements, are in history.