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

zat.dev/zds

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

0
0
Claude and Claude Opus 5.5 Add a reads-during-writes bench lane 38a9d59 History
README.md

benchmarks

bench/ contains local benchmarks for ZDS storage paths. The goal is to track scaling curves and compare protocol work against reference implementations, not to produce a single universal score.

The benchmark style follows atproto-bench: state the exact work being measured, keep correctness work visible, compare equivalent operations, and treat run-to-run variance as real.

run

just bench all
just bench write
just bench read
just bench repo
just bench blob
just bench blob-gc 512 65536
just bench metastore 10 1000
just bench get-cid 10 1000
just bench get-block 10 1000
just bench decode-record 10 1000
just bench render-record 10 1000
just bench get-record 10 1000
just bench list-records 10 1000
just bench repo-size 5000
just bench get-repo 5000 4 5
just bench firehose 1000 32 100
just bench publish-sync 100 3 3 3145728
just bench fly-upload
just bench repo-large 100000
just bench space 1000
just bench http
just bench startup 5 10000
just bench official-pds
just bench write-profile 10 500
just bench run --scenario write --records 10000

just bench ... is a Just module declared from the repository root with mod bench.

current scenarios

  • write: applyWrites creating app.bsky.feed.post records.
  • read: repeated listRecords queries against one seeded repo.
  • repo: full repo CAR materialization through writeRepoCar.
  • blob: blob write/read against disk blobstore plus SQLite metadata.
  • blob-gc: bounded deletion of untethered blob metadata and disk files.
  • metastore: Tranquil-shaped apply/get/list benchmark with caller counts and latency percentiles.
  • get-cid: CID-only record lookup, matching Tranquil's get_record_cid metastore benchmark.
  • get-block: record index lookup plus repo_blocks byte fetch.
  • decode-record: DAG-CBOR decode of one seeded record block, without SQLite.
  • render-record: DAG-CBOR decode plus JSON rendering, without SQLite.
  • get-record: full com.atproto.repo.getRecord storage materialization.
  • list-records: full com.atproto.repo.listRecords storage materialization.
  • repo-size: synthetic small/medium/large repo probes for listRecords(limit=100) and full repo CAR materialization. The default Just target keeps this moderate; use repo-large for intentional 100k+ record runs.
  • get-repo: focused com.atproto.sync.getRepo storage-pressure probe. It measures full repo CAR construction, since diff CAR construction after one additional commit, and concurrent full exports against one seeded repo. Its isolation lane runs account lookups and writes during those exports so a throughput improvement cannot hide resident-facing database stalls.
  • firehose: runs the maximum 32 synthetic subscribeRepos pollers while measuring resident account-read latency. Event-history reads must remain ordinary indexed range reads; migration or repair work in this path causes global database-lock contention that stalls login, writes, and blob reads.
  • publish-sync: mixed workload modeled on continuous media publishers. It runs concurrent multi-megabyte blob uploads and same-repo writes alongside blob/repo sync reads, while measuring a small metadata lookup for unrelated tail-latency stalls.
  • fly-upload: end-to-end upload/write/read pressure on an isolated, production-shaped Fly Machine. A separate load-generator Machine logs in 100 synthetic accounts, publishes blobs and records at staged concurrency, and records collateral authenticated-read latency. The temporary Fly app and all of its Machines are deleted after the run.
  • space: experimental permissioned-data storage probes for space discovery, private record writes, private record reads/lists, repo oplog catch-up, and blob readback.
  • http: starts a local ReleaseFast ZDS server and measures a seeded HTTP route matrix with ApacheBench. This is the route-level check for the httpz server boundary and should be tracked separately from storage microbenchmarks.
  • official-pds: copies the official-PDS read probe into a local bluesky-social/atproto checkout and runs it with Vitest.
  • write-profile: applyWrites stage timing under write concurrency.

Each run uses temporary SQLite and blobstore state.

permissioned data

Permissioned-data benchmarks are separate from the public repo/appview/sync benchmarks. The goal is not broad coverage yet; it is to catch obviously bad access patterns introduced by the experimental com.atproto.space.* storage model.

just bench space seeds one self-owned space, one writer repo, and one small blob, then measures these paths as distinct units of work:

  • listSpaces
  • listMembers
  • full-state getRepo STAR construction
  • full-state STAR verification, as a syncer or migration does
  • createRecord into a space writer repo
  • getRecord by (space, repo, collection, rkey)
  • listRecords, limit 50, with values included by default
  • listWriters
  • listRepoOps catch-up reads
  • listBlobs
  • getBlob exact-space reference authorization plus storage readback

Comparison against Daniel's permissioned-data branch should live in this section once we have a repeatable way to run that PDS locally. Until then, keep ZDS numbers as local trend data and compare only equivalent operations.

