3 # Copyright (C) 2015 Red Hat <contact@redhat.com>
4 # Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
6 # Author: Loic Dachary <loic@dachary.org>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU Library Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Library Public License for more details.
18 # Test that it works from sources with:
20 # CEPH_ERASURE_CODE_BENCHMARK=src/ceph_erasure_code_benchmark \
21 # PLUGIN_DIRECTORY=src/.libs \
22 # qa/workunits/erasure-code/bench.sh fplot jerasure |
23 # tee qa/workunits/erasure-code/bench.js
25 # This should start immediately and display:
28 # [ '2/1', .48035538612887358583 ],
29 # [ '3/2', .21648470405675016626 ],
32 # and complete within a few seconds. The result can then be displayed with:
34 # firefox qa/workunits/erasure-code/bench.html
36 # Once it is confirmed to work, it can be run with a more significant
37 # volume of data so that the measures are more reliable:
39 # TOTAL_SIZE=$((4 * 1024 * 1024 * 1024)) \
40 # CEPH_ERASURE_CODE_BENCHMARK=src/ceph_erasure_code_benchmark \
41 # PLUGIN_DIRECTORY=src/.libs \
42 # qa/workunits/erasure-code/bench.sh fplot jerasure |
43 # tee qa/workunits/erasure-code/bench.js
47 export PATH=/sbin:$PATH
50 : ${CEPH_ERASURE_CODE_BENCHMARK:=ceph_erasure_code_benchmark}
51 : ${PLUGIN_DIRECTORY:=/usr/lib/ceph/erasure-code}
52 : ${PLUGINS:=isa jerasure}
53 : ${TECHNIQUES:=vandermonde cauchy}
54 : ${TOTAL_SIZE:=$((1024 * 1024))}
56 : ${PARAMETERS:=--parameter jerasure-per-chunk-alignment=true}
58 function bench_header() {
59 echo -e "seconds\tKB\tplugin\tk\tm\twork.\titer.\tsize\teras.\tcommand."
77 command=$(echo $CEPH_ERASURE_CODE_BENCHMARK \
79 --workload $workload \
80 --iterations $iterations \
82 --erasures $erasures \
85 --erasure-code-dir $PLUGIN_DIRECTORY)
86 result=$($command "$@")
87 echo -e "$result\t$plugin\t$k\t$m\t$workload\t$iterations\t$size\t$erasures\t$command ""$@"
90 function packetsize() {
93 local vector_wordsize=$3
96 local p=$(( ($size / $k / $w / $vector_wordsize ) * $vector_wordsize))
97 if [ $p -gt 3100 ] ; then
103 function bench_run() {
104 local plugin=jerasure
106 local VECTOR_WORDSIZE=16
107 local ks="2 3 4 6 10"
114 for technique in ${TECHNIQUES} ; do
115 for plugin in ${PLUGINS} ; do
116 eval technique_parameter=\$${plugin}2technique_${technique}
117 echo "serie encode_${technique}_${plugin}"
119 for m in ${k2ms[$k]} ; do
120 bench $plugin $k $m encode $(($TOTAL_SIZE / $SIZE)) $SIZE 0 \
121 --parameter packetsize=$(packetsize $k $w $VECTOR_WORDSIZE $SIZE) \
123 --parameter technique=$technique_parameter
129 for technique in ${TECHNIQUES} ; do
130 for plugin in ${PLUGINS} ; do
131 eval technique_parameter=\$${plugin}2technique_${technique}
132 echo "serie decode_${technique}_${plugin}"
134 for m in ${k2ms[$k]} ; do
136 for erasures in $(seq 1 $m) ; do
137 bench $plugin $k $m decode $(($TOTAL_SIZE / $SIZE)) $SIZE $erasures \
138 --parameter packetsize=$(packetsize $k $w $VECTOR_WORDSIZE $SIZE) \
140 --parameter technique=$technique_parameter
150 bench_run | while read seconds total plugin k m workload iteration size erasures rest ; do
151 if [ -z $seconds ] ; then
153 elif [ $seconds = serie ] ; then
154 if [ "$serie" ] ; then
157 local serie=`echo $total | sed 's/cauchy_\([0-9]\)/cauchy_good_\1/g'`
158 echo "var $serie = ["
161 if [ $workload = encode ] ; then
166 echo "[ '$x', " $(echo "( $total / 1024 / 1024 ) / $seconds" | bc -ql) " ], "
177 if [ "$1" = fplot ] ; then
183 # compile-command: "\
184 # CEPH_ERASURE_CODE_BENCHMARK=../../../src/ceph_erasure_code_benchmark \
185 # PLUGIN_DIRECTORY=../../../src/.libs \