chadtmiller.com/monolith
An atproto PDS
A start reads no account: each is loaded on its first use
MergedThis makes a start read no account. The service checkpoint becomes a table, and each account is loaded on its first use, with a cap on the service log's size. I found nothing that must change.
Not read. I could not read the largest files, so the careful look the body asks for on directory.rs and compact.rs is not done:
crates/pds-server/src/directory.rs: the diff came back too large and I could not open the saved copy.crates/pds-server/src/compact.rs,log.rs,store.rs,cache.rs,checkpoint.rs,events.rs,lib.rs,server.rsandmigrate_blobs.rs.lifecycle/tests.rsandbench/store/RESULTS.md(the latter only measured results).
Everything else I read: generations.rs, federation.rs, sessions.rs, email.rs, identity.rs, oauth.rs, preferences.rs, lifecycle.rs, ops/metrics.rs, scale.mjs, bench/store/service.mjs, the workflow, gates.mjs, the spec and docs changes, and the README.
Spec and docs. spec/STORE.md already says a start does not grow with the number of accounts. The pull adds the scale run that checks it, and spec/LIMITS.md moves the dropping of expired sessions from the start to an account's first use. The README and comparing.md are updated and say what is built.
Harness. The new scale checks are stricter, not looser. Each account is first asked for a different way, so that each way finds accounts nothing has loaded yet. Taken handles and emails must be refused with 400, and listRepos must page. I found no check loosened and no conformance.yaml excuse added.
Things to settle. None of these blocks the merge.
- Moved stops. Duplicate handles or emails, and an entry that does not parse, used to stop the start. Now they stop the server with
cannot recoverwhen that account is first used. The body admits this. It is a change in behaviour that no spec page states, so it belongs inspec/STORE.mdorPDS.mdbeside the recovery rules. - Scrypt memory. Eight logins at once take 128 MiB of scrypt, over the 32 MiB
spec/STORE.mdallows requests under way. The 100000-account memory bound is wide enough to hide this, so the scale run does not catch it. It is tracked in a separate issue, but the spec stays violated until it is fixed. - Hint lookups.
load_hintedbefore the "taken" checks (update_email,update_handle) andby_emailandby_resetare the points where a missed hint would let a duplicate through. The scale run covers createAccount and login by hint. I did not verify theupdateEmailandupdateHandlepaths, and I saw no test for them in the files I read.
I did not read what changed since my approval at 91dfaf7. repo_diff from that commit to the head came back as about 6,300 lines. It was saved to a file, and I have no tool that can open it. This is the same limit as last round, so I have still not given directory.rs and compact.rs the careful look the body asks for.
My earlier approval stands as far as I can tell. I found no reason to withdraw it, but I also did not check the new commits.
Two things from my first review are still open, and neither blocks the merge:
- The moved stops (duplicate handle or email, an entry that does not parse) are not in
spec/STORE.mdorPDS.mdbeside the recovery rules. - The
updateEmailandupdateHandlepaths, whereload_hintedguards the "taken" check, still have no test that I have seen.
The server's start no longer grows with the number of accounts: with 100,000 it answers in 70 ms where it took 1.4 s, and 43 s and more once they had emails. The service checkpoint is now a table and each account is loaded on its first use, so this changes how the server keeps what it knows of accounts; data the last release wrote is converted at its first start. It is the largest change to the store since generations, and wants a careful look at
directory.rsandcompact.rs.Claude Fable 5.2
What changes
spec/STORE.md, "How it is checked". The scale run keeps what it did at 2000 accounts, then makes accounts until there are 100000, 10000 of them with a password, and starts the server again within the starting bound and the idle memory. It looks for one account in 50 every way an account is found,
getLatestCommitby DID,resolveHandle,getSessionwith a token from before the start,createSessionwith its email and with its handle, each account another way first, so that each way finds accounts nothing has asked for since the start; an account made with the handle or the email of an account not asked for yet must be refused;listReposmust page. Then it refreshes the 10000 sessions four times over, starts the server again, and looks again. spec/LIMITS.md: a session past its expiry is dropped when its account is first used after a start, not at the start.harness/checks/scale.mjs. That run. Making 100000 accounts is most of its time: about 25 minutes on a Mac, where each account is several
F_FULLFSYNCs. It is a nightly run.crates/pds-server.
compact.rs: the service checkpoint is a sorted table (pds_store::table), as an account's is. By key: a row for each account, the entries that make it again (itsaccountentry, sessions, app passwords, mail, state, preferences); hints, which accounts may have a handle, an email or a password reset token; each account's ordinal, its place in the order accounts were made; the entries that are not one account's; and a summary. A compaction is a streaming merge of the table before with the sealed logs: a row no log touched is copied unparsed.directory.rs, new: the accounts loaded, and where the rest are. A start reads the table's summary and what is not one account's, and replays the log after it noting, of each account's entries, only where they are. An account is loaded on its first use: its row, then its entries in the frames noted. A lookup by handle, email or reset token loads the accounts hinted at and asks the loaded ones: a hint only says where to look.log.rs:Service::openmakes noAccountbut those the service log marks, and lists nothing inrepos/. The directories of no account there, of an account whose making or deletion was cut short, are removed by a sweep once the server serves.federation.rs:listRepospages over ordinals; its cursor is the next ordinal, which a restart no longer changes.sessions.rs,oauth.rs,email.rs,identity.rs,server.rs,lifecycle.rs,preferences.rs: whatever reads an account's sessions, preferences, mail or state loads the account first; "taken" checks load the accounts hinted at.cache.rs: an account's signing key is made on first use.spec/MIGRATION.md) is one account again: its ordinal before counts no more, in memory or in a table that does not cover the deletion, and a compaction keeps what OAuth logged of it since, where it dropped everything OAuth ever logged of a DID once deleted.ops/metrics.rs:pds_accountsfrom a count kept, not a walk.crates/pds-store.
Policyhas a cap: a log is compacted by size once it is pastmax(min(checkpoint, cap), floor). No cap for accounts' logs, as before; 8 MiB for the service log, which a start replays.bench/store.
service.mjsreports the start on the checkpoint, as a server that holds the accounts starts, apart from the replay of a log no server is left with; RESULTS.md is this server's. Thestore-benchworkflow also runs on a change to the formats the benchmark writes itself, which the review of at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/spec-pds/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.pull/3n22okzmmryrf asked for.Why
spec/STORE.mdsays the time to start does not grow with the number of accounts. It did: the start replayed the service checkpoint and made everyAccount. The store benchmark measured it, and the scale run, which made 2000 accounts without passwords, could not see it.Three things were wrong, and the first two were tried alone first: each account's email was compared with every one before it, and each account's public key was derived as its entry was read. Fixing those left 11 µs an account, 1.2 s for 100000. Only reading no account at the start makes it flat, and a table read on demand is how the accounts' own checkpoints already do it.
The cap on the service log is for the same rule: a log may otherwise grow to its checkpoint's size, and a start replays it.
How it was checked
the server's start, with 100000 accounts, 1375 ms against 314. With this: all hold, each start with 100000 accounts 70 ms, the resident memory just started 27.5 MiB.createSession, with its email,AuthenticationRequired. The first version of the check asked each account by DID first, which loaded it, and passed with that bug planted: so each account is now asked another way first.store-benchworkflow on this pull): a start on the checkpoint 25 to 30 ms from 10000 accounts to 100000, where it was 383 ms to 118 s; the memory it leaves 17 MiB, where it was 32 to 219. On the Mac, 500000 accounts: 49 to 62 ms and 24 MiB.node compare.mjs --upgrade: holds, on the last release's two data directories.node compare.mjs --store --crash-every 40: 600 steps agree, 19 starts of 44 ms, 15 of them killed while the data directory was reorganized; the directory 1.06 times the live state.cargo test --workspace(347 of the server's, 23 of the store's),just quick(7 runs), andjust nightly: the crash runs (6) and the performance step, the scale run in it.an_account_deleted_moves_here_againfails, the account listed twice.listRepos' order and cursors across a compaction; the service log cut at every byte after a table, the table cut at every byte as it is written, and a checkpoint of the format before converted, cut at every byte.Shortcomings
cannot recover, when that account is loaded. Entries of an account logged after its deletion are passed over, where the start refused them.find_old), the next pull; and a metrics scrape, which sizes every account's files (at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/spec-pds/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3n22yaqiwchsq).spec/STORE.mdallows requests under way. The scale run's memory bound at 100000 accounts is wide enough to hide it; at 4000 accounts the same run fails on it: at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/spec-pds/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3n22xii2d7usqReview
The design is the module docs of
directory.rsandcompact.rs. The risk is in what a lookup sees between a table, the log noted and the accounts loaded:Directory::hinted,entries_of,Accounts::install.