This repository has been archived by the owner on Apr 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tpch_runone
executable file
·72 lines (65 loc) · 1.81 KB
/
tpch_runone
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
63
64
65
66
67
68
69
70
71
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Please provide the number of the query you wish to run, e.g.:"
echo "$0 6"
exit 1
fi
PERFDATADIR=perfdata
PGDATADIR=$HOME/pg92/pgdata
PGPORT=5442
SCRIPTDIR=$(dirname $0)
SCRIPTDIR=$(cd "$SCRIPTDIR"; pwd)
PIN_EXE=$SCRIPTDIR/pin/pin
PIN_NVRAMSIM=$SCRIPTDIR/obj-intel64/nvramsim.so
cd "$SCRIPTDIR"
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
ii=$(printf "%02d" $1)
dir="$PERFDATADIR/q${ii}"
mkdir -p $dir
cd $dir
### get statistics e.g. IPC, cache hits/misses
# perf stat -B --log-fd 2 -- postgres -D $PGDATADIR -p $PGPORT &
### for callgraph
# perf record -g postgres -D $PGDATADIR -p $PGPORT &
### run under pin
$PIN_EXE -follow_execv -mt -t "$PIN_NVRAMSIM" -- postgres -D $PGDATADIR -p $PGPORT &
pg_ctl -D $PGDATADIR status
while ! pg_ctl status -D $PGDATADIR | grep "server is running" -q; do
echo "Waiting for the Postgres server to start"
pg_ctl -D $PGDATADIR status
sleep 1
done
pg_ctl -D $PGDATADIR status
sleep 4
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 <"$SCRIPTDIR/$f"
echo "Asking Pg server to stop"
pg_ctl stop -D $PGDATADIR
echo "Pg server stopped"
cd - >/dev/null
for p in $(jobs -p);
do
wait $p
done