on master help sign in
Multiple changes corresponding to the fold benchmark.
b6d787fadithyaov
bench.sh+44−4
@@ -3,8 +3,9 @@
3SERIAL_O_1="linear base"
3SERIAL_O_1="linear base"
4SERIAL_O_n="serial-o-n-heap serial-o-n-stack serial-o-n-space \
4SERIAL_O_n="serial-o-n-heap serial-o-n-stack serial-o-n-space \
5 base-o-n-heap base-o-n-stack base-o-n-space"
5 base-o-n-heap base-o-n-stack base-o-n-space"
6+FOLD_BENCHMARKS="fold-o-1-space fold-o-n-heap"
6
7
7−SERIAL_BENCHMARKS="$SERIAL_O_1 $SERIAL_O_n"
8+SERIAL_BENCHMARKS="$SERIAL_O_1 $SERIAL_O_n $FOLD_BENCHMARKS"
8# parallel benchmark-suite is separated because we run it with a higher
9# parallel benchmark-suite is separated because we run it with a higher
9# heap size limit.
10# heap size limit.
10CONCURRENT_BENCHMARKS="linear-async linear-rate nested-concurrent parallel concurrent adaptive"
11CONCURRENT_BENCHMARKS="linear-async linear-rate nested-concurrent parallel concurrent adaptive"
@@ -21,6 +22,33 @@ VIRTUAL_BENCHMARKS="array-cmp"
21
22
22ALL_BENCHMARKS="$SERIAL_BENCHMARKS $CONCURRENT_BENCHMARKS $ARRAY_BENCHMARKS $VIRTUAL_BENCHMARKS"
23ALL_BENCHMARKS="$SERIAL_BENCHMARKS $CONCURRENT_BENCHMARKS $ARRAY_BENCHMARKS $VIRTUAL_BENCHMARKS"
23
24
25+# RTS options that go inside +RTS and -RTS while running the benchmark.
26+bench_rts_opts () {
27+ case "$1" in
28+ "fold-o-1-space") echo -n "-T -K36K -M16M" ;;
29+ "fold-o-n-heap") echo -n "-T -K36K -M128M" ;;
30+ *) echo -n "" ;;
31+ esac
32+}
33+
34+# The correct executable for the given benchmark name.
35+bench_exec () {
36+ case "$1" in
37+ "fold-o-1-space") echo -n "fold" ;;
38+ "fold-o-n-heap") echo -n "fold" ;;
39+ *) echo -n "$1" ;;
40+ esac
41+}
42+
43+# Specific gauge options for the given benchmark.
44+bench_gauge_opts () {
45+ case "$1" in
46+ "fold-o-1-space") echo -n "-m prefix o-1-space" ;;
47+ "fold-o-n-heap") echo -n "-m prefix o-n-heap" ;;
48+ *) echo -n "" ;;
49+ esac
50+}
51+
24list_benches () {
52list_benches () {
25 for i in $ALL_BENCHMARKS
53 for i in $ALL_BENCHMARKS
26 do
54 do
@@ -177,10 +205,11 @@ bench_output_file() {
177
205
178run_bench () {
206run_bench () {
179 local bench_name=$1
207 local bench_name=$1
208+ local bench_exe=$(bench_exec $bench_name)
180 local output_file=$(bench_output_file $bench_name)
209 local output_file=$(bench_output_file $bench_name)
181 local bench_prog
210 local bench_prog
182 local quick_bench=0
211 local quick_bench=0
183− bench_prog=$($GET_BENCH_PROG $bench_name) || \
212+ bench_prog=$($GET_BENCH_PROG $bench_exe) || \
184 die "Cannot find benchmark executable for benchmark $bench_name"
213 die "Cannot find benchmark executable for benchmark $bench_name"
185
214
186 mkdir -p `dirname $output_file`
215 mkdir -p `dirname $output_file`
@@ -217,9 +246,11 @@ run_bench () {
217 fi
246 fi
218
247
219 $bench_prog $SPEED_OPTIONS \
248 $bench_prog $SPEED_OPTIONS \
249+ +RTS $(bench_rts_opts $bench_name) -RTS \
220 --csvraw=$output_file \
250 --csvraw=$output_file \
221 -v 2 \
251 -v 2 \
222− --measure-with $bench_prog $GAUGE_ARGS || die "Benchmarking failed"
252+ --measure-with $bench_prog $GAUGE_ARGS \
253+ $(bench_gauge_opts $bench_name) || die "Benchmarking failed"
223}
254}
224
255
225run_benches() {
256run_benches() {
@@ -382,8 +413,17 @@ only_real_benchmarks () {
382 done
413 done
383}
414}
384
415
416+proper_executables () {
417+ for i in $BENCHMARKS
418+ do
419+ echo -n "$(bench_exec $i) "
420+ done
421+}
422+
423+
385BENCHMARKS_ORIG=$BENCHMARKS
424BENCHMARKS_ORIG=$BENCHMARKS
386BENCHMARKS=$(only_real_benchmarks)
425BENCHMARKS=$(only_real_benchmarks)
426+EXECUTABLES=$(proper_executables)
387echo "Using benchmark suites [$BENCHMARKS]"
427echo "Using benchmark suites [$BENCHMARKS]"
388
428
389has_benchmark () {
429has_benchmark () {
@@ -431,7 +471,7 @@ then
431 then
471 then
432 $BUILD_BENCH || die "build failed"
472 $BUILD_BENCH || die "build failed"
433 else
473 else
434− $BUILD_BENCH $BENCHMARKS || die "build failed"
474+ $BUILD_BENCH $EXECUTABLES || die "build failed"
435 fi
475 fi
436 run_measurements "$BENCHMARKS"
476 run_measurements "$BENCHMARKS"
437fi
477fi
benchmark/Chart.hs+14
@@ -38,6 +38,8 @@ data BenchType
38 | Concurrent
38 | Concurrent
39 | Parallel
39 | Parallel
40 | Adaptive
40 | Adaptive
41+ | FoldO1Space
42+ | FoldOnHeap
41 deriving Show
43 deriving Show
42
44
43data Options = Options
45data Options = Options
@@ -86,6 +88,8 @@ parseBench = do
86 Just "concurrent" -> setBenchType Concurrent
88 Just "concurrent" -> setBenchType Concurrent
87 Just "parallel" -> setBenchType Parallel
89 Just "parallel" -> setBenchType Parallel
88 Just "adaptive" -> setBenchType Adaptive
90 Just "adaptive" -> setBenchType Adaptive
91+ Just "fold-o-1-space" -> setBenchType FoldO1Space
92+ Just "fold-o-n-heap" -> setBenchType FoldOnHeap
89 Just str -> do
93 Just str -> do
90 liftIO $ putStrLn $ "unrecognized benchmark type " <> str
94 liftIO $ putStrLn $ "unrecognized benchmark type " <> str
91 mzero
95 mzero
@@ -409,3 +413,13 @@ main = do
409 showStreamK opts cfg'
413 showStreamK opts cfg'
410 "charts/base/results.csv"
414 "charts/base/results.csv"
411 "charts/base"
415 "charts/base"
416+ FoldO1Space -> benchShow opts cfg
417+ { title = Just "Fold O(1) Space" }
418+ (makeGraphs "fold-o-1-space")
419+ "charts/fold-o-1-space/results.csv"
420+ "charts/fold-o-1-space"
421+ FoldOnHeap -> benchShow opts cfg
422+ { title = Just "Fold O(n) Heap" }
423+ (makeGraphs "fold-o-n-heap")
424+ "charts/fold-o-n-heap/results.csv"
425+ "charts/fold-o-n-heap"
benchmark/streamly-benchmarks.cabal+1−2
@@ -225,11 +225,10 @@ benchmark serial-o-n-space
225 build-depends: lib-prelude
225 build-depends: lib-prelude
226 buildable: True
226 buildable: True
227
227
228−-- XXX Default memory restriction = o-1-space
229benchmark fold
228benchmark fold
230 import: bench-options
229 import: bench-options
231 type: exitcode-stdio-1.0
230 type: exitcode-stdio-1.0
232− ghc-options: -with-rtsopts "-T -K36K -M16M"
231+ ghc-options: -rtsopts
233 hs-source-dirs: ., Streamly/Benchmark/Data
232 hs-source-dirs: ., Streamly/Benchmark/Data
234 main-is: Fold.hs
233 main-is: Fold.hs
235 if impl(ghcjs)
234 if impl(ghcjs)