zat.dev/zds
atproto pds · mirror of https://tangled.org/zat.dev/zds
zds 0.25.1 Latest 2 packages, all images
0
0
# startup and storage benchmarks
> History: dated optimization work on startup and Spaces storage, with the
> measurements taken at the time. The current benchmark methodology is in
> [benchmarking](https://tangled.org/zat.dev/zds/blob/main/docs/benchmarking.md).
## 2026-09-05: index commit CID lookups
The revision backfill runs on startup and matches NULL-revision blocks against
commits by `(did, cid)`. Without a matching index, unmatched historical tree
blocks repeatedly scan an account's commit history. A non-unique composite
index removes those scans without skipping backfill or integrity validation.
Five-run medians on macOS arm64, ReleaseSafe, warm filesystem. This initial
fixture had block and commit history but no sequence-event payloads:
| lane | before | indexed |
| --- | ---: | ---: |
| fresh schema | 22.00 ms | 22.34 ms |
| empty restart | 9.11 ms | 9.33 ms |
| history restart | 3147.59 ms | 15.38 ms |
| old history snapshot, including index creation | — | 29.01 ms |
These fixture results are not production startup timings. Before the change,
Fly logs showed about 5 seconds from process launch to the listening message.
An external one-second health probe with a two-second request timeout observed
8 consecutive timeouts spanning roughly 17 seconds during the prior deployment;
that includes machine replacement and proxy routing, not just process startup.
## sequence recovery
The first indexed production deployment still recorded `storage_ms=5709`.
The fixture improvement alone did not establish a production improvement.
Read-only production probes then identified another scan: computing the next
sequence via `MAX` over a union of every commit and event sequence. That query
scanned the event table (including its large row storage). Computing `MAX(seq)`
inside each branch first preserves empty-table and gap semantics while letting
SQLite seek to each table's final integer primary key. A production read-only
comparison returned 10914 for both queries, taking 556 ms and 1 ms respectively;
these are individual warm query measurements, not full startup measurements.
The history fixture now includes 10,000 events with 4 KiB payloads to exercise
this path. Regression tests cover empty histories, either history being ahead,
gaps, and an empty commit table with retained events.
## narrow revision backfill to missing revisions
Production `EXPLAIN QUERY PLAN` showed `SCAN repo_blocks` for both backfill
updates even after commit lookup was indexed. Unlike the read-only SELECT
probes, UPDATE selected a full scan of payload-bearing block rows. A partial
index on `(did, cid) WHERE repo_rev IS NULL` bounds subsequent backfill work to
unversioned blocks. It is created after the legacy `repo_rev` column migration.
Index creation still scans existing blocks once on upgrade; it does not remove
or bypass migration work. The fixture now includes 4 KiB block payloads as well
as events, exposing the cost of scanning payload-bearing tables.
With payloads in the fixture, five-run macOS ReleaseSafe median readiness fell
from 33.86 ms (commit index only) to 9.22 ms (partial index plus per-table sequence
maxima). Empty restarts measured 9.16 ms. These warm-cache results are distinct
from the initial small-block comparison above.
## September 2026: independent simplespace read/write access
On macOS arm64, Zig 0.16.0, ReleaseFast, three `just bench space 1000`
runs before and after the API/storage update gave these median throughputs:
| storage operation | before ops/s | after ops/s |
| --- | ---: | ---: |
| listSpaces | 56,055 | 54,399 |
| listMembers | 38,596 | 37,099 |
| createRecord | 7,389 | 7,224 |
| getRecord | 180,344 | 174,748 |
| listRecords | 44,609 | 43,957 |
| getRepo | 624 | 628 |
These sequential local samples show small changes (roughly 1–4% on most read
paths), not a production capacity estimate. The member list now returns two
additional flags and space configuration reads return independent policies.
At 10,000 records, a single export probe measured 69.0 ops/s before and 68.6
after; createRecord measured 7,016 before and 7,319 after. Membership size is
not scaled with record count in this fixture.
A ReleaseSafe startup rehearsal on a consistent production SQLite backup
preserved account, session, OAuth, public block, permissioned record, space
configuration, and membership state. The migration stage took 10 ms locally;
first readiness was 336 ms and a subsequent restart reached readiness in
11 ms. These are individual warm-filesystem samples, not Fly replacement
or network interruption measurements.