lock-test.sh

application/x-shellscript

Filename: lock-test.sh
Type: application/x-shellscript
Part: 0
Message: Re: scalability bottlenecks with (many) partitions (and more)
#!/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

RESULTS=results-$(date +%s).csv

for x in $(seq 1 $REPEATS); do

	for b in master patched; do

		for l in 64 1024 8192; do

			PATH=/mnt/data/builds/$b/bin:$PATH_OLD

			echo "max_locks_per_transaction = $l" >> $DATADIR/postgresql.conf

			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 p in 0 4 32; do

				dropdb --if-exists test >> logs/pgbench-init.log 2>&1
				createdb test >> logs/pgbench-init.log 2>&1

				pgbench -i -s 1 --partitions=$p test >> logs/pgbench-init.log 2>&1
				psql test -c "vacuum analyze;" > logs/vacuum.log 2>&1

				for m in simple prepared; do

					for c in 1 4 16; 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 $l $p $m $c $tps_median $tps_average >> $RESULTS

					done

				done

			done

		done

	done

done