on master help sign in
Fix parser benchmark namespace and RTS options
c2def51Harendra Kumar
bench.sh+23−11
@@ -1,22 +1,25 @@
1#!/bin/bash
1#!/bin/bash
2
2
3−base_grp="\
3+# Note "_grp" and "_cmp" suffixes are special, do not rename them to something
4+# else.
5+
6+base_stream_grp="\
4 Data.Stream.StreamD \
7 Data.Stream.StreamD \
5 Data.Stream.StreamK \
8 Data.Stream.StreamK \
6 Data.Stream.StreamDK"
9 Data.Stream.StreamDK"
7SERIAL_O_1="linear"
10SERIAL_O_1="linear"
8SERIAL_O_n="serial-o-n-heap serial-o-n-stack serial-o-n-space"
11SERIAL_O_n="serial-o-n-heap serial-o-n-stack serial-o-n-space"
9UNFOLD_BENCHMARKS="unfold-o-1-space unfold-o-n-space"
12UNFOLD_BENCHMARKS="unfold-o-1-space unfold-o-n-space"
10−serial_grp="\
13+serial_grp="$SERIAL_O_1 $SERIAL_O_n"
11− $SERIAL_O_1 \
12− $SERIAL_O_n \
13− Data.Fold"
14−
15# parallel benchmark-suite is separated because we run it with a higher
14# parallel benchmark-suite is separated because we run it with a higher
16# heap size limit.
15# heap size limit.
17concurrent_grp="linear-async linear-rate nested-concurrent parallel concurrent adaptive"
16concurrent_grp="linear-async linear-rate nested-concurrent parallel concurrent adaptive"
17+
18array_grp="Memory.Array Data.Array Data.Prim.Array Data.SmallArray"
18array_grp="Memory.Array Data.Array Data.Prim.Array Data.SmallArray"
19
19
20+base_parser_grp="Data.Parser.ParserD Data.Parser.ParserK"
21+parser_grp="Data.Fold Data.Parser"
22+
20# XXX We can include SERIAL_O_1 here once "base" also supports --stream-size
23# XXX We can include SERIAL_O_1 here once "base" also supports --stream-size
21infinite_grp="linear linear-async linear-rate nested-concurrent"
24infinite_grp="linear linear-async linear-rate nested-concurrent"
22finite_grp="$SERIAL_O_n $array_grp fileio parallel concurrent adaptive"
25finite_grp="$SERIAL_O_n $array_grp fileio parallel concurrent adaptive"
@@ -28,14 +31,16 @@ QUICK_BENCHMARKS="linear-rate concurrent adaptive fileio"
28# *_cmp denotes a comparison benchmarks, the benchmarks provided in *_cmp
31# *_cmp denotes a comparison benchmarks, the benchmarks provided in *_cmp
29# variables are compared with each other
32# variables are compared with each other
30array_cmp="Memory.Array Data.Prim.Array Data.Array"
33array_cmp="Memory.Array Data.Prim.Array Data.Array"
31−base_cmp="Data.Stream.StreamD Data.Stream.StreamK"
34+base_stream_cmp="Data.Stream.StreamD Data.Stream.StreamK"
35+base_parser_cmp=$base_parser_grp
32−COMPARISONS="array_cmp base_cmp"
36+COMPARISONS="array_cmp base_stream_cmp base_parser_cmp"
33
37
38+# All high level benchmarks
34all_grp="\
39all_grp="\
35− $base_grp \
36 $serial_grp \
40 $serial_grp \
37 $concurrent_grp \
41 $concurrent_grp \
38− $array_grp"
42+ $array_grp \
43+ $parser_grp"
39
44
40ALL_BENCH_GROUPS="\
45ALL_BENCH_GROUPS="\
41 all_grp \
46 all_grp \
@@ -43,7 +48,9 @@ ALL_BENCH_GROUPS="\
43 concurrent_grp \
48 concurrent_grp \
44 array_grp \
49 array_grp \
45 infinite_grp \
50 infinite_grp \
46− finite_grp"
51+ finite_grp \
52+ base_stream_grp \
53+ base_parser_grp"
47
54
48# RTS options that go inside +RTS and -RTS while running the benchmark.
55# RTS options that go inside +RTS and -RTS while running the benchmark.
49bench_rts_opts () {
56bench_rts_opts () {
@@ -147,6 +154,11 @@ print_help () {
147 echo "--quick: Faster results, useful for longer benchmarks"
154 echo "--quick: Faster results, useful for longer benchmarks"
148 echo "--cabal-build-flags: Pass any cabal builds flags to be used for build"
155 echo "--cabal-build-flags: Pass any cabal builds flags to be used for build"
149 echo
156 echo
157+ echo "When specific space complexity group is chosen then (and only then) "
158+ echo "RTS memory restrictions are used accordingly. For example, "
159+ echo "bench.sh --benchmarks Data.Parser -- Data.Parser/o-1-space "
160+ echo "restricts Heap/Stack space for O(1) characterstics"
161+ echo
150 echo "When using --compare, by default comparative chart of HEAD^ vs HEAD"
162 echo "When using --compare, by default comparative chart of HEAD^ vs HEAD"
151 echo "commit is generated, in the 'charts' directory."
163 echo "commit is generated, in the 'charts' directory."
152 echo "Use --base and --candidate to select the commits to compare."
164 echo "Use --base and --candidate to select the commits to compare."
benchmark/Chart.hs+4−23
@@ -28,9 +28,6 @@ data BenchType
28 | LinearAsync
28 | LinearAsync
29 | LinearRate
29 | LinearRate
30 | NestedConcurrent
30 | NestedConcurrent
31− | ParserD
32− | ParserK
33− | Parser
34 | FileIO
31 | FileIO
35 | Concurrent
32 | Concurrent
36 | Parallel
33 | Parallel
@@ -44,7 +41,7 @@ data Options = Options
44 , benchType :: BenchType
41 , benchType :: BenchType
45 } deriving Show
42 } deriving Show
46
43
47−defaultOptions = Options False False Linear
44+defaultOptions = Options False Linear
48
45
49setGenGraphs val = do
46setGenGraphs val = do
50 (args, opts) <- get
47 (args, opts) <- get
@@ -70,9 +67,6 @@ parseBench = do
70 Just "linear-async" -> setBenchType LinearAsync
67 Just "linear-async" -> setBenchType LinearAsync
71 Just "linear-rate" -> setBenchType LinearRate
68 Just "linear-rate" -> setBenchType LinearRate
72 Just "nested-concurrent" -> setBenchType NestedConcurrent
69 Just "nested-concurrent" -> setBenchType NestedConcurrent
73− Just "parserD" -> setBenchType ParserD
74− Just "parserK" -> setBenchType ParserK
75− Just "parser" -> setBenchType Parser
76 Just "fileio" -> setBenchType FileIO
70 Just "fileio" -> setBenchType FileIO
77 Just "concurrent" -> setBenchType Concurrent
71 Just "concurrent" -> setBenchType Concurrent
78 Just "parallel" -> setBenchType Parallel
72 Just "parallel" -> setBenchType Parallel
@@ -226,9 +220,11 @@ showComparisons Options{..} cfg inp out =
226
220
227 where
221 where
228
222
223+ dropComponent = dropWhile (== '/') . dropWhile (/= '/')
224+
229 classifyComparison b = Just $
225 classifyComparison b = Just $
230 ( takeWhile (/= '/') b
226 ( takeWhile (/= '/') b
231− , dropWhile (== '/') $ dropWhile (/= '/') b
227+ , dropComponent b
232 )
228 )
233
229
234------------------------------------------------------------------------------
230------------------------------------------------------------------------------
@@ -291,21 +287,6 @@ main = do
291 (makeStreamComparisonGraphs "nested-concurrent" nestedBenchPrefixes)
287 (makeStreamComparisonGraphs "nested-concurrent" nestedBenchPrefixes)
292 "charts/nested-concurrent/results.csv"
288 "charts/nested-concurrent/results.csv"
293 "charts/nested-concurrent"
289 "charts/nested-concurrent"
294− ParserD -> benchShow opts cfg
295− { title = Just "ParserD" }
296− (makeGraphs "parserD")
297− "charts/parserD/results.csv"
298− "charts/parserD"
299− ParserK -> benchShow opts cfg
300− { title = Just "ParserK" }
301− (makeGraphs "parserK")
302− "charts/parserK/results.csv"
303− "charts/parserK"
304− Parser -> benchShow opts cfg
305− { title = Just "Parser" }
306− (makeGraphs "parser")
307− "charts/parser/results.csv"
308− "charts/parser"
309 FileIO -> benchShow opts cfg
290 FileIO -> benchShow opts cfg
310 { title = Just "File IO" }
291 { title = Just "File IO" }
311 (makeGraphs "fileIO")
292 (makeGraphs "fileIO")
benchmark/Streamly/Benchmark/Data/Parser.hs+13−14
@@ -221,8 +221,11 @@ parseIterate =
221-- Benchmarks
221-- Benchmarks
222-------------------------------------------------------------------------------
222-------------------------------------------------------------------------------
223
223
224−o_1_space_serial_parse :: Int -> [Benchmark]
224+moduleName :: String
225−o_1_space_serial_parse value =
225+moduleName = "Data.Parser"
226+
227+o_1_space_serial :: Int -> [Benchmark]
228+o_1_space_serial value =
226 [ benchIOSink value "any" $ any value
229 [ benchIOSink value "any" $ any value
227 , benchIOSink value "all" $ all value
230 , benchIOSink value "all" $ all value
228 , benchIOSink value "take" $ take value
231 , benchIOSink value "take" $ take value
@@ -242,8 +245,8 @@ o_1_space_serial_parse value =
242 , benchIOSink value "parseIterate" parseIterate
245 , benchIOSink value "parseIterate" parseIterate
243 ]
246 ]
244
247
245−o_n_heap_serial_parse :: Int -> [Benchmark]
248+o_n_heap_serial :: Int -> [Benchmark]
246−o_n_heap_serial_parse value =
249+o_n_heap_serial value =
247 [
250 [
248 -- lookahead benchmark holds the entire input till end
251 -- lookahead benchmark holds the entire input till end
249 benchIOSink value "lookAhead" $ lookAhead value
252 benchIOSink value "lookAhead" $ lookAhead value
@@ -278,16 +281,12 @@ main = do
278 where
281 where
279
282
280 allBenchmarks value =
283 allBenchmarks value =
281− [ bgroup "o-1-space"
284+ [ bgroup (o_1_space_prefix moduleName) $ concat
282− [ bgroup "parser" $ concat
283− [
285+ [
284− o_1_space_serial_parse value
286+ o_1_space_serial value
285− ]
286 ]
287 ]
287− , bgroup "o-n-heap"
288+ , bgroup (o_n_heap_prefix moduleName) $ concat
288− [ bgroup "parser" $ concat
289− [
289+ [
290− o_n_heap_serial_parse value
290+ o_n_heap_serial value
291− ]
292 ]
291 ]
293 ]
292 ]
benchmark/Streamly/Benchmark/Data/ParserD.hs → benchmark/Streamly/Benchmark/Data/Parser/ParserD.hsrenamed+18−21
@@ -177,8 +177,11 @@ choice value =
177-- Benchmarks
177-- Benchmarks
178-------------------------------------------------------------------------------
178-------------------------------------------------------------------------------
179
179
180−o_1_space_serial_parse :: Int -> [Benchmark]
180+moduleName :: String
181−o_1_space_serial_parse value =
181+moduleName = "Data.Parser.ParserD"
182+
183+o_1_space_serial :: Int -> [Benchmark]
184+o_1_space_serial value =
182 [ benchIOSink value "any" $ any value
185 [ benchIOSink value "any" $ any value
183 , benchIOSink value "all" $ all value
186 , benchIOSink value "all" $ all value
184 , benchIOSink value "take" $ take value
187 , benchIOSink value "take" $ take value
@@ -193,8 +196,8 @@ o_1_space_serial_parse value =
193 , benchIOSink value "longest (all,any)" $ longestAllAny value
196 , benchIOSink value "longest (all,any)" $ longestAllAny value
194 ]
197 ]
195
198
196−o_n_heap_serial_parse :: Int -> [Benchmark]
199+o_n_heap_serial :: Int -> [Benchmark]
197−o_n_heap_serial_parse value =
200+o_n_heap_serial value =
198 [
201 [
199 -- lookahead benchmark holds the entire input till end
202 -- lookahead benchmark holds the entire input till end
200 benchIOSink value "lookAhead" $ lookAhead value
203 benchIOSink value "lookAhead" $ lookAhead value
@@ -206,8 +209,8 @@ o_n_heap_serial_parse value =
206 ]
209 ]
207
210
208-- accumulate results in a list in IO
211-- accumulate results in a list in IO
209−o_n_space_serial_parse :: Int -> [Benchmark]
212+o_n_space_serial :: Int -> [Benchmark]
210−o_n_space_serial_parse value =
213+o_n_space_serial value =
211 [ benchIOSink value "sequenceA/100" $ sequenceA (value `div` 100)
214 [ benchIOSink value "sequenceA/100" $ sequenceA (value `div` 100)
212 , benchIOSink value "sequenceA_/100" $ sequenceA_ (value `div` 100)
215 , benchIOSink value "sequenceA_/100" $ sequenceA_ (value `div` 100)
213 , benchIOSink value "sequence/100" $ sequence (value `div` 100)
216 , benchIOSink value "sequence/100" $ sequence (value `div` 100)
@@ -226,22 +229,16 @@ main = do
226 where
229 where
227
230
228 allBenchmarks value =
231 allBenchmarks value =
229− [ bgroup "o-1-space"
232+ [ bgroup (o_1_space_prefix moduleName) $ concat
230− [ bgroup "parser" $ concat
231− [
233+ [
232− o_1_space_serial_parse value
234+ o_1_space_serial value
233− ]
234 ]
235 ]
235− , bgroup "o-n-heap"
236+ , bgroup (o_n_heap_prefix moduleName) $ concat
236− [ bgroup "parser" $ concat
237− [
237+ [
238− o_n_heap_serial_parse value
238+ o_n_heap_serial value
239− ]
240 ]
239 ]
241− , bgroup "o-n-space"
240+ , bgroup (o_n_space_prefix moduleName) $ concat
242− [ bgroup "parser" $ concat
243− [
241+ [
244− o_n_space_serial_parse value
242+ o_n_space_serial value
245− ]
246 ]
243 ]
247 ]
244 ]
benchmark/Streamly/Benchmark/Data/ParserK.hs → benchmark/Streamly/Benchmark/Data/Parser/ParserK.hsrenamed+11−12
@@ -121,15 +121,18 @@ choice value =
121-- Benchmarks
121-- Benchmarks
122-------------------------------------------------------------------------------
122-------------------------------------------------------------------------------
123
123
124−o_1_space_serial_parse :: Int -> [Benchmark]
124+moduleName :: String
125−o_1_space_serial_parse value =
125+moduleName = "Data.Parser.ParserK"
126+
127+o_1_space_serial :: Int -> [Benchmark]
128+o_1_space_serial value =
126 [ benchIOSink value "any" $ anyK value
129 [ benchIOSink value "any" $ anyK value
127 , benchIOSink value "splitApp" $ splitApp value
130 , benchIOSink value "splitApp" $ splitApp value
128 ]
131 ]
129
132
130-- O(n) heap beacuse of accumulation of the list in strict IO monad?
133-- O(n) heap beacuse of accumulation of the list in strict IO monad?
131−o_n_heap_serial_parse :: Int -> [Benchmark]
134+o_n_heap_serial :: Int -> [Benchmark]
132−o_n_heap_serial_parse value =
135+o_n_heap_serial value =
133 [ benchIOSink value "sequenceA" $ sequenceA value
136 [ benchIOSink value "sequenceA" $ sequenceA value
134 , benchIOSink value "sequenceA_" $ sequenceA_ value
137 , benchIOSink value "sequenceA_" $ sequenceA_ value
135 , benchIOSink value "sequence" $ sequence value
138 , benchIOSink value "sequence" $ sequence value
@@ -150,14 +153,10 @@ main = do
150 where
153 where
151
154
152 allBenchmarks value =
155 allBenchmarks value =
153− [ bgroup "o-1-space"
156+ [ bgroup (o_1_space_prefix moduleName) $ concat
154− [ bgroup "parserK" $ concat
157+ [ o_1_space_serial value
155− [ o_1_space_serial_parse value
156− ]
157 ]
158 ]
158− , bgroup "o-n-heap"
159+ , bgroup (o_n_heap_prefix moduleName) $ concat
159− [ bgroup "parserK" $ concat
160+ [ o_n_heap_serial value
160− [ o_n_heap_serial_parse value
161− ]
162 ]
161 ]
163 ]
162 ]
benchmark/streamly-benchmarks.cabal+12−15
@@ -190,32 +190,31 @@ benchmark serial
190 build-depends: lib-prelude
190 build-depends: lib-prelude
191 buildable: True
191 buildable: True
192
192
193−benchmark Data.Fold
193+benchmark unfold
194 import: bench-options
194 import: bench-options
195 type: exitcode-stdio-1.0
195 type: exitcode-stdio-1.0
196− hs-source-dirs: Streamly/Benchmark/Data
196+ hs-source-dirs: ., Streamly/Benchmark/Data
197− main-is: Fold.hs
197+ main-is: Unfold.hs
198+ other-modules: Streamly.Benchmark.Data.NestedUnfoldOps
198 if impl(ghcjs)
199 if impl(ghcjs)
199 buildable: False
200 buildable: False
200 else
201 else
201 buildable: True
202 buildable: True
202
203
203−benchmark unfold
204+benchmark Data.Fold
204 import: bench-options
205 import: bench-options
205 type: exitcode-stdio-1.0
206 type: exitcode-stdio-1.0
206− hs-source-dirs: ., Streamly/Benchmark/Data
207+ hs-source-dirs: Streamly/Benchmark/Data
207− main-is: Unfold.hs
208+ main-is: Fold.hs
208− other-modules: Streamly.Benchmark.Data.NestedUnfoldOps
209 if impl(ghcjs)
209 if impl(ghcjs)
210 buildable: False
210 buildable: False
211 else
211 else
212 buildable: True
212 buildable: True
213
213
214−benchmark parserD
214+benchmark Data.Parser.ParserD
215 import: bench-options
215 import: bench-options
216 type: exitcode-stdio-1.0
216 type: exitcode-stdio-1.0
217− ghc-options: -with-rtsopts "-T -K64K -M16M"
218− hs-source-dirs: ., Streamly/Benchmark/Data
217+ hs-source-dirs: Streamly/Benchmark/Data/Parser
219 main-is: ParserD.hs
218 main-is: ParserD.hs
220 if impl(ghcjs)
219 if impl(ghcjs)
221 buildable: False
220 buildable: False
@@ -223,11 +222,10 @@ benchmark parserD
223 buildable: True
222 buildable: True
224 build-depends: exceptions >= 0.8 && < 0.11
223 build-depends: exceptions >= 0.8 && < 0.11
225
224
226−benchmark parserK
225+benchmark Data.Parser.ParserK
227 import: bench-options
226 import: bench-options
228 type: exitcode-stdio-1.0
227 type: exitcode-stdio-1.0
229− ghc-options: -with-rtsopts "-T -K128K -M32M"
230− hs-source-dirs: Streamly/Benchmark/Data
228+ hs-source-dirs: Streamly/Benchmark/Data/Parser
231 main-is: ParserK.hs
229 main-is: ParserK.hs
232 if impl(ghcjs)
230 if impl(ghcjs)
233 buildable: False
231 buildable: False
@@ -235,10 +233,9 @@ benchmark parserK
235 buildable: True
233 buildable: True
236 build-depends: exceptions >= 0.8 && < 0.11
234 build-depends: exceptions >= 0.8 && < 0.11
237
235
238−benchmark parser
236+benchmark Data.Parser
239 import: bench-options
237 import: bench-options
240 type: exitcode-stdio-1.0
238 type: exitcode-stdio-1.0
241− ghc-options: -with-rtsopts "-T -K128K -M32M"
242 hs-source-dirs: Streamly/Benchmark/Data
239 hs-source-dirs: Streamly/Benchmark/Data
243 main-is: Parser.hs
240 main-is: Parser.hs
244 if impl(ghcjs)
241 if impl(ghcjs)