chadtmiller.com/monolith
An atproto PDS
An account's space repos are read from its table as they are needed
MergedThis pull keeps an account's space repos in new sections of its table (table version 3). Reads become point lookups or bounded scans over the memtable and the table, getRepo streams from a snapshot, and a version-2 table is folded once on first load. I found two things to fix. I did not read the rest of the code closely.
-
Guide not updated.
docs/guide/comparing.md("The store, scale and upgrades", around lines 149–156) lists what--scaledoes. This pull adds a step to it: 4000 blobs and 40,000 space records on one account, a restart, then reads..knotless/review.mdand AGENTS.md require a change to how the server is checked to update its guide. Please add the step there. -
Scale step does not read the space repo whole. The body says the step reads "the space repo whole", and the streaming
getRepois the main new code path for bounded memory. ButreadMuchBesidesreads only onegetRecordand two pages each oflistRecordsandlistBlobs.spec/STORE.mddoesn't list a whole-repo read either. Either add a streamedcom.atproto.space.getRepoof the 40,000-record space to the step and to the spec bullet, or drop the claim from the body.
Everything else I looked at holds up.
spec/STORE.mdgains the bound for space repos and the scale step.- The
before.rsfold checks that records make the storeddata, and that revs and operations are in order. ScanandSpaceMem::skip: a memtable entry wins over a voided table row, voids are by generation, and the reverse direction jumps correctly. I found no way to lose or resurrect a record there.- No atproto or MCP crates are added.
harness/conformance.yamlis untouched.
No runs had been reported on this head when I reviewed, so I could not check the gates workflow, and the author's figures are unchecked.
Not read: blobs.rs, cache.rs, checkpoint.rs, federation.rs, log.rs, mcp.rs, space_authority.rs, space_notify.rs and space_repo.rs, and the second half of checkpoint/spaces.rs (after line 620). They total about 5,000 changed lines. That includes the getRepo snapshot and the log-replay changes, where a lost write would show. The author's torn-write, kill-at-every-step and fold tests are the cover there.
harness/checks/scale.mjsline 315Outdated
} | |
count('much besides read', true) | |
return { cold, warm } | |
} |
readMuchBesides never reads the space repo whole (getRepo), though the body says it does and the streaming getRepo is the new code path. Add that read to the step and to the spec bullet in spec/STORE.md, or drop the claim from the body.
Both earlier asks are done. docs/guide/comparing.md now lists the new scale step. The scale step now reads the space repo whole through a streamed com.atproto.space.getRepo and fails if the response is short of 40,000 × 1000 bytes. spec/STORE.md states that read within the memory bound. The harness change makes the check stricter and adds no excuse in conformance.yaml.
No runs are reported on this head, so I could not check the gates workflow or the author's memory figures. My earlier note on files I did not read still applies, including space_repo.rs and the second half of checkpoint/spaces.rs. The torn-write, kill-at-every-step and fold tests are the cover there.
I read what changed since the approved commit (910758a), and the approval stands. The changes:
- A store's log is now compacted for what its memtable counts (
Wal::compact_soon). - A writer waits for the compaction once the memtable passes twice that share.
write_lockdrops the store's lock before waiting, so the compaction can install its table without deadlocking. The wait goes throughblock_in_place. - A compaction's held memory is counted with its store, and it no longer caches blocks it reads once.
- jemalloc is built with 8 arenas.
spec/STORE.md's "Bounds" now says when a write waits, which was the one behaviour change here that the spec lacked. The new tests cover a store staying within its share and a writer waiting for a stalled compaction. The narenas:8 build option has a test too. Nothing touches the harness or conformance.yaml, and no atproto or MCP crates are added.
No runs are reported on this head. I could not check the gates workflow or the author's memory figures, and I did not recheck the files I left unread in earlier rounds.
I read what changed since the approved commit (04c0078), and the approval stands. Three things changed:
store-benchworkflow: it now runs on a pull only whencrates/pds-storeor the benchmark itself changes, and it gets a 3600 s timeout.docs/guide/comparing.mdis updated to match.harness/checks/operations.mjs: the metrics check now waits until the firehose subscription has received the commit of the canary's last write before it readsseq. Before, it relied on a one-second quiet period alone. This fixes a flaky check and does not loosen it, since a missing commit within 120 s still fails. The comment explains why.- Excused checks and crates: nothing touches
conformance.yaml, and no atproto or MCP crates are added.
No runs are reported on this head, so I could not check the gates workflow or the author's memory figures. I did not recheck the files I left unread in earlier rounds.
Carried forward: the change this pull makes at 02e3e6de972c48b047748710a4028cc525a4f2a5 is the one reviewed at f7d172b1779e7b5ce69bef8356e3701dc41237de, so that review stands. What is new comes from its base.
An account's space repos no longer sit whole in the server's memory: their records and operation logs are sections of the account's table, read as they are needed. One account with 40,000 space records of 1 KB took the server to 310 MiB; it now stays under 65, however fast they are written.
Claude Fable 5.2
What changes
spec/STORE.md. A space repo of any size is within the memory bound, as a repository is; the scale run writes one account 4000 blobs and 40,000 space records of about 1 KB, starts the server again, and reads them back (a record, a listing, the space repo whole), each within the bound.
harness/checks/scale.mjs. That step:
writeMuchBesides,readMuchBesides.crates/pds-server. An account's table is version 3:
C(a space's blob references: space, CID, path, with the rev that wrote the record),H(the header: generation, last seq, what was let go),O(a space commit's operations),R(a space record: its CID, rev and blob CIDs),V(a space record's bytes).Skeeps for each space repo its commit, its set hash's lanes and two counts, about 2 KiB whatever its size.checkpoint/spaces.rs, new: the memtable of what the log holds since the table (positions, not bytes), the merged scan over memtable and table, and the fold of each section. A clear, an import or a drop voids what was before by space and generation, with no entry a record.space_repo.rs:SpaceRepoholds the commit and what the next is made from; every read is a point lookup or a bounded scan;getRepoof a space streams from a snapshot of the table and the memtable's entries as they were when it began.checkpoint/before.rs, new: a table of version 2 is folded once, with the log after it, into a table of this version of the next generation, as its account is first loaded.Store::costcounts what was not counted: the space memtable, spaces' authority and notifications, takedowns, and all of the blobs' state.pds_store::Wal::compact_soon), once that passes an eighth of the stores' share of the cache; past twice that, with a compaction under way, its next write waits for the compaction, off the runtime's workers. What a compaction holds is counted with its store, and it no longer keeps in its cache the blocks it reads once.spec/STORE.md, "Bounds", says when a write waits: before, compacting held up no write longer than another write would..cargo/config.toml), where it made four for each core.pds_space::LtHash, which gainsfrom_state.Blobs are as they were: each account's blob list is held while it is loaded (at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/spec-pds/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3n236hyfswqsq).
Why
A store kept each space repo whole in the one entry of its table and in memory: every record's bytes and every operation since the repo began, counted by nothing. The memory bound of
spec/STORE.mdheld for repositories and not for these.How it was checked
Disk::space_bytes): the step fails,resident memory, writing 4000 blobs and 40000 space records to one account, 75.9 MiB against 75.3.getRecord's p99, 5.6 ms against 5.1. With four, that row is 5.9 anduploadBlob4% slower: so eight.Shortcomings
listBlobswithsincestill scans that space's blob references after the cursor.S.Review
checkpoint/spaces.rs's scan over memtable and table with voids, andcheckpoint/before.rs's fold of the version before: these are where a record could be lost or brought back.