~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

The store benchmark: reads, sizes and the firehose, RocksDB and fjall

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:spike/store
Claude Fable 5.2

What changes

The store benchmark measures what a store is chosen for, each part the server's logs and tables beside SQLite, RocksDB and fjall on the same commits at the same durability:

  • commits that look like records (a post, tree nodes, a commit, its event) in place of random bytes;
  • writes at 4, 16, 64 and 256 writers, with frames as bytes beside the server's JSON with hex, a log allocated ahead, waiters answered in turn or together, a sync that first lets the commits begun be written, and every store with no sync at all;
  • a firehose replayed from one log (with SHA-256, CRC32C, XXH3-64, BLAKE3 or no check), from a table of events in each other store, and from the logs for each account;
  • reads: a record, a listing, the first read of an account, 16 threads, memory with accounts open; tables read with their files held open, with 4 KiB blocks, and with other checks;
  • size on disk, blocks compressed or not, every record rewritten, and what RocksDB writes for each byte given.

bench/store/RESULTS.md has the runner's numbers and a Mac's. The store-bench workflow installs libclang, which RocksDB's bindings need. Nothing of the server changes.

Why

To see from numbers that can be run again whether the server's own store is worth keeping, and what it loses to: the benchmark before measured writes alone, against SQLite alone. What it says, on the runner: no SQLite layout is faster than the server's logs at the same durability; RocksDB tuned is level with them or a little ahead; and what the server's store loses is in how it reads and syncs (a file opened for each block, 16 KiB blocks, SHA-256, one lock on the block cache, a log that grows under each sync, JSON frames), each of which has a row saying what it is worth.

How it was checked

./run.sh whole on a Mac (16 minutes) and by the store-bench workflow on the runner at each push; cargo fmt --check and cargo clippy --release -- -D warnings clean in bench/store. RESULTS.md's tables are the runner's output at 82bf3b3 and the Mac's at 41ca6ca, and each sentence under them was checked against those rows.

Shortcomings

  • Every read is from the operating system's cache: nothing measures a read from a cold disk.
  • The rows "this benchmark's" reader and log are prototypes in the benchmark, not the server's code: the table reader's block map has no size limit, so its 16-thread rows are a ceiling.
  • The runner's write rows move from run to run by up to a half at 4 and 16 writers; RESULTS.md says so and gives the run before.
  • RocksDB needs a build flag for F_FULLFSYNC on macOS, which bench/store/.cargo/config.toml gives; fjall has no shared sync of its own, so its strongest row is one the benchmark builds over it.
  • The first build of RocksDB adds about four minutes to the workflow.

Review

Whether each part is fair to SQLite, RocksDB and fjall, as bench/store/README.md says it is; and whether RESULTS.md says only what its tables show.

Asked for changes

The pull widens bench/store from write-only against SQLite into a benchmark with realistic commits, more writer counts, firehose replay, reads and sizes, across the server's logs and tables, SQLite, RocksDB and fjall. It touches no server code, spec or harness, and it adds no atproto or MCP crates. The pds-store items it uses (frame_of, HEADER) exist on the base branch.

Change needed: docs/guide/comparing.md ("The store benchmark", around line 236) still describes the old benchmark. It says "its logs beside SQLite under the same commits, a log replayed, and the server's start and memory". The review rules ask that a change to how something is checked updates its guide in docs/guide/. The section should now name RocksDB and fjall, the reads, firehose and size parts, the libclang requirement for building RocksDB, and the macOS F_FULLFSYNC build flag from .cargo/config.toml. The guide's just store-bench command should still work, but please confirm that the recipe passes the new arguments.

Checks: the store-bench run was still running at this head when I looked, so I have no result for it. gates and docs were skipped by their path filters. The docs skip means nothing builds the docs for this pull.

Not read: I did not read write.rs, reads.rs, firehose.rs, size.rs, tables.rs, data.rs, README.md or RESULTS.md line by line. I cannot vouch for the fairness of those parts, or for whether RESULTS.md says only what its tables show. Of the files I did read:

  • I found no loosened or unfair setup in rocks.rs and fj.rs. Both use the same keys and values, 4 KiB blocks, XXH3 and bloom filters. fjall's comment says its filters are on its first level only.
  • The Check variants in check.rs all hash the same bytes.
bench/store/run.shline 71
node service.mjs "$@"
else
echo "Left out: there is no server at $pds (\`just build\`)."
fi
review.knotless.dev

docs/guide/comparing.md still says the store benchmark covers only the logs beside SQLite, a log replayed and the service log. Update it for the parts and stores added here.

Approved

My earlier review asked for docs/guide/comparing.md to describe the new benchmark. That is done. The section now names RocksDB and fjall, the writer counts, the firehose, read and size parts, the libclang requirement, and the macOS F_FULLFSYNC flag from .cargo/config.toml. The Justfile comment and the workflow header were updated to match. store-bench still passes {{args}} through to run.sh, as I asked you to confirm.

I still have not read write.rs, reads.rs, firehose.rs, size.rs, tables.rs, data.rs, README.md or RESULTS.md line by line. I can't vouch for the fairness of those parts, or for whether RESULTS.md says only what its tables show. That is the review the author asked for, so a reviewer should check it. Nothing in the diff since my last review breaks what I did read.

Merged as 2eb4a9a