repo sizes

The normal write/read benchmarks use small synthetic repos so they stay fast enough to run while developing. just bench repo-size adds explicit small/medium/large tiers for repo-size-sensitive paths:

  • small: 100 records
  • medium: 1,000 records, unless the selected maximum is lower
  • large: the max_records argument

Use just bench repo-large 100000 for a deliberate larger run. Large public accounts are useful reference shapes because they stress repo export, record indexes, and cursor/list behavior. As of June 15, 2026, the public appview reports about 38k posts for pfrazee.com and about 87k posts for jcsalterego.bsky.social, so a 100k synthetic tier is the right order of magnitude for large-repo stress. Live network corpora should be captured into fixtures before they become stable benchmarks. Do not make routine CI or pre-commit checks depend on live PDS availability.

June 29, 2026 local reachable-export check after switching full com.atproto.sync.getRepo from whole-DID repo_blocks scans to current-root reachability via zat.mst.collectReachableBlocks:

repo tierrecordslistfull CAR export
small10013.4k ops/s, 15.0 ms3.6k ops/s, 72.1 MB/s, 1.4 ms
medium1,00012.4k ops/s, 16.1 ms297 ops/s, 59.6 MB/s, 16.8 ms
large5,00011.9k ops/s, 16.8 ms52 ops/s, 53.1 MB/s, 95.7 ms

These are synthetic local trend numbers, not cross-PDS comparisons. The old whole-DID range-scan export path is intentionally no longer the production full export behavior because it could include retained stale blocks.

just bench get-repo is the narrower operator-facing lane for the same sync surface. It belongs here first because ZDS owns the storage and route behavior for serving repo exports. Cross-PDS HTTP comparisons, compression behavior, and live backfill traffic should live in atproto-bench once this local seam is stable enough to compare against other implementations.

methodology

  • Build ZDS with -Doptimize=ReleaseFast.
  • Use temporary SQLite and blobstore state for every run.
  • Seed records before read benchmarks so lookup/list work is separated from write setup.
  • Report throughput plus p50/p95/p99/max/mean latency for concurrent paths.
  • Keep HTTP route benchmarks separate from storage benchmarks. Route numbers include request parsing, routing, response serialization, auth/session work, and httpz connection handling.
  • Compare ratios from the same machine and same run window. Absolute numbers move with system load, thermal state, compiler version, and storage backend.
  • Do not compare paths that perform different correctness work. For example, CID-only metadata lookup is separate from full getRecord materialization.

traffic model

For a small hosted PDS, the hot paths are not exotic. A hundred active accounts mainly means more session checks, appview-proxied feed/profile reads, record writes from clients and apps, blob uploads, sync subscribers, crawl requests, and occasional repo export/import. The storage benchmarks should therefore keep these domains separate:

  • record index: current CID lookups, existence checks, and index-only lists.
  • record materialization: index lookup, block fetch, DAG-CBOR decode, and JSON response rendering.
  • write path: validation, repo mutation, commit/block persistence, event publication, and crawl notification.
  • blob path: upload body ingest, disk write, metadata persistence, and readback.
  • sync path: event delivery and repo CAR materialization.

current local baseline

On this machine, with --records 1000 unless noted:

scenariozds
write records144 ops/s
list records30k ops/s
write repo car252 ops/s, 440 MB/s
blob put+get368 ops/s, 46 MB/s

Current local HTTP route baseline after adopting httpz, measured with just bench http using 5000 requests at concurrency 50 for normal routes and 500 requests at concurrency 10 for blob/CAR routes. The harness covers public metadata, OAuth metadata, session/account reads, preference reads, repo reads, sync reads, blob reads, and repo CAR reads. Stateful write endpoints and WebSocket subscribeRepos need separate harnesses.

route grouphttpz
static/landing routes11.6k-40.2k req/s
public identity/server metadata31.9k-38.9k req/s
OAuth metadata/JWKS35.6k-37.0k req/s
OAuth authorize JSON4.4k req/s, p95 28 ms
session/account reads20.5k-34.9k req/s
createSession7.4k req/s, p95 20 ms
repo reads26.2k-39.0k req/s
listRecords, limit 5026.2k req/s, p95 6 ms
sync JSON reads24.1k-39.4k req/s
blob/CAR reads34.5k-37.9k req/s

The pre-httpz column below is the original narrow route set run against commit 4841aec; it should not be treated as coverage for the expanded route matrix.

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

coverage map

High-level ZDS surface area represented in bench/:

