kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject incubator-kudu git commit: tpch: switch CPU to performance mode before running benchmark
Date Tue, 26 Jan 2016 21:24:26 GMT
Repository: incubator-kudu
Updated Branches:
  refs/heads/master 1204c0a9a -> c7a9b1211


tpch: switch CPU to performance mode before running benchmark

For benchmarks, it's important to disable frequency scaling to get
consistent results. We were already doing this for the main benchmarks
script, but not for the tpch test. One of our benchmark slaves was
set to 'performance' mode whereas another is set to 'ondemand'
which resulted in about a 2x difference in performance on this benchmark.

This refactors out some code for setting the frequency governor and
uses it in the TPCH script.

Change-Id: If917950cef028470d0e603475a236847b1cccd46
Reviewed-on: http://gerrit.cloudera.org:8080/1910
Reviewed-by: Jean-Daniel Cryans
Tested-by: Todd Lipcon <todd@apache.org>


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

Branch: refs/heads/master
Commit: c7a9b1211d0b5c1f2102021260e8f14acb511182
Parents: 1204c0a
Author: Todd Lipcon <todd@apache.org>
Authored: Tue Jan 26 12:12:33 2016 -0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Tue Jan 26 21:24:12 2016 +0000

----------------------------------------------------------------------
 src/kudu/scripts/benchmarks.sh         | 24 +-----------------------
 src/kudu/scripts/ensure_cpu_scaling.sh | 24 ++++++++++++++++++++++++
 src/kudu/scripts/tpch.sh               | 11 +++++++++++
 3 files changed, 36 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/c7a9b121/src/kudu/scripts/benchmarks.sh
----------------------------------------------------------------------
diff --git a/src/kudu/scripts/benchmarks.sh b/src/kudu/scripts/benchmarks.sh
index bd722f8..e5f6e27 100755
--- a/src/kudu/scripts/benchmarks.sh
+++ b/src/kudu/scripts/benchmarks.sh
@@ -87,30 +87,8 @@ usage_and_die() {
   exit 1
 }
 
-# Ensure that the CPU governor is set to a particular governor, outputting
-# the prior governor on stdout.
-#
-# Without this, some of our tests end up having higher variance due to
-# changing CPU speed during the test.
-#
-# Assumes that all CPUs are set to the same governor.
 ensure_cpu_scaling() {
-  target_governor=$1
-  old_governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
-  for cpu_dir in /sys/devices/system/cpu/cpu[0-9]*/ ; do
-    governor_file=$cpu_dir/cpufreq/scaling_governor
-    governor=$(cat $governor_file)
-    if [ "$governor" != "$target_governor" ]; then
-      >&2 echo "CPU $cpu_dir not in '$target_governor' mode. Attempting to change"
-      echo $target_governor | sudo tee $governor_file > /dev/null
-      if [ $? -ne 0 ]; then
-        >&2 echo Could not set $target_governor governor!
-        >&2 echo Perhaps you need passwordless sudo for this user
-        exit 1
-      fi
-    fi
-  done
-  echo $old_governor
+  $(dirname $BASH_SOURCE)/ensure_cpu_scaling.sh "$@"
 }
 
 record_result() {

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/c7a9b121/src/kudu/scripts/ensure_cpu_scaling.sh
----------------------------------------------------------------------
diff --git a/src/kudu/scripts/ensure_cpu_scaling.sh b/src/kudu/scripts/ensure_cpu_scaling.sh
new file mode 100755
index 0000000..0de657a
--- /dev/null
+++ b/src/kudu/scripts/ensure_cpu_scaling.sh
@@ -0,0 +1,24 @@
+#!/bin/bash -e
+# Ensure that the CPU governor is set to a particular governor, outputting
+# the prior governor on stdout.
+#
+# Without this, some of our tests end up having higher variance due to
+# changing CPU speed during the test.
+#
+# Assumes that all CPUs are set to the same governor.
+target_governor=$1
+old_governor=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
+for cpu_dir in /sys/devices/system/cpu/cpu[0-9]*/ ; do
+    governor_file=$cpu_dir/cpufreq/scaling_governor
+    governor=$(cat $governor_file)
+    if [ "$governor" != "$target_governor" ]; then
+        >&2 echo "CPU $cpu_dir not in '$target_governor' mode. Attempting to change"
+        echo $target_governor | sudo tee $governor_file > /dev/null
+        if [ $? -ne 0 ]; then
+            >&2 echo Could not set $target_governor governor!
+            >&2 echo Perhaps you need passwordless sudo for this user
+            exit 1
+        fi
+    fi
+done
+echo $old_governor

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/c7a9b121/src/kudu/scripts/tpch.sh
----------------------------------------------------------------------
diff --git a/src/kudu/scripts/tpch.sh b/src/kudu/scripts/tpch.sh
index eee47de..10f7173 100755
--- a/src/kudu/scripts/tpch.sh
+++ b/src/kudu/scripts/tpch.sh
@@ -67,6 +67,10 @@ record_result() {
   fi
 }
 
+ensure_cpu_scaling() {
+  $(dirname $BASH_SOURCE)/ensure_cpu_scaling.sh "$@"
+}
+
 ##########################################################
 # Main
 ##########################################################
@@ -82,6 +86,13 @@ set -o pipefail
 ulimit -m $[3000*1000]
 ulimit -c unlimited # gather core dumps
 
+# Set CPU governor, and restore it on exit.
+old_governor=$(ensure_cpu_scaling performance)
+restore_governor() {
+  ensure_cpu_scaling $old_governor >/dev/null
+}
+trap restore_governor EXIT
+
 # PATH=<toolchain_stuff>:$PATH
 export TOOLCHAIN=/mnt/toolchain/toolchain.sh
 if [ -f "$TOOLCHAIN" ]; then


Mime
View raw message