diff --git a/scripts/bench/lib.sh b/scripts/bench/lib.sh index df5e37fc..4ddbe67b 100644 --- a/scripts/bench/lib.sh +++ b/scripts/bench/lib.sh @@ -38,6 +38,15 @@ host_probe() { -c 'time -p awk "BEGIN{for(i=0;i<5000000;i++)s+=i}"' 2>&1 | awk '/^real/ { print $2 }' } +# state_log keeps from `compose logs` (stdin) what explains a run: the +# balancer's server state changes and the replicas' start and stop. An +# overloaded run logs every failed request, gigabytes over a series; those +# lines are only counted. +state_log() { + awk '/is DOWN|is UP|UP\/READY|maintenance|"msg":"(starting|shutdown started|shutdown completed)"/ { print; next } + { dropped++ } END { printf "# %d other lines dropped\n", dropped }' +} + # sample_docker_stats appends the CPU and memory of every container until killed. sample_docker_stats() { while :; do diff --git a/scripts/bench/plot.py b/scripts/bench/plot.py index eb4017d6..5258974c 100755 --- a/scripts/bench/plot.py +++ b/scripts/bench/plot.py @@ -20,6 +20,7 @@ under 1 % errors, p99 of successful requests within 500 ms). Charts show the median of the repeats; a hollow marker means the generator fell behind. """ import csv +import gzip import json import pathlib import statistics @@ -40,10 +41,15 @@ COMPONENTS = ("api", "lb", "postgres", "valkey", "loadgen") def read_jsonl(path): - if not path.exists(): + packed = path.with_name(path.name + ".gz") + if packed.exists(): + text = gzip.decompress(packed.read_bytes()).decode("utf-8") + elif path.exists(): + text = path.read_text(encoding="utf-8") + else: return [] rows = [] - for line in path.read_text(encoding="utf-8").splitlines(): + for line in text.splitlines(): line = line.strip() if line: try: diff --git a/scripts/bench/run-series.sh b/scripts/bench/run-series.sh index f8b8de71..f291fa77 100755 --- a/scripts/bench/run-series.sh +++ b/scripts/bench/run-series.sh @@ -58,7 +58,8 @@ run_config() { 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 + docker compose logs --no-color --timestamps lb api 2>&1 | state_log >"$dir/compose.log" + gzip -9 "$dir"/*.jsonl grep '^step' "$dir/loadgen.log" || true }