PDS surfacerepresentative benchmark
repo writeswrite, metastore, write-profile
repo readsget-cid, get-block, get-record, list-records
repo export/sync snapshotsrepo, repo-size, get-repo
sync event storagemetastore write path plus smoke tests
blob storageblob, publish-sync, space blob readback
HTTP routing/serialization/auth overheadhttp
OAuth/session/account routeshttp route matrix
permissioned spacesspace
official PDS read-path comparisonofficial-pds

Still intentionally outside the routine benchmark gate:

  • passkey ceremony cryptography and browser UX
  • mail delivery providers
  • live appview proxy latency
  • WebSocket subscriber fanout under network backpressure
  • live public-repo corpora until captured as stable fixtures

implementation comparison

The main PDS implementations do not expose identical benchmark seams, so keep comparisons grouped by equivalent work:

implementationcomparable bench surfacenotes
ZDSbench/main.zig, tools/http_bench.shlocal SQLite/blobstore, storage microbenchmarks, HTTP route matrix, permissioned-space storage
Tranquilcrates/tranquil-store/benches/metastore*.rs, blockstore.rs, eventlog.rsbest match for metastore-shaped record/index/event/blockstore comparisons
official Bluesky PDSbench/official-pds-records.bench.ts copied into packages/pdsbest match for actor-store record CID/get/list/write paths
Pegasuspegasus/bench/bench_repository.ml, mist/bench/bench_mst.mlbest match for repository block/MST internals; not a full HTTP/PDS route comparison yet

stage checklist

For each protocol-parity or storage-behavior stage, do this before calling the stage complete:

  • Re-read the relevant atproto spec or lexicon, then cross-check the official PDS implementation and Tranquil.
  • Decide whether any new parser, codec, verifier, resolver, repository primitive, OAuth helper, or JSON-path helper belongs in zat; keep it local unless the reusable boundary is clear.
  • Add or update a focused ZDS benchmark for the changed surface.
  • Run the comparable Tranquil benchmark when Tranquil has the same seam.
  • Run the comparable official PDS probe when the official PDS has the same seam.
  • Record any mismatch as either fixed, intentionally local with rationale, or a concrete follow-up issue. Do not leave “close enough” behavior unnamed.

Run Tranquil's metastore benchmark:

cd /tmp/tranquil-pds
SQLX_OFFLINE=true cargo bench -p tranquil-store --bench metastore --features tranquil-store/test-harness

Run the matching ZDS scenarios:

just bench metastore 10 1000
just bench metastore 100 200
just bench get-cid 10 1000
just bench get-cid 100 200

This matrix includes only operation/count pairs measured with the same unit of work. Tranquil's get_record_cid is a record-index operation. The official PDS probe measures its actor-store read paths with Vitest; its single-operation rows are included for matching internal read/write boundaries.

Summary from the May 31, 2026 local run: ZDS is fastest in the single-caller CID lookup and full-materialization read probes. Tranquil is fastest in the 10/100 caller CID lookup probes and its index-only list_records path is faster than ZDS's full listRecords materialization. For writes, Tranquil and ZDS are close around the single-caller 1000-op shape, Tranquil is faster with much tighter tails at 10 callers, and ZDS has higher 100-caller throughput with much worse tail latency.

operationcallerszdstranquilofficial PDS
apply one record commit1281 ops/s, p95 8.1 ms289 ops/s, p95 4.9 ms448 ops/s, p99 4.0 ms
current record CID lookup1509k ops/s, p95 2 us111k ops/s, p95 12.6 us3.1k ops/s, p99 511 us

The direct caller-count concurrency matrix is ZDS and Tranquil only. Official PDS concurrency probes are kept separate until they use the same caller model.

operationcallersopszdstranquil
apply one record commit1010000289 ops/s, p95 86.1 ms744 ops/s, p95 15.9 ms
apply one record commit100200001423 ops/s, p95 65.0 ms, p99 806 ms1051 ops/s, p95 100 ms
current record CID lookup1010000345k ops/s, p95 18 us610k ops/s, p95 27 us
current record CID lookup10020000302k ops/s, p95 273 us630k ops/s, p95 212 us

Official PDS batched CID lookup:

operationbatch shapeconverted throughputbatch p99
current record CID lookup10 callers x 100 lookups3.3k lookups/s317 ms
current record CID lookup100 callers x 20 lookups3.2k lookups/s630 ms

Tranquil's metastore list_records benchmark is index-only, while ZDS listRecords joins repo_blocks and materializes record data. Keep these rows as adjacent probes until ZDS grows an explicit index-only list benchmark.

operationcallersopszds full materializationtranquil index-only
list records, limit 501500022.5k ops/s, p95 58 us32.9k ops/s, p95 37 us
list records, limit 50101000018.2k ops/s, p95 97 us38.9k ops/s, p95 271 us
list records, limit 501002000021.5k ops/s, p95 60 us38.5k ops/s, p95 2.75 ms

