chadtmiller.com/monolith
An atproto PDS
Scale: memory bounded by a cache, start time independent of the accounts, repositories and the firehose streamed from disk
ClosedThis pull makes memory depend on a cache and start time not depend on the number of accounts. It does that with lazy, evictable accounts, sorted-table checkpoints, an incremental MST, a firehose and getRepo streamed from disk, and jemalloc. The only new crates are tikv-jemallocator, plus rustix on Linux, which the workspace already had. Neither is an atproto or MCP crate.
I read these in full:
Cargo.toml,.cargo/config.toml,crates/pds/Cargo.tomlandcrates/pds/src/main.rsREADME.md,spec/PDS.mdandspec/STORE.mdharness/checks/scale.mjs,harness/compare.mjs,harness/gates.mjsand theharness/libchanges
What I found:
- Spec and README:
STORE.mdstates the new behaviour in observable terms: thePDS_CACHE_BYTESvariable, the memory bound, the cold-account bound, the start bound and streaming. It also describes the--scalecheck. The README says what is built and how it is checked, not how it was built. - Harness:
--scaleis a new check, not a loosened one. It states what it compares: RSS, sampled every 20 ms, against base + 32 MiB + cache + 4 KiB per account; start time against twice the empty start + 250 ms; and the records and events it wrote against what comes back. The start bound inSTORE.mdis now stricter than the old one, since it no longer allows growth with accounts. It is checked at 100 and 2000 accounts. - Perf suite:
gates.mjsruns the scale check alone in theperfsuite, which is right for a timing check.
I did not read the Rust diff, about 13,000 lines, so I make no claim about the following. If you want a second round, point me at the parts that matter most.
- Rust code: the
pds-repoMST,pds-storetables and generations, thepds-servercache, checkpoint, log, events, blobs, sync and lifecycle code, and their tests. - Server code and the reference PDS: I checked nothing against the reference PDS's or an SDK's source.
- Durability: I did not confirm that the
DURABILITY.mdguarantees still hold. harness/conformance.yaml: the pull does not touch it.
Landed on main as part of b1f2478, the folded stack (gate speed, then the lifecycle rules, then this). Its head 3ab04f7 is in main, plus a test fix (6f62865) and the rpc refusal's aud encoding (c97fc5e). Closing, as its content is merged.
The server scales to any size on one machine: memory is bounded by a cache, not by the data, and start time doesn't grow with the number of accounts.
Spec (
STORE.md, scale rules; observable, storage-agnostic)PDS_CACHE_BYTES(default 256 MiB), plus 4 KiB per account. It doesn't grow with idle accounts or repository size.getRepo, firehose replay andlistBlobsare read from disk as they are sent.Server
rustix).sha2's asm is on, since software SHA-256 dominated cold loads on aarch64.DURABILITY.mdguarantee and its byte-cut tests.Bugs the later steps found, fixed with tests:
FutureCursorafter a restart (seqs are reserved ahead);Measured (
--scale, 16 MiB cache)getRepoof 64 MiBHarness:
--scalemeasures RSS and start time over 100, then 2000 accounts and a 64 MiB repository. It runs in theperfsuite, alone, since it times the server.Checked: the code gates (in
rust:1.98),cargo test --workspace,gates.mjs perf(--scaleand perf),--store, plain seed 1, crash seed 21 with--firehose,--lifecycle, the other gate runs on the scale branch, and--scaleon Linux.🤖 Generated with Claude Code
Stacked on the lifecycle pull: this branch is the scale work merged with it. The one combining conflict was in
lifecycle.rs, wheregetSubjectStatusnow reads a record through the store (st.record(path)), since records are no longer all in memory.