chadtmiller.com/monolith
An atproto PDS
0
0
A log is given room ahead, so a sync carries no change of size
Closedchadtmiller.com added 4 commits
Closed for the pull that carries this with the changes it was stacked beside: 3n25dt62arysq, "The store reads and syncs less: open files, XXH3, clean starts, room". There a log's room is made from its first frame, its file is locked while it is open, and the room is given back when the log is closed.
Claude Fable 5.2
What changes
A log is given room ahead: zeros after its frames, written by the commit that grows the file, so that the commits after it sync a file whose size does not change. Frames are written at their offsets. The first frame since a log was opened makes no room; a later one that does not fit grows the file by itself and as much again as was written since the log was opened, up to 256 KiB and to what is left before the log is compacted by size. Room is given back before a seal, when the pool closes the file, and at a start. A log ends at its last whole frame: zeros are no frame.
A log's file is locked (
flock, exclusive, not waited for) for as long as aWalholds it open to write to: frames written at offsets are not kept apart by the system as appended ones are, so a second handle on a log is an error,ResourceBusy, and writes nothing.crates/pds-store(lib.rs,generations.rs), and inpds-serverwhat reads a log's size, and the tests that kept two servers on one data directory.Why
On the runner a sync of a file that grew takes 19 ms and one of a file that did not 5 to 12 (the store benchmark, "allocated ahead" rows).
How it was checked
cargo test -p pds-store(38) and-p pds-server(362) on this branch; new: a write torn in room at every byte, zeros read as no frame, logs with no room carried on, a log has one writer.gatesworkflow passed on it, atb4d1390and at7b5a816.gatesworkflow's:main(five runs)Shortcomings
A draft, not ready:
store-benchat this branch), twice, before anything is concluded: if a log for many accounts each written once or twice is slower with room, room should begin at a third frame, or not be made at all.mainas it is now, one of the firehose's tests fails (events::tests::an_index_cut_short_is_no_index, atcache.rs:448): it keeps a second server on a data directory, as the tests fixed here did. The merge is the branchstore/log-ahead-stacked.just nightlyhave not been run on it here, as a change to how the server stores must be.Review
Not yet.