crates/storage-git-gix/parked-gix/.nornir/bench/affinity-seed.sh
#!/usr/bin/env bash
# Push nornir in 12 increments so the served repository is 12 packs, not one.
set -euo pipefail
B=${TP_BINARY:?set TP_BINARY to the gunnar under test}
ROOT=${TP_ROOT:-/home/rickard/scratch/gunnar-tp}
DATA=$ROOT/data
SRC=${TP_SRC:-/home/rickard/git/nornir}
PORT=18899
TOK=$(cat "$ROOT/token")
URL="http://bencher:$TOK@127.0.0.1:$PORT/bench/conc.git"
"$B" --data-root "$DATA" serve --http-bind 127.0.0.1:$PORT \
--http-allow-cleartext-credentials --no-grpc --ssh-bind 127.0.0.1:12299 \
> "$ROOT/seed-server.log" 2>&1 &
SPID=$!
for i in $(seq 1 60); do
curl -fsS -o /dev/null "http://127.0.0.1:$PORT/bench/conc.git/info/refs?service=git-upload-pack" --user "bencher:$TOK" && break
sleep 0.5
done
rm -rf "$ROOT/seed"
git clone -q --bare "$SRC/.git" "$ROOT/seed"
cd "$ROOT/seed"
TIP=$(git rev-parse HEAD)
N=$(git rev-list --count HEAD)
echo "source: $N commits on HEAD, tip $TIP"
# 12 increasing prefixes of history, each its own push -> its own pack.
for k in $(seq 1 12); do
SKIP=$(( N - (N * k / 12) ))
REV=$(git rev-list HEAD | sed -n "$((SKIP+1))p")
[ -z "$REV" ] && REV=$TIP
git push -q --force "$URL" "$REV:refs/heads/main" || { echo "FATAL: push $k failed" >&2; kill $SPID; exit 1; }
printf 'push %2d -> %s\n' "$k" "${REV:0:12}"
done
# Every other ref, in one last push, so ls-remote has something to say.
git push -q --force "$URL" 'refs/heads/*:refs/heads/*' 'refs/tags/*:refs/tags/*' || true
kill $SPID 2>/dev/null || true
wait $SPID 2>/dev/null || true
echo "--- served repository:"
git --git-dir="$DATA/repos/bench/conc.git" count-objects -v
ls "$DATA/repos/bench/conc.git/objects/pack" | grep -c '\.pack$' | xargs echo "packs:"
ls "$DATA/repos/bench/conc.git/objects/pack" | grep -c '\.bitmap$' | xargs echo "bitmaps:"