| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright 2016, International Business Machines |
| 5 |
# |
| 6 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 |
# you may not use this file except in compliance with the License. |
| 8 |
# You may obtain a copy of the License at |
| 9 |
# |
| 10 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
# |
| 12 |
# Unless required by applicable law or agreed to in writing, software |
| 13 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 |
# See the License for the specific language governing permissions and |
| 16 |
# limitations under the License. |
| 17 |
# |
| 18 |
|
| 19 |
card=0 |
| 20 |
verbose=0 |
| 21 |
PLATFORM=`uname -p` |
| 22 |
start_time=`date` |
| 23 |
options="" |
| 24 |
verbose=0 |
| 25 |
logging=0 |
| 26 |
keep=0 |
| 27 |
|
| 28 |
test_data=linux-3.17.tar |
| 29 |
sizes="1 8 16 64 256 1024 4096 8192 9000 12000 14000 16000 32000 48000 56000 64000 96000 128000 200000 300000 400000 500000" |
| 30 |
|
| 31 |
# Set default accelerator based on platform we are running on |
| 32 |
if [ ${PLATFORM} == "ppc64le" ]; then |
| 33 |
accelerator=CAPI |
| 34 |
else |
| 35 |
accelerator=GENWQE |
| 36 |
fi |
| 37 |
|
| 38 |
function usage() { |
| 39 |
echo "Usage:" |
| 40 |
echo " genwqe_file_perf" |
| 41 |
echo " [-A] <accelerator> GENWQE|CAPI" |
| 42 |
echo " [-C] <card> card to be used for the test" |
| 43 |
echo " [-t] <test_data> file to use for performance measurement" |
| 44 |
echo " [-1] --fast mode for compression" |
| 45 |
echo " [-9] --best mode for compression" |
| 46 |
echo " [-k] keep output data and write to filesystem" |
| 47 |
echo " [-l] Enable system load logging" |
| 48 |
echo " sadc - System activity data collector and gnuplot" |
| 49 |
echo " must be installed" |
| 50 |
echo " [-v] verbose" |
| 51 |
echo |
| 52 |
echo "To exclude influences from reading and writing to disk," |
| 53 |
echo "it is recommended to create a ramdisk e.g. by using tmpfs" |
| 54 |
echo "to get more precise measurements about what is caused by" |
| 55 |
echo "the accellerator and what is caused by using faster or smaller" |
| 56 |
echo "disks." |
| 57 |
echo |
| 58 |
} |
| 59 |
|
| 60 |
function erase_files() { |
| 61 |
for s in ${sizes} ; do |
| 62 |
rm -f ${s}KiB.bin ${s}KiB.orig ${s}KiB.gz out.stderr |
| 63 |
done |
| 64 |
rm -f system_load.sar system_load.*.sar system_load.csv system_load.txt \ |
| 65 |
system_load.gnuplot system_load.pid |
| 66 |
} |
| 67 |
|
| 68 |
function cleanup() { |
| 69 |
if [ $logging -eq 1 ]; then |
| 70 |
system_load_logging_stop |
| 71 |
fi |
| 72 |
echo "EXIT ..." |
| 73 |
} |
| 74 |
|
| 75 |
trap cleanup SIGINT |
| 76 |
trap cleanup SIGKILL |
| 77 |
trap cleanup SIGTERM |
| 78 |
|
| 79 |
############################################################################### |
| 80 |
# System Load Logging |
| 81 |
############################################################################### |
| 82 |
|
| 83 |
function system_load_logging_start() { |
| 84 |
rm -f system_load.sar system_load.pid |
| 85 |
sync |
| 86 |
/usr/lib/sysstat/sadc 1 system_load.sar & |
| 87 |
echo $! > system_load.pid |
| 88 |
} |
| 89 |
|
| 90 |
function system_load_logging_stop() { |
| 91 |
kill -9 `cat system_load.pid` |
| 92 |
|
| 93 |
# Skip the 1st 4 lines, since they container some header information |
| 94 |
cp system_load.sar system_load.$ZLIB_ACCELERATOR.sar |
| 95 |
sar -u -f system_load.sar | tail -n +3 > system_load.txt |
| 96 |
grep -v Average system_load.txt > system_load.csv |
| 97 |
|
| 98 |
start=`head -n1 system_load.csv | cut -f1 -d' '` |
| 99 |
end=`tail -n1 system_load.csv | cut -f1 -d' '` |
| 100 |
|
| 101 |
cat <<EOF > system_load.gnuplot |
| 102 |
# Gnuplot Config |
| 103 |
# |
| 104 |
set terminal pdf size 16,8 |
| 105 |
set output "system_load.pdf" |
| 106 |
set autoscale |
| 107 |
set title "System Load using $ZLIB_ACCELERATOR" |
| 108 |
set xdata time |
| 109 |
set timefmt "%H:%M:%S" |
| 110 |
set xlabel "Time" |
| 111 |
set xrange ["$start":"$end"] |
| 112 |
set ylabel "CPU Utilization" |
| 113 |
# Set yrange small, we use only one CPU using 100.00 is not useful here |
| 114 |
set yrange ["0.00":"5.00"] |
| 115 |
set style data lines |
| 116 |
set grid |
| 117 |
# set datafile separator " " |
| 118 |
plot "system_load.csv" using 1:4 title "%user", '' using 1:6 title "%system", '' using 1:9 title "%idle" |
| 119 |
EOF |
| 120 |
|
| 121 |
# Instructing gnuplot to generate a png with out CPU load statistics |
| 122 |
cat system_load.gnuplot | gnuplot |
| 123 |
|
| 124 |
# Safe it under an accelerator unique name |
| 125 |
mv system_load.pdf system_load.${ZLIB_ACCELERATOR}.pdf |
| 126 |
} |
| 127 |
|
| 128 |
while getopts "19A:C:t:klvh" opt; do |
| 129 |
case $opt in |
| 130 |
A) |
| 131 |
accelerator=$OPTARG; |
| 132 |
;; |
| 133 |
C) |
| 134 |
card=$OPTARG; |
| 135 |
;; |
| 136 |
t) |
| 137 |
test_data=${OPTARG}; |
| 138 |
;; |
| 139 |
1) |
| 140 |
options+=" -1" |
| 141 |
;; |
| 142 |
9) |
| 143 |
options+=" -9" |
| 144 |
;; |
| 145 |
l) |
| 146 |
logging=1; |
| 147 |
;; |
| 148 |
k) |
| 149 |
keep=1; |
| 150 |
;; |
| 151 |
b) |
| 152 |
verbose=1; |
| 153 |
;; |
| 154 |
h) |
| 155 |
usage; |
| 156 |
exit 0; |
| 157 |
;; |
| 158 |
t) |
| 159 |
tools_dir=$OPTARG; |
| 160 |
;; |
| 161 |
\?) |
| 162 |
echo "Invalid option: -$OPTARG" >&2 |
| 163 |
;; |
| 164 |
esac |
| 165 |
done |
| 166 |
|
| 167 |
if [ ${accelerator} = SW ]; then |
| 168 |
options+=" -s" |
| 169 |
fi |
| 170 |
|
| 171 |
ZLIB_ACCELERATOR=${accelerator} |
| 172 |
|
| 173 |
# Generate core dumps, in case something needs debug |
| 174 |
ulimit -c unlimited |
| 175 |
|
| 176 |
echo "ACCELERATOR: ${accelerator}" |
| 177 |
|
| 178 |
if [ ! -f ${test_data} ]; then |
| 179 |
echo "Testdata: ${test_data} missing!" |
| 180 |
echo "Use -t <test_data> to specify alternate file." |
| 181 |
exit 1 |
| 182 |
fi |
| 183 |
|
| 184 |
for s in ${sizes} ; do |
| 185 |
dd if=${test_data} of=${s}KiB.bin bs=1024 count=${s} 2> /dev/null |
| 186 |
done |
| 187 |
|
| 188 |
if [ $logging -eq 1 ]; then |
| 189 |
system_load_logging_start |
| 190 |
fi |
| 191 |
|
| 192 |
echo "KiB ; sec ; sec" |
| 193 |
for s in ${sizes} ; do |
| 194 |
if [ ${keep} -eq 1 ]; then |
| 195 |
outfile=${s}KiB.orig |
| 196 |
else |
| 197 |
outfile=/dev/null |
| 198 |
fi |
| 199 |
|
| 200 |
sync |
| 201 |
(time genwqe_gzip -A ${accelerator} ${options} -B ${card} -c \ |
| 202 |
${s}KiB.bin > ${s}KiB.gz) 2> out.stderr |
| 203 |
if [ $? -ne 0 ]; then |
| 204 |
echo "Compression failed ..." |
| 205 |
exit 1 |
| 206 |
fi |
| 207 |
|
| 208 |
c=`grep real out.stderr | cut -f2 -d'm' | cut -d's' -f1`; |
| 209 |
if [ $verbose -eq 1 ]; then |
| 210 |
cat out.stderr |
| 211 |
fi |
| 212 |
|
| 213 |
sync |
| 214 |
(time genwqe_gunzip -A ${accelerator} -o512KiB ${options} -B ${card} \ |
| 215 |
-c ${s}KiB.gz > ${outfile}) 2> out.stderr |
| 216 |
if [ $? -ne 0 ]; then |
| 217 |
echo "Decompression failed ..." |
| 218 |
exit 1 |
| 219 |
fi |
| 220 |
|
| 221 |
d=`grep real out.stderr | cut -f2 -d'm' | cut -d's' -f1`; |
| 222 |
if [ $verbose -eq 1 ]; then |
| 223 |
cat out.stderr |
| 224 |
fi |
| 225 |
|
| 226 |
echo "${s} ; ${c} ; ${d}" |
| 227 |
rm -f ${s}KiB.orig ${s}KiB.gz out.stderr |
| 228 |
done |
| 229 |
|
| 230 |
if [ $logging -eq 1 ]; then |
| 231 |
system_load_logging_stop |
| 232 |
fi |
| 233 |
|
| 234 |
erase_files |
| 235 |
|
| 236 |
exit 0 |