Skip to content

Commit 698ab25

Browse files
committed
Merge pull request #88 from nchammas/timing-info
[SPARK-5125] Time major blocks of code in setup.sh
2 parents eefbe90 + db7622c commit 698ab25

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

setup.sh

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#!/bin/bash
22

3-
sudo yum install -y pssh
3+
sudo yum install -y -q pssh
4+
5+
# usage: echo_time_diff name start_time end_time
6+
echo_time_diff () {
7+
local format='%Hh %Mm %Ss'
8+
9+
local diff_secs="$(($3-$2))"
10+
echo "[timing] $1: " "$(date -u -d@"$diff_secs" +"$format")"
11+
}
412

513
# Make sure we are in the spark-ec2 directory
614
pushd /root/spark-ec2 > /dev/null
@@ -45,20 +53,26 @@ echo "Setting executable permissions on scripts..."
4553
find . -regex "^.+.\(sh\|py\)" | xargs chmod a+x
4654

4755
echo "RSYNC'ing /root/spark-ec2 to other cluster nodes..."
56+
rsync_start_time="$(date +'%s')"
4857
for node in $SLAVES $OTHER_MASTERS; do
4958
echo $node
5059
rsync -e "ssh $SSH_OPTS" -az /root/spark-ec2 $node:/root &
5160
scp $SSH_OPTS ~/.ssh/id_rsa $node:.ssh &
5261
sleep 0.1
5362
done
5463
wait
64+
rsync_end_time="$(date +'%s')"
65+
echo_time_diff "rsync /root/spark-ec2" "$rsync_start_time" "$rsync_end_time"
5566

5667
echo "Running setup-slave on all cluster nodes to mount filesystems, etc..."
68+
setup_slave_start_time="$(date +'%s')"
5769
pssh --inline \
5870
--host "$MASTERS $SLAVES" \
5971
--user root \
6072
--extra-args "-t -t $SSH_OPTS" \
6173
"spark-ec2/setup-slave.sh"
74+
setup_slave_end_time="$(date +'%s')"
75+
echo_time_diff "setup-slave" "$setup_slave_start_time" "$setup_slave_end_time"
6276

6377
# Always include 'scala' module if it's not defined as a work around
6478
# for older versions of the scripts.
@@ -69,9 +83,12 @@ fi
6983
# Install / Init module
7084
for module in $MODULES; do
7185
echo "Initializing $module"
86+
module_init_start_time="$(date +'%s')"
7287
if [[ -e $module/init.sh ]]; then
7388
source $module/init.sh
7489
fi
90+
module_init_end_time="$(date +'%s')"
91+
echo_time_diff "$module init" "$module_init_start_time" "$module_init_end_time"
7592
cd /root/spark-ec2 # guard against init.sh changing the cwd
7693
done
7794

@@ -88,8 +105,11 @@ chmod u+x /root/spark/conf/spark-env.sh
88105
# Setup each module
89106
for module in $MODULES; do
90107
echo "Setting up $module"
108+
module_setup_start_time="$(date +'%s')"
91109
source ./$module/setup.sh
92110
sleep 0.1
111+
module_setup_end_time="$(date +'%s')"
112+
echo_time_diff "$module setup" "$module_setup_start_time" "$module_setup_end_time"
93113
cd /root/spark-ec2 # guard against setup.sh changing the cwd
94114
done
95115

0 commit comments

Comments
 (0)