-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtpch_runall_seq
executable file
·63 lines (56 loc) · 1.48 KB
/
tpch_runall_seq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
PERFDATADIR=perfdata
if [ $# -gt 0 ]; then
PERFDATADIR="$PERFDATADIR-$1"
fi
PGDATADIR=/dev/shm/$USER/pgdata
PGPORT=5442
BASEDIR=$(cd "$(dirname $0)"; pwd)
cd $BASEDIR
PGPORT_PROCLIST="$(lsof -i tcp:$PGPORT | tail -n +2 | awk '{print $2}')"
if [[ $(echo "$PGPORT_PROCLIST" | wc -w) -gt 0 ]];
then
echo "The following processes have taken port $PGPORT"
echo "Please terminate them before running this script"
echo
for p in $PGPORT_PROCLIST;
do
ps -o pid,cmd $p
done
exit -1
fi
#
# Check if a Postgres server is running in the same directory
#
if pg_ctl status -D $PGDATADIR | grep "server is running" -q; then
echo "A Postgres server is already running in the selected directory. Exiting."
pg_ctl status -D $PGDATADIR
exit -2
fi
for i in $(seq 1 22);
do
ii=$(printf "%02d" $i)
dir="$PERFDATADIR/q${ii}"
mkdir -p $dir
cd $dir
perf record -g postgres -D $PGDATADIR -p $PGPORT &
PGPID=$!
while ! pg_ctl status -D $PGDATADIR | grep "server is running" -q; do
echo "Waiting for the Postgres server to start"
sleep 1
done
f="queries/q$ii.sql"
echo "Running query: $i"
/usr/bin/time -f '%e\n%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k'\
-o query_exec_seconds.txt \
psql -p $PGPORT tpch <$BASEDIR/$f
pg_ctl stop -D $PGDATADIR
cgf="../q${ii}-callgraph.pdf"
echo "Creating the call graph: $cgf"
perf script | python $BASEDIR/gprof2dot.py -f perf | dot -Tpdf -o $cgf &
cd - >/dev/null
done
for p in $(jobs -p);
do
wait $p
done