The current Tranquil metastore bench panics at its built-in 1000-caller get_record_cid row with metastore handler backpressure; treat that as a backpressure behavior to investigate, not as a throughput result.

official PDS probe

The official-PDS probe lives at bench/official-pds-records.bench.ts and is run with:

ATPROTO_REPO=/tmp/bluesky-atproto just bench official-pds

It seeds 1000 app.bsky.feed.post records through the official test network, then measures actor-store reads directly:

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

The matching ZDS single-caller rows are:

operationzds
apply one record commit642 ops/s, p95 2.9 ms
current record CID lookup414k ops/s, p95 4 us
full getRecord materialization48.6k ops/s, p95 28 us
full listRecords, limit 5021.6k ops/s, p95 60 us

local probes

These rows are useful for ZDS tuning but are not direct Tranquil comparisons.

operationcallersopszds
get record block1010000128k ops/s, p95 11 us
get record block10020000121k ops/s, p95 15 us
decode DAG-CBOR101000040.6M ops/s, p95 below timer resolution
decode DAG-CBOR1002000012.6M ops/s, p95 below timer resolution
render record JSON101000024.8M ops/s, p95 below timer resolution
render record JSON1002000012.4M ops/s, p95 1 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

The read-path split says SQLite serialization and row materialization dominate single-record reads. Decode/render is effectively invisible for tiny benchmark records; it needs a larger-record probe before we can extrapolate image-heavy or rich-record traffic.

write profile

write-profile tracks where concurrent writes spend time:

callersopsthroughputlock waitload repobuild commitsqlite/event
105000708 ops/s25%26%3%46%
10020003683 ops/s64%10%1%25%

ZDS separates repo ordering from database serialization: writes take a per-DID lane before loading and mutating the repo, then use the DB mutex for the shared SQLite connection. Tranquil remains the reference shape for bounded write queues, explicit backpressure, less full-repo state loading, and a narrower SQLite persistence phase.

comparison work

Tranquil benchmark source:

Official PDS source for matching probes:

Open apples-to-apples comparison gaps:

  • single-repo write curve as record count grows
  • multi-repo concurrent writes
  • record-index list latency without record body materialization, across ZDS and Tranquil
  • official-PDS direct concurrency harness for the same read/write boundaries
  • full repo export cost
  • blob/block store throughput

ZDS and Tranquil both report latency percentiles for the metastore-shaped write and CID lookup rows. The remaining comparison gap is broader coverage of blockstore, eventlog, full repo export behavior, an official-PDS benchmark harness, and an explicit ZDS index-only list probe that matches Tranquil's list_records.

June 18, 2026 write-path check

ZDS now uses zat.mst.Mst.loadLazy for repo authoring, backed by SQLite repo_blocks, instead of reading every repo block into an in-memory CAR before each write. This completes the earlier zat lazy-MST adoption for the hot write path.

Fresh local 10-caller metastore-shaped rows. The ZDS write row was repeated three times after the change and stayed in the same band: 2312.8-2525.2 ops/s, p95 11.2-12.2 ms.

operationzdstranquil
apply one record commit2312.8-2525.2 ops/s, p95 11.2-12.2 ms503 ops/s, p95 26.1 ms
current record CID lookup319.7k ops/s, p95 8 us294.6k ops/s, p95 54 us
list records, limit 5021.5k ops/s, p95 53 us35.8k ops/s, p95 382 us

Two just bench write-profile 10 1000 runs after the lazy-MST change reported 2527.1-2698.4 ops/s, p95 9.3-9.8 ms. Average write time was split roughly across lock wait 23-24%, lazy repo loading 9-10%, staging 10%, commit build 7%, and SQLite/event persistence 50%.

Spaces self-read scope parity (2026-10-02)

just bench space-scopes alternates member-list-style read_self checks with writes outside the granted collection. One million checks accept 500,000 reads and reject all 500,000 writes. Before the fix, ZDS rejected both. On the local Apple Silicon host, the ReleaseFast loop measured 42 ns/check before and 50–60 ns/check after; the earlier exit represented incorrect authorization.

The official PDS at 5b95b2f2723a2882824fbb0b819fd6aad884ef20 uses read_self for listMembers and its scope matcher makes both read actions collection-independent. A local probe of that revision's SpacePermission.matches accepted the same 500,000 reads and rejected all writes (14 ns/check in Node, with an already parsed grant; this is not directly comparable to ZDS's parse-and-match measurement). The local Tranquil scope implementation has no Spaces permission matcher, so there is no equivalent probe there. No storage or protocol primitive changed; this authorization policy remains local to ZDS.