Доработать инструменты экспериментов: чередовать повторы, останавливать лестницу на первой проваленной ступени, задавать maxconn и CPU базы в сериях, записывать замер скорости хоста и контроль шума, сократить комментарии
This commit is contained in:
+65
-44
@@ -1,61 +1,82 @@
|
||||
#!/bin/sh
|
||||
# Track 1, the cost of scaling: runs every configuration of one series file,
|
||||
# each repeated, each on a fresh stand (empty volumes, same seed), under the
|
||||
# same grid of offered rates.
|
||||
# Track 1: every configuration of the given series files, each on a fresh
|
||||
# stand, under one grid of offered rates. Repeats are interleaved (repeat 1
|
||||
# of every configuration, then repeat 2), so a slow spell of the host does not
|
||||
# fall on one configuration.
|
||||
#
|
||||
# RATES=200,400,800 sh scripts/bench/run-series.sh scripts/bench/series/A.conf [repeats]
|
||||
# RATES=400,800,1200 sh scripts/bench/run-series.sh scripts/bench/series/A.conf [...]
|
||||
#
|
||||
# Environment: RATES (required), STEP (30s), WARMUP (30s), OUT (results root,
|
||||
# default evidence/track1/raw). Fixed for every configuration: HAProxy
|
||||
# LB_CPUS (1.0), PostgreSQL PG_CPUS/PG_MEMORY (1.0/1G), Valkey 0.5 CPU and the
|
||||
# generator LOADGEN_CPUS (1.5). Results per run:
|
||||
# <OUT>/<series>/<config>/rep<k>/{meta.json,steps.json,seconds.csv,
|
||||
# metrics.jsonl,docker-stats.jsonl,postgres.jsonl,loadgen.log}
|
||||
# The stand is removed at the end; `make up` brings the normal one back.
|
||||
# Environment: RATES (required), REPEATS (3), STEP (30s), WARMUP (30s),
|
||||
# STOP_ON_FAIL (1: end a ladder at its first failing step), OUT
|
||||
# (evidence/track1/raw). Results: <OUT>/<series>/<config>/rep<k>/.
|
||||
set -eu
|
||||
cd "$(dirname "$0")/../.."
|
||||
. scripts/bench/lib.sh
|
||||
|
||||
series=${1:?usage: run-series.sh <series.conf> [repeats]}
|
||||
repeats=${2:-3}
|
||||
: "${RATES:?set RATES, the offered requests per second of the steps, e.g. 200,400,800}"
|
||||
[ $# -gt 0 ] || { echo "usage: RATES=... run-series.sh <series.conf>..." >&2; exit 2; }
|
||||
: "${RATES:?set RATES, the offered requests per second of the steps, e.g. 400,800,1200}"
|
||||
repeats=${REPEATS:-3}
|
||||
step=${STEP:-30s}
|
||||
warmup=${WARMUP:-30s}
|
||||
root=${OUT:-evidence/track1/raw}/$(basename "$series" .conf)
|
||||
out=${OUT:-evidence/track1/raw}
|
||||
stop=
|
||||
[ "${STOP_ON_FAIL:-1}" = 1 ] && stop=-stop-on-fail
|
||||
|
||||
export APP_DEBUG_ADDR=:9090 LB_QUIET=1
|
||||
export LB_CPUS=${LB_CPUS:-1.0} PG_CPUS=${PG_CPUS:-1.0} PG_MEMORY=${PG_MEMORY:-1G} LOADGEN_CPUS=${LOADGEN_CPUS:-1.5}
|
||||
# Fixed for every configuration; the API, its pool, maxconn and the database
|
||||
# CPU come from the series line.
|
||||
export LB_QUIET=1 LB_CPUS=1.0 PG_MEMORY=1G LOADGEN_CPUS=2.0
|
||||
export MSYS_NO_PATHCONV=1
|
||||
|
||||
grep -v '^#' "$series" | while read -r name replicas cpus memory gomemlimit pool; do
|
||||
[ -n "$name" ] || continue
|
||||
for rep in $(seq 1 "$repeats"); do
|
||||
dir=$root/$name/rep$rep
|
||||
rm -rf "$dir"
|
||||
mkdir -p "$dir"
|
||||
echo "== $name rep $rep: $replicas x $cpus CPU / $memory, pool $pool, rates $RATES"
|
||||
export API_REPLICAS=$replicas API_CPUS=$cpus API_MEMORY=$memory API_GOMEMLIMIT=$gomemlimit DB_MAX_CONNS=$pool
|
||||
# One series line: name replicas cpus memory gomemlimit pool maxconn pg_cpus.
|
||||
run_config() {
|
||||
series=$1 rep=$2 name=$3 replicas=$4 cpus=$5 memory=$6 gomemlimit=$7 pool=$8 maxconn=$9 pg_cpus=${10}
|
||||
dir=$out/$series/$name/rep$rep
|
||||
rm -rf "$dir"
|
||||
mkdir -p "$dir"
|
||||
echo "== $series/$name rep $rep: $replicas x $cpus CPU / $memory, pool $pool, maxconn $maxconn, PostgreSQL $pg_cpus CPU"
|
||||
export API_REPLICAS=$replicas API_CPUS=$cpus API_MEMORY=$memory API_GOMEMLIMIT=$gomemlimit \
|
||||
DB_MAX_CONNS=$pool API_MAXCONN=$maxconn PG_CPUS=$pg_cpus
|
||||
|
||||
docker compose down -v --remove-orphans >/dev/null 2>&1
|
||||
docker compose up -d --build --wait >/dev/null 2>&1
|
||||
meta "$dir/meta.json" "series=$(basename "$series" .conf)" "config=$name" "repeat=$rep" \
|
||||
"api_replicas=$replicas" "api_cpus=$cpus" "api_memory=$memory" "gomemlimit=$gomemlimit" "db_max_conns=$pool" \
|
||||
"lb_cpus=$LB_CPUS" "pg_cpus=$PG_CPUS" "pg_memory=$PG_MEMORY" "loadgen_cpus=$LOADGEN_CPUS" \
|
||||
"rates=$RATES" "step=$step" "warmup=$warmup"
|
||||
docker compose down -v --remove-orphans >/dev/null 2>&1
|
||||
if ! docker compose up -d --build --wait >"$dir/up.log" 2>&1; then
|
||||
echo " the stand did not start, see $dir/up.log" >&2
|
||||
exit 1
|
||||
fi
|
||||
meta "$dir/meta.json" "series=$series" "config=$name" "repeat=$rep" \
|
||||
"api_replicas=$replicas" "api_cpus=$cpus" "api_memory=$memory" "gomemlimit=$gomemlimit" \
|
||||
"db_max_conns=$pool" "api_maxconn=$maxconn" "pg_cpus=$pg_cpus" "pg_memory=$PG_MEMORY" \
|
||||
"lb_cpus=$LB_CPUS" "loadgen_cpus=$LOADGEN_CPUS" "rates=$RATES" "step=$step" "warmup=$warmup" \
|
||||
"stop_on_fail=${STOP_ON_FAIL:-1}" "host_probe_s=$(host_probe)"
|
||||
|
||||
sample_docker_stats "$dir/docker-stats.jsonl" &
|
||||
stats=$!
|
||||
sample_postgres "$dir/postgres.jsonl" &
|
||||
pg=$!
|
||||
# stdin is closed: `compose run` is interactive by default and would
|
||||
# otherwise read the rest of the series file this loop is reading.
|
||||
BENCH_OUT=$(abspath "$dir") docker compose --profile bench run --rm loadgen bench \
|
||||
-rates "$RATES" -step "$step" -warmup "$warmup" -scrape >"$dir/loadgen.log" 2>&1 </dev/null ||
|
||||
echo " loadgen failed, see $dir/loadgen.log"
|
||||
kill "$stats" "$pg" 2>/dev/null || true
|
||||
wait "$stats" "$pg" 2>/dev/null || true
|
||||
cat "$dir/loadgen.log" | grep '^step' || true
|
||||
sample_docker_stats "$dir/docker-stats.jsonl" &
|
||||
stats=$!
|
||||
sample_postgres "$dir/postgres.jsonl" &
|
||||
pg=$!
|
||||
# stdin closed: `compose run` would otherwise read it.
|
||||
BENCH_OUT=$(abspath "$dir") docker compose --profile bench run --rm loadgen bench \
|
||||
-rates "$RATES" -step "$step" -warmup "$warmup" -scrape $stop >"$dir/loadgen.log" 2>&1 </dev/null ||
|
||||
echo " loadgen failed, see $dir/loadgen.log"
|
||||
kill "$stats" "$pg" 2>/dev/null || true
|
||||
wait "$stats" "$pg" 2>/dev/null || true
|
||||
docker compose logs --no-color --timestamps lb api >"$dir/compose.log" 2>&1
|
||||
grep '^step' "$dir/loadgen.log" || true
|
||||
}
|
||||
|
||||
docker compose --profile bench build loadgen >/dev/null
|
||||
default_ifs=$IFS
|
||||
newline='
|
||||
'
|
||||
for rep in $(seq 1 "$repeats"); do
|
||||
for conf in "$@"; do
|
||||
lines=$(grep -v '^#' "$conf" | sed '/^[[:space:]]*$/d')
|
||||
IFS=$newline
|
||||
for line in $lines; do
|
||||
IFS=$default_ifs
|
||||
# shellcheck disable=SC2086 # the line splits into the fields
|
||||
run_config "$(basename "$conf" .conf)" "$rep" $line
|
||||
done
|
||||
IFS=$default_ifs
|
||||
done
|
||||
done
|
||||
docker compose down -v --remove-orphans >/dev/null 2>&1
|
||||
echo "results in $root"
|
||||
echo "results in $out"
|
||||
|
||||
Reference in New Issue
Block a user