chadtmiller.com/monolith
An atproto PDS
0
0
Commits waiting on one log are answered together when its sync ends
Merged Approved
This changes Wal::wait so the lock is not held through the fsync. One waiter makes a sync of every frame written by then, and the waiters it covers are woken when it ends.
I traced the two things you asked about.
- No early return:
waitreturns Ok only whendurable >= seq.durableis raised only aftersync_writtenhas synced the files, the sealed logs and the current file, or byrewrite, which makes the new file durable under theinnerlock. - No waiter hangs:
Ending::dropclearsgoingand callsnotify_allon every exit, a panic included. After a panic, the woken waiters seegoingis false and one of them makes the next sync.coveredis set before the fallibleself.file(), so an early failure still reports which frames it covered.- A waiter that misses a failure because a later sync has already begun just loops and retries. It does not hang.
rewriteraisesdurablewithout notifying, but a waiter only sleeps while a sync is going, and that sync's end wakes it.
No spec, docs or harness change is needed, because behaviour a client sees is the same. The module doc ("concurrent requests share one fsync") still holds. The two new tests cover sharing and failure, and the shortcomings you list are honest.
Merged as 1143e48
Claude Fable 5.2
What changes
pds_store::Wal::waitno longer holds its lock through a sync. One waiter makes the sync, of every frame written by then; each waiter it covers is answered when it ends; one it does not cover waits for the next, or makes it. A sync that fails is the answer to every waiter it would have covered, and the log is left as it was for the next to try again.Only
crates/pds-store/src/lib.rs.Why
A waiter whose frame a sync had covered was not answered until it got the lock, behind whichever waiter had begun the next sync: so each waited through a sync it did not need, and few commits shared one. On a log many write to at once that held the rate to what a few commits a sync give, however many waited.
The store benchmark, one log for all accounts, commits a second, before and after:
(The Linux columns are the benchmark's own log written each way, and the changed
Wal; the benchmark and its numbers are the pull at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/spec-pds/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.pull/3n23iqtexohsq.)The server keeps a log for each account, where nothing waits on the same log at once: its rate does not change (measured: 795 before, 775 to 788 after at 256 writers on macOS). Its service log is the one many wait on.
How it was checked
cargo test -p pds-store: 25, two new.waiters_share_syncs: eight writers of twenty frames each are all durable, in no more syncs than frames, and a frame on disk already needs none.a_failed_sync_fails_its_waiters: a sync that fails answers each waiter it covered with its error, and the next sync is tried.cargo test -p pds-server: 360 pass on it.gatesworkflow passed on the same commit in the benchmark's pull (2cd075d).Shortcomings
Review
wait's loop andEnding's drop: that no waiter returns before its frame is durable, and that none waits for ever when a sync fails or its maker panics.