run.sh
application/x-shellscript
#!/usr/bin/env bash
set -e
ulimit -n $((32*1024))
PATH_OLD=$PATH
CLIENTS=128
STEP=8
ROWS=1442000
DATADIR=/mnt/data/pg
RUNS=5
DURATION=60
TS=$(date +%Y%m%d-%H%M%S)
killall -9 postgres || true
rm -f $DATADIR/postmaster.pid
sleep 1
mkdir $TS
mkdir $TS/scripts
rm -f pgbench_log.*
for p in $(seq 1 $CLIENTS); do
echo "SELECT * FROM t_${p} OFFSET 1000000000" >> $TS/scripts/$p.sql
done
for r in $(seq 1 $RUNS); do
for p in 60 75 90 110; do
for c in $(seq 8 $STEP $CLIENTS | sort -R); do
SCRIPTS=""
for i in $(seq 1 $c); do
SCRIPTS="$SCRIPTS -f $TS/scripts/${i}.sql"
done
for b in master numa numa-16; do
sb=$((c*1024*p/100))
cp postgresql-$b.conf $DATADIR/postgresql.conf
echo "shared_buffers = '${sb}MB'" >> $DATADIR/postgresql.conf
export PATH=/home/tomas/builds/$b/bin:$PATH_OLD
pg_ctl -D $DATADIR -l pg.log start
# warmup
pgbench -n -M prepared -c $c -l $SCRIPTS -T $DURATION -P 1 test > $TS/$r-$p-$c-$b.warmup.log 2>&1
mv pgbench_log.* $TS/$r-$p-$c-$b.warmup.pgbench.log
# benchmark
pgbench -n -M prepared -c $c -l $SCRIPTS -T $DURATION -P 1 test > $TS/$r-$p-$c-$b.log 2>&1
mv pgbench_log.* $TS/$r-$p-$c-$b.pgbench.log
pg_ctl -D $DATADIR -l pg.log stop
tps=$(grep '^tps = ' $TS/$r-$p-$c-$b.log | awk '{print $3}')
tps_05=$(grep progress $TS/$r-$p-$c-$b.log | awk '{print $4}' | sort -n | head -n 3 | tail -n 1)
tps_25=$(grep progress $TS/$r-$p-$c-$b.log | awk '{print $4}' | sort -n | head -n 15 | tail -n 1)
tps_50=$(grep progress $TS/$r-$p-$c-$b.log | awk '{print $4}' | sort -n | head -n 30 | tail -n 1)
tps_75=$(grep progress $TS/$r-$p-$c-$b.log | awk '{print $4}' | sort -n | head -n 45 | tail -n 1)
tps_95=$(grep progress $TS/$r-$p-$c-$b.log | awk '{print $4}' | sort -n | head -n 57 | tail -n 1)
echo $r $p $c $sb $b $tps $tps_05 $tps_25 $tps_50 $tps_75 $tps_95 >> $TS/results.csv
done
done
done
done