on master help sign in
Refactor and improve error reporting
commit2b8c70bfac109c033775cab2d20c9bdaa765eaa5 authorHarendra Kumar <harendra@composewell.com> dateSun 4 Jul 2021, 23:06 (5 years ago) parent0cbcf0b
5 files changed+79−74
benchmark/bench-report/bin/bench-runner.sh+8−3 benchmark/bench-report/bin/build-lib.sh+19−63 benchmark/bench-report/default.nix+1−1 bin/bench-config.sh+6−6 bin/test.sh+45−1
benchmark/bench-report/bin/bench-runner.sh+8−3
@@ -247,7 +247,7 @@ $RTS_OPTIONS \
247247 $QUICK_BENCH_OPTIONS \
248248 "$@" \
249249 --csv=${output_file}.tmp \
250− -p '$0 == "'"$BENCH_NAME_ESC"'"'
250+ -p '$0 == "'"$BENCH_NAME_ESC"'"' || die "Benchmark execution failed."
251251
252252 # Convert cpuTime field from picoseconds to seconds
253253 awk --version 2>&1 | grep -q "GNU Awk" \
@@ -262,7 +262,7 @@ $RTS_OPTIONS \
262262 $QUICK_BENCH_OPTIONS \
263263 "$@" \
264264 --csvraw=${output_file}.tmp \
265− -m exact "$BENCH_NAME"
265+ -m exact "$BENCH_NAME" || die "Benchmark execution failed."
266266 tail -n +2 ${output_file}.tmp \
267267 >> $output_file
268268 fi
@@ -321,7 +321,12 @@ run_bench_target () {
321321 local target_name=$3
322322
323323 local target_prog
324− target_prog=$(cabal_target_prog $package_name $component $target_name) || \
324+ if test -z "$BENCHMARK_PACKAGE_VERSION"
325+ then
326+ echo "Please set BENCHMARK_PACKAGE_VERSION in bench_config"
327+ exit 1
328+ fi
329+ target_prog=$(cabal_target_prog $package_name-$BENCHMARK_PACKAGE_VERSION $component $target_name) || \
325330 die "Cannot find executable for target $target_name"
326331
327332 echo "Running executable $target_name ..."
benchmark/bench-report/bin/build-lib.sh+19−63
@@ -112,6 +112,24 @@ set_targets() {
112112 fi
113113}
114114
115+# XXX cabal issue "cabal v2-exec which" cannot find benchmark/test executables
116+
117+# $1: builddir
118+# $2: package name with version
119+# $3: component ("" (lib), t (test), b (benchmark), x (executable))
120+# $4: command to find
121+cabal_which_builddir() {
122+ local path=$(echo $1/build/*/ghc-${GHC_VERSION}/${2}/$3/$4/build/$4/$4)
123+ test -f "$path" && echo $path
124+}
125+
126+# $1: package name with version
127+# $2: component
128+# $3: command to find
129+cabal_which() {
130+ cabal_which_builddir $BUILD_DIR $1 $2 $3
131+}
132+
115133# We run the benchmarks in isolation in a separate process so that different
116134# benchmarks do not interfere with other. To enable that we need to pass the
117135# benchmark exe path to gauge as an argument. Unfortunately it cannot find its
@@ -119,7 +137,7 @@ set_targets() {
119137
120138# The path is dependent on the architecture and cabal version.
121139
122−# $1: package name
140+# $1: package name with version
123141# $2: component
124142# $3: target
125143cabal_target_prog () {
@@ -169,24 +187,6 @@ set_derived_vars () {
169187 GHC_VERSION=$($CABAL_WITH_COMPILER --numeric-version)
170188}
171189
172−# XXX cabal issue "cabal v2-exec which" cannot find benchmark/test executables
173−
174−# $1: builddir
175−# $2: package name
176−# $3: component ("" (lib), t (test), b (benchmark), x (executable))
177−# $4: command to find
178−cabal_which_builddir() {
179− local path=$(echo $1/build/*/ghc-${GHC_VERSION}/${2}-0.0.0/$3/$4/build/$4/$4)
180− test -f "$path" && echo $path
181−}
182−
183−# $1: package name
184−# $2: component
185−# $3: command to find
186−cabal_which() {
187− cabal_which_builddir $BUILD_DIR $1 $2 $3
188−}
189−
190190# $1: build program
191191# $2: package name
192192# $3: component prefix
@@ -204,47 +204,3 @@ run_build () {
204204 done
205205 run_verbose $build_prog $COMPONENTS || die "build failed"
206206}
207−
208−# $1: target name
209−get_tix_file () {
210− echo $BUILD_DIR/build/$SYSTEM/ghc-${GHC_VERSION}/$PACKAGE_FULL_NAME/hpc/vanilla/tix/$1/$1.tix
211−}
212−
213−# $1: package name
214−# $2: component
215−# $3: target
216−# $4: args generator func
217−run_target () {
218− local package_name=$1
219− local component=$2
220− local target_name=$3
221− local extra_args=$4
222−
223− local target_prog
224− target_prog=$(cabal_target_prog $package_name $component $target_name) || \
225− die "Cannot find executable for target $target_name"
226−
227− echo "Running executable $target_name ..."
228−
229− # Needed by bench-exec-one.sh
230− export BENCH_EXEC_PATH=$target_prog
231− mkdir -p $(dirname $(get_tix_file $target_name))
232− export HPCTIXFILE=$(get_tix_file $target_name)
233−
234− run_verbose $target_prog $($extra_args $target_name $target_prog) \
235− || die "Target exe failed"
236−
237− # hpc-coveralls fails if there is an empty dir and no .tix file generated
238− rmdir $(dirname $(get_tix_file $target_name)) 2>/dev/null || true
239−}
240−
241−# $1: package name
242−# $2: component
243−# $3: targets
244−# $4: args generator func
245−run_targets() {
246− for i in $3
247− do
248− run_target $1 $2 $i $4
249− done
250−}
benchmark/bench-report/default.nix+1−1
@@ -47,4 +47,4 @@ let haskellPackages =
4747 };
4848in if nixpkgs.lib.inNixShell
4949 then shell
50− else (mkHaskellPackages false).streamly
50+ else (mkHaskellPackages false).bench-report
bin/bench-config.sh+6−6
@@ -42,8 +42,13 @@ bench_rts_options () {
4242 *) echo -n "" ;;
4343 esac
4444
45− echo " "
45+ echo -n " "
46+ case "$exe_name" in
47+ Prelude.Concurrent*) echo -n "-K256K -M384M" ;;
48+ *) echo -n "" ;;
49+ esac
4650
51+ echo -n " "
4752 # Based on specific benchmark
4853 # XXX Note: for tasty-bench we replace the "." separator in the benchmark names
4954 # with "/" for matching with this. It may not work reliably if the benchmark
@@ -106,11 +111,6 @@ bench_rts_options () {
106111 Data.Array.Foreign/o-1-space/elimination/foldable/sum) echo -n "-K8M" ;;
107112 *) echo -n "" ;;
108113 esac
109−
110− case "$exe_name" in
111− Prelude.Concurrent*) echo -n " -K256K -M384M" ;;
112− *) echo -n "" ;;
113− esac
114114}
115115
116116#------------------------------------------------------------------------------
bin/test.sh+45−1
@@ -156,9 +156,53 @@ fi
156156# Run targets
157157#-----------------------------------------------------------------------------
158158
159+# $1: target name
160+get_tix_file () {
161+ echo $BUILD_DIR/build/$SYSTEM/ghc-${GHC_VERSION}/$PACKAGE_FULL_NAME/hpc/vanilla/tix/$1/$1.tix
162+}
163+
164+# $1: package name
165+# $2: component
166+# $3: target
167+# $4: args generator func
168+run_target () {
169+ local package_name=$1
170+ local component=$2
171+ local target_name=$3
172+ local extra_args=$4
173+
174+ local target_prog
175+ target_prog=$(cabal_target_prog $package_name $component $target_name) || \
176+ die "Cannot find executable for target $target_name"
177+
178+ echo "Running executable $target_name ..."
179+
180+ # Needed by bench-exec-one.sh
181+ export BENCH_EXEC_PATH=$target_prog
182+ mkdir -p $(dirname $(get_tix_file $target_name))
183+ export HPCTIXFILE=$(get_tix_file $target_name)
184+
185+ run_verbose $target_prog $($extra_args $target_name $target_prog) \
186+ || die "Target exe failed"
187+
188+ # hpc-coveralls fails if there is an empty dir and no .tix file generated
189+ rmdir $(dirname $(get_tix_file $target_name)) 2>/dev/null || true
190+}
191+
192+# $1: package name with version
193+# $2: component
194+# $3: targets
195+# $4: args generator func
196+run_targets() {
197+ for i in $3
198+ do
199+ run_target $1 $2 $i $4
200+ done
201+}
202+
159203if test "$MEASURE" -eq "1"
160204then
161−run_targets streamly-tests t "$TARGETS" target_exe_extra_args
205+run_targets "streamly-tests-0.0.0" t "$TARGETS" target_exe_extra_args
162206fi
163207
164208#-----------------------------------------------------------------------------