run-lock-test.sh
application/x-shellscript
Filename: run-lock-test.sh
Type: application/x-shellscript
Part: 3
#!/usr/bin/bash
set -e
MACHINE=$1
# number of runs for each parameter combination
REPEATS=10
# number of samples for each run
SAMPLES=60
# data directory
DATADIR=/mnt/pgdata/data-test-locks
PATH_OLD=$PATH
# initialize a cluster from scratch
killall -9 postgres || true
sleep 1
rm -Rf $DATADIR
PATH=/mnt/data/builds/master/bin:$PATH_OLD
pg_ctl -D $DATADIR init > logs/init.log 2>&1
pg_ctl -D $DATADIR -l logs/pg.log start > logs/start.log 2>&1
createdb test > logs/pgbench-init.log 2>&1
pgbench -i -s 1 --partitions=4 test >> logs/pgbench-init.log 2>&1
psql test -c "vacuum analyze;" > logs/vacuum.log 2>&1
#uncomment to test with 1024 locks
#echo 'max_locks_per_transaction = 1024' >> $DATADIR/postgresql.conf
RESULTS=results-$(date +%s).csv
for x in $(seq 1 $REPEATS); do
for b in master built-in built-in-guc; do
PATH=/mnt/data/builds/$b/bin:$PATH_OLD
pg_ctl -D $DATADIR stop > logs/debug.log 2>&1 || true
pg_ctl -D $DATADIR -l logs/pg.log start > logs/debug.log 2>&1
for m in simple prepared; do
for c in 1 4; do
pgbench -n -S -P 1 -M $m -c $c -j $c -T $SAMPLES test > logs/$m-$c-$b-$x.log 2>&1
tps_median=$(grep '^progress:' logs/$m-$c-$b-$x.log | awk '{print $4}' | sort -n | head -n $((SAMPLES/2)) | tail -n 1)
tps_average=$(grep '^tps =' logs/$m-$c-$b-$x.log | awk '{print $3}')
echo $MACHINE $x $b $m $c $tps_median $tps_average >> $RESULTS
done
done
done
done