chadtmiller.com/monolith
An atproto PDS
0
0
#!/bin/sh
# The store benchmark, whole (README.md): Markdown on stdout, to read or to
# put in RESULTS.md. The server is ../../target/release/pds, built already
# (`just build`), or PDS_BIN: without one, the last part is left out; CARGO
# names the cargo that builds the rest (`cargo` by default); arguments are
# service.mjs's, its counts of accounts. With BENCH_SMALL set every part
# runs at a size that shows only that it builds and runs, in a minute or
# two: its numbers say nothing.
set -eu
cd "$(dirname "$0")"
cargo=${CARGO:-cargo}
dir=${BENCH_DIR:-$PWD/target/data}
mkdir -p "$dir"
$cargo build --release >&2
bench=target/release/store-bench
pds=${PDS_BIN:-../../target/release/pds}
echo "## Machine"
echo
echo "- $(uname -srm), $(getconf _NPROCESSORS_ONLN) cores, load $(uptime | sed 's/.*load averages\{0,1\}: *//')"
if command -v findmnt >/dev/null 2>&1; then
echo "- its files on: $(findmnt -no SOURCE,FSTYPE,OPTIONS -T "$dir")"
else
echo "- its files on: $(df -P "$dir" | awk 'NR==2 {print $1}')"
fi
echo "- $($cargo --version); node $(node --version)"
echo "- the repository at $(git rev-parse --short HEAD 2>/dev/null || echo 'a commit git cannot name here')"
echo
# Each part's size: the sizes RESULTS.md's numbers are of, or small ones,
# and then one count of writers a part.
if [ -n "${BENCH_SMALL:-}" ]; then
writes="100:16" spreads="100:16:40" unsynced="2000:16:40"
logs="8 16" events=5000 accounts=200 records=100 sized=20 ladder="40 5"
[ $# -gt 0 ] || set -- 1000
# A journal's checkpoints, 16 MiB of it apart, would never come round.
export BENCH_JOURNAL_CHECKPOINT=16384
else
writes="1500:16 1500:4"
spreads="1500:4:40 1500:16:40 2048:64:2000 4096:256:2000"
unsynced="40000:16:40 40000:256:2000"
logs="64 512" events=200000 accounts=2000 records=500 sized=200 ladder="40 100"
fi
# A part run once for each of its sizes, `:` between a size's numbers.
each() {
part=$1
shift
for size in "$@"; do
echo
$bench "$part" $(echo "$size" | tr : ' ')
done
}
echo
echo "## Writes"
each write $writes
echo
echo "## Writes of realistic commits, by the number of writers"
each spread $spreads
echo
echo "## Writes with no sync: not durable"
each unsynced $unsynced
echo
echo "## A log replayed"
echo
$bench scan $logs
echo
echo "## The firehose replayed"
echo
$bench firehose $events $accounts
echo
echo "## Reads"
echo
$bench reads $accounts $records
echo
echo "## A record read, a stage at a time"
echo
$bench ladder $ladder
echo
if [ -x "$pds" ]; then
node ladder.mjs $ladder
else
echo "Stage 5 left out: there is no server at $pds (\`just build\`)."
fi
echo
echo "## Size and compression"
echo
$bench size $sized $records
echo
echo "## The service log by the number of accounts"
echo
if [ -x "$pds" ]; then
node service.mjs "$@"
else
echo "Left out: there is no server at $pds (\`just build\`)."
fi