Доработать инструменты экспериментов: чередовать повторы, останавливать лестницу на первой проваленной ступени, задавать maxconn и CPU базы в сериях, записывать замер скорости хоста и контроль шума, сократить комментарии

This commit is contained in:
2026-11-04 12:39:04 +03:00
parent ce47c138e4
commit baa5995938
24 changed files with 253 additions and 240 deletions
+13 -8
View File
@@ -3,14 +3,13 @@
# The generator and the knobs the experiments vary live in compose.bench.yaml.
export COMPOSE_PATH_SEPARATOR=: COMPOSE_FILE=compose.yaml:compose.bench.yaml
# abspath prints the absolute path of an existing directory in the form the
# Docker CLI accepts for a bind mount (a Windows path under Git Bash).
# abspath prints a directory in the form the Docker CLI mounts (a Windows path
# under Git Bash).
abspath() {
(cd "$1" && (pwd -W 2>/dev/null || pwd))
}
# meta writes the header of one run: what ran, when, on which commit and
# host. Arguments: file, then key=value pairs added to the record.
# meta writes what ran, when, on which commit and host: file, then key=value.
meta() {
file=$1
shift
@@ -30,8 +29,13 @@ meta() {
} >"$file"
}
# sample_docker_stats appends the CPU and memory of every container of the
# stand to a JSON-lines file, about every two seconds, until killed.
# host_probe prints the seconds a fixed CPU loop takes in a one-CPU container:
# the same work every time, so a slow spell of the host shows in the results.
host_probe() {
docker run --rm --cpus 1 --entrypoint sh mtusi-messenger:lab3 -c 'time -p awk "BEGIN{for(i=0;i<5000000;i++)s+=i}"' 2>&1 | awk '/^real/ { print $2 }'
}
# sample_docker_stats appends the CPU and memory of every container until killed.
sample_docker_stats() {
while :; do
docker stats --no-stream --format "{\"t\":$(date +%s),\"name\":\"{{.Name}}\",\"cpu\":\"{{.CPUPerc}}\",\"mem\":\"{{.MemUsage}}\"}" \
@@ -39,8 +43,8 @@ sample_docker_stats() {
done >>"$1"
}
# sample_postgres appends, every second, the database's commit counters and
# what its active sessions are waiting for (none: running on CPU).
# sample_postgres appends, every second, the database counters and what the
# active sessions wait for ("cpu": nothing).
sample_postgres() {
while :; do
docker compose exec -T postgres psql -U messenger -d messenger -XAtq -c "
@@ -48,6 +52,7 @@ sample_postgres() {
't', extract(epoch FROM now()),
'xact_commit', xact_commit, 'xact_rollback', xact_rollback,
'tup_inserted', tup_inserted, 'blks_read', blks_read, 'blks_hit', blks_hit,
'sessions', sessions, 'sessions_abandoned', sessions_abandoned,
'active', (SELECT count(*) FROM pg_stat_activity WHERE state = 'active' AND backend_type = 'client backend' AND pid <> pg_backend_pid()),
'waits', (SELECT coalesce(json_object_agg(w, n), '{}') FROM (
SELECT coalesce(wait_event_type || ':' || wait_event, 'cpu') AS w, count(*) AS n