quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nav...@apache.org
Subject [1/2] incubator-quickstep git commit: Add trap. Clean up usage notes.
Date Sun, 12 Jun 2016 20:04:58 GMT
Repository: incubator-quickstep
Updated Branches:
  refs/heads/build_script 93929f092 -> 32f51127d


Add trap. Clean up usage notes.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/7983a4a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/7983a4a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/7983a4a6

Branch: refs/heads/build_script
Commit: 7983a4a63af4b2d070aa9105b364fe2a351576e7
Parents: 93929f0
Author: Navneet <nav@cs.wisc.edu>
Authored: Sun Jun 12 14:45:14 2016 -0500
Committer: Navneet <nav@cs.wisc.edu>
Committed: Sun Jun 12 14:45:14 2016 -0500

----------------------------------------------------------------------
 build/profile_build.sh | 109 ++++++++++++++++++++++++++++----------------
 1 file changed, 69 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/7983a4a6/build/profile_build.sh
----------------------------------------------------------------------
diff --git a/build/profile_build.sh b/build/profile_build.sh
index 94631fc..369f934 100755
--- a/build/profile_build.sh
+++ b/build/profile_build.sh
@@ -11,55 +11,84 @@
 # - vmstat and mpstat 
 # sudo apt-get install -y sysstat
 #
-# Usage: ./profile_build.sh [num_parallel_jobs]
-# The number of parallel make jobs can be passed as argument to this script.
-# By default, it is the number of (virtual) CPUs on the machine (nproc).
-# Set the CMake flags you want to use below.
-#
+# Usage: ./profile_build.sh
+# Set the CMake and make command you want to use below.
+# By default, the number of parallel make jobs is equal to the number of
+# (virtual) CPUs on the machine (nproc).
 # If CMakeCache.txt is detected, the script skips cmake and runs make only.
+
+#   Copyright 2011-2015 Quickstep Technologies LLC.
+#   Copyright 2015-2016 Pivotal Software, Inc.
+#   Copyright 2016, Quickstep Research Group, Computer Sciences Department,
+#     University of Wisconsin—Madison.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
 #
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
 
-NUM_JOBS=`nproc`
-if [[ "$1" != "" ]]; then 
-    NUM_JOBS=$1
-fi
+set -e
 
-echo "Starting build in " `pwd`  >> build.log
-echo 
+CMAKE_COMMAND="cmake \
+-D BUILD_SHARED_LIBS=On \
+-D USE_TCMALLOC=0 \
+-D CMAKE_BUILD_TYPE=Debug \
+.. "
+MAKE_COMMAND="make VERBOSE=1 -j `nproc`"
 
 # Continuously dump memory usage and cpu load info to files for later analysis
-rm -f stats_*.txt
-vmstat -SM 3 | ts "%.s (%H:%M:%S)" > stats_mem.txt 3>&1 &
-PID_vmstat=$!
-mpstat 3 | ts "%.s (%H:%M:%S)" > stats_cpu.txt 2>&1  &
-PID_mpstat=$!
+function start_stat_collectors {
+  rm -f stats_*.txt
+  vmstat -SM 3 | ts "%.s (%H:%M:%S)" > stats_mem.txt 3>&1 &
+  PID_vmstat=$!
+  mpstat 3 | ts "%.s (%H:%M:%S)" > stats_cpu.txt 2>&1  &
+  PID_mpstat=$!
+}
 
-START_TIME=`date +"%s"`
-if [[ ! -f CMakeCache.txt ]]; then 
-  CMAKE_COMMAND="cmake -D BUILD_SHARED_LIBS=On -D USE_TCMALLOC=0 \
-               -D CMAKE_BUILD_TYPE=Debug \
-               -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=/usr/bin/clang++
.. "
-  echo "$CMAKE_COMMAND" | tee -a build.log
-  if ! $CMAKE_COMMAND 2>&1 | ts "%.s (%H:%M:%S)" | tee -a build.log; then exit 1;
fi
-else 
-  echo "CMakeCache.txt detected. Not running CMake again."
-fi
+function kill_stat_collectors {
+  kill $PID_vmstat
+  kill $PID_mpstat
+  exit
+}
 
-MAKE_COMMAND="make VERBOSE=1 -j $NUM_JOBS"
-echo "$MAKE_COMMAND" | tee -a build.log
-if ! $MAKE_COMMAND 2>&1 | ts "%.s (%H:%M:%S)" | tee -a build.log; then exit 1; fi
+function run_cmake {
+  if [[ ! -f CMakeCache.txt ]]; then 
+    echo "$CMAKE_COMMAND" | tee -a build.log
+    $CMAKE_COMMAND 2>&1 | ts "%.s (%H:%M:%S)" | tee -a build.log
+  else 
+    echo "CMakeCache.txt detected. Not running CMake again."
+  fi
+}
 
-END_TIME=`date +"%s"`
+function run_make {
+  echo "$MAKE_COMMAND" | tee -a build.log
+  $MAKE_COMMAND 2>&1 | ts "%.s (%H:%M:%S)" | tee -a build.log
+}
 
-kill $PID_vmstat
-kill $PID_mpstat
+function print_stats {
+  avg_mem=`grep -v r stats_mem.txt | tr -s ' ' | awk -F " " '{s+= $6; c++} END {print s/c/1024}'`
+  echo -e "\n\n"
+  echo "Average memory used was $avg_mem GB"  | tee -a build.log
 
-avg_mem=`grep -v r stats_mem.txt | tr -s ' ' | awk -F " " '{s+= $6; c++} END {print s/c/1024}'`
-echo
-echo
-echo "Average memory used was $avg_mem GB"  | tee -a build.log
+  time_taken=`expr $END_TIME - $START_TIME`
+  mins=`expr $time_taken / 60`
+  secs=`expr $time_taken % 60`
+  echo "Time taken was ${mins}m ${secs}s" | tee -a build.log
+}
 
-time_taken=`expr $END_TIME - $START_TIME`
-mins=`expr $time_taken / 60`
-secs=`expr $time_taken % 60`
-echo "Time taken was ${mins}m ${secs}s" | tee -a build.log
+echo "Starting build in " `pwd`  >> build.log
+start_stat_collectors
+trap kill_stat_collectors SIGHUP SIGINT SIGTERM
+START_TIME=`date +"%s"`
+run_cmake
+run_make
+END_TIME=`date +"%s"`
+kill_stat_collectors
+print_stats


Mime
View raw message