Commit Graph

417 Commits

Author SHA1 Message Date
Pranay Sashank
960def155f Make the finalizer based exception handling routines the default.
- Change the handlers for both streams and unfolds.
2020-08-23 11:50:59 +05:30
Harendra Kumar
1639cfde98 Use monadic action to get the initial state
In ReaderT/StateT evaluation.
2020-08-19 19:41:08 +05:30
adithyaov
ead1601148 Replace Data.Strict with Data.*.Strict
"Streamly.Internal.Data.Strict" is replaced by:
Streamly.Internal.Data.Tuple.Strict
Streamly.Internal.Data.Maybe.Strict
Streamly.Internal.Data.Either.Strict

This commit also has some formatting changes to imports.
2020-08-14 20:25:52 +05:30
pranaysashank
d93ac86607 Drop support for GHC 7.10.3. 2020-08-12 11:24:34 +05:30
Harendra Kumar
ec97cec4d2 Fix the backtrack buffer management for fromParserK
This commit results in worse performance because now we are double
buffering once in ParserD and once in ParserK. This can potentially be
fixed but would require bigger changes to unify the backtracking buffer
management for ParserD and ParserK.
2020-08-02 16:26:46 +05:30
adithyaov
ef7c6d9633 Skip building Array.Prim.* modules for ghc < 8.0
getSizeofMutableByteArray# does not exist for versions of ghc below 8
2020-07-21 09:13:31 +05:30
adithyaov
4d0631a0c6 Add Data.Array.Prim.Pinned and Data.Array.Prim
Respect the new module structure for Internal files
2020-07-21 09:13:31 +05:30
adithyaov
27c3aebbce Combine all the array benchmarks to reduce duplication
Use --stream-size for all the array benchmarks now

Replace the following files:
- benchmark/Streamly/Benchmark/Data/Array.hs
- benchmark/Streamly/Benchmark/Data/ArrayOps.hs
- benchmark/Streamly/Benchmark/Data/Prim/Array.hs
- benchmark/Streamly/Benchmark/Data/Prim/ArrayOps.hs
- benchmark/Streamly/Benchmark/Data/SmallArray.hs
- benchmark/Streamly/Benchmark/Data/SmallArrayOps.hs
- benchmark/Streamly/Benchmark/Memory/Array.hs
- benchmark/Streamly/Benchmark/Memory/ArrayOps.hs
With:
- benchmark/Streamly/Benchmark/Array.hs
- benchmark/Streamly/Benchmark/ArrayOps.hs
2020-07-20 01:44:18 +05:30
Harendra Kumar
f0398ee8b6 Add benchmarking for fromParserK 2020-07-17 03:46:04 +05:30
Harendra Kumar
37f325e4b2 Add some more benchmarks for ParserK 2020-07-17 03:46:04 +05:30
Harendra Kumar
81339c8f8b Fix comments 2020-07-13 23:58:02 +05:30
Harendra Kumar
09f2fa7cb4 Add the ability to select fields to report 2020-07-09 17:40:27 +05:30
Harendra Kumar
89b9e233ba Fix inspection tests 2020-07-09 17:40:27 +05:30
Harendra Kumar
bc6b4eed32 Reduce compile time mem util in Handle benchmarks
* Split into two modules
* Remove unnecessary INLINE pragmas
2020-07-09 17:40:27 +05:30
Harendra Kumar
0d586750a7 Add INLINE phase annotations on some functions 2020-07-09 16:10:24 +05:30
Harendra Kumar
53504dba3c Use smaller input files for longer benchmarks 2020-07-09 16:10:01 +05:30
Harendra Kumar
3d033ae915 Reorganize, move the FileIO benchmarks
Now they are in FileSystem.Handle module corresponding to the source module
with the same name. Also, now we have them arranged based on space complexity
so that we can apply RTS memory restrictions when running.

Also, now longer benchmarks use a shorter file.
2020-07-08 03:10:09 +05:30
Harendra Kumar
ea79e0f9b7 Add "allocated" and "bytesCopied" fields
"allocated" is much more stable for regression comparisons as it stays the same
whereas "time" varies based on various factors like cpu frequency, other things
running on the computer, context switches etc.

bytesCopied is a measure of long lived data being retained across GCs, which is
also a good measure of performance.
2020-07-07 16:23:06 +05:30
pranaysashank
202f674462 Change the signature of foldlM' to use a monadic seed.
- Also change usages of foldlM' in tests and benchmarks.
2020-07-07 14:17:44 +05:30
Harendra Kumar
55d49bd50c Optimize Functor/Applicative/Monad etc for serial
Some of the benchmarks were order of magnitude off due to missing INLINE for
type class operations. Now, all of them are in reasonable limits. Benchmarks
affected for serial streams:

* Functor, Applicative, Monad, transformers

We need to do a similar exercise for other types of streams and for
folds/parsers as well.
2020-06-23 13:41:41 +05:30
Harendra Kumar
b4cef11d19 Add iterative benchmarks for Functor/transformers
* Also factor out the existing iteration utilities and use the same everywhere
2020-06-23 13:01:25 +05:30
Harendra Kumar
1a331cb402 Add more benchmarks for applicative/monad
Separate the applicative and monad benchmark groups
Complete benchmarks for all type class operations
2020-06-21 15:15:55 +05:30
Harendra Kumar
1cccb00101 Use foldrSShared instead of foldrS for Async
Because of not sharing the SVar foldrS performs poorly for Async streams and
has quadratic complexity.
2020-06-21 11:28:59 +05:30
Harendra Kumar
c0bd11de4b Elaborate concatMap, async benchmarks
* Add 3 interesting cases for each concatMap case
* For mapM, map concurrently on a serial stream so that we measure the
  concurrency overhead of mapM only and not both concurrent generation + mapM
* For Async streams add some benchmarks involving the `async` combinator.
* Add a benchmark for `foldrS`
2020-06-21 11:28:59 +05:30
Harendra Kumar
f9a7d24230 Fix perf regression in zip/zipM benchmarks 2020-06-08 18:52:06 +05:30
Harendra Kumar
354f337c80 Fix performance of monad-outer-product benchmarks 2020-06-08 14:37:52 +05:30
Harendra Kumar
294aa21417 Disable some broken benchmarks 2020-06-07 18:34:40 +05:30
Harendra Kumar
75903a101a Update with new changes in benchmaring script 2020-06-07 10:28:15 +05:30
Harendra Kumar
dc68afd167 Fix inspection testing 2020-06-07 10:27:58 +05:30
Harendra Kumar
129ebaf82c Refactor Prelude benchmarks
* Now benchmark modules correspond to source modules. The Prelude module in
  source corresponds to several modules one for each stream type.

* Benchmarks in the same order/groupings as they appear in source

* All benchmarks now have division according to space complexity

* Refactoring reduces a lot of code duplication especially the stream
  generation and elimination functions.

* The RTS options are now completely set in the shell script to run the
  benchmarks.

* RTS options can be set on a per benchmark basis. RTS options work correctly
  now.

* The set of streaming/infinite stream benchmarks is now complete and we can
  run all such benchmarks coneveniently.

* Benchmark "quick"/"speed" options can now be specified on a per benchmark
  basis. Longer benchmarks can have fewer iterations/quick run time.

* Benchmarks are grouped in several groups which can be run on a per group
  basis. Comparison groups are also defined for convenient comparisons of
  different modules (e.g. arrays or streamD/K).

* The benchmark namespaces are grouped in a consistent manner. Benchmark
  executables have a consistent naming based on module names.
2020-06-07 01:48:05 +05:30
Harendra Kumar
ed799d6b51 Fix unfold benchmark name, namespace, RTS options 2020-06-07 01:26:34 +05:30
Harendra Kumar
c2def514f9 Fix parser benchmark namespace and RTS options
Also, rename the benchmark modules to reflect source module hierarchy.
2020-06-07 01:26:34 +05:30
Harendra Kumar
0b83f5d445 Fix benchmark name space for fold benchmarks
Use Data.Fold/o-1-space/...
2020-06-07 01:17:43 +05:30
Harendra Kumar
c2fa79613e Generalize group/comparative benchmarking 2020-06-07 01:17:43 +05:30
Harendra Kumar
f72d007c51 Rename array benchmarks and prefixes by module names 2020-06-07 01:17:43 +05:30
Harendra Kumar
1c57096c3c Split "base" benchmark into per module benchmarks
Also, use module name prefix on the benchmarks.
2020-06-07 01:17:43 +05:30
adithyaov
ae7a0250cd Split lib/b/Prelude into Generation, Elimination and Transformation 2020-06-07 01:17:42 +05:30
adithyaov
cf8ec5cc91 Rename o_1_space_parallel* to o_n_space_parallel* 2020-06-07 01:09:26 +05:30
adithyaov
e7df8acee3 Merge all the base* executables 2020-06-07 01:09:26 +05:30
adithyaov
0d66526074 Add a standard behaviour to Chart.hs 2020-06-07 01:09:26 +05:30
adithyaov
9abd8b84b6 Merge all the Serial/* benchmarks into Serial.hs 2020-06-07 01:09:26 +05:30
Harendra Kumar
b90107f15b Fix build for older versions of GHC 2020-06-03 23:30:04 +05:30
Harendra Kumar
01fa925af3 rename mconcatTo to sconcat 2020-05-31 01:46:01 +05:30
Harendra Kumar
07efcbd671 Add benchmark for classifySessionsOf 2020-05-28 19:16:01 +05:30
Harendra Kumar
602539f613 Add/change some time/interspersing combinators
Add: intersperseSuffix_, delay, timeIndexed
Change the APIs: times, absTimes, relTimes, timestamped

The new APIs have a default clock granularity of 10 ms.
2020-05-28 16:26:59 +05:30
Harendra Kumar
7f9d4a4210 Add some time related combinators
add: times, relTimes, timestamped
unimplemented skeletons: durations, ticks, timeout

Changes to the original currentTime combinator: remove delay from the first
event, cap the granularity to 1 ms to guarantee reasonable cpu usage.
2020-05-27 12:21:54 +05:30
Harendra Kumar
aa25b34db0 Add benchmarks for *>, <*, split_, sequence_ 2020-05-11 21:25:24 +05:30
Harendra Kumar
2c9feb48ef Add YieldB (yield and backtrack) constructor
This fixes an issue in many/some/manyTill combinators.
2020-05-11 21:25:24 +05:30
Harendra Kumar
633c55eb31 rename splitParse/parseMany, concatParse/parseIterate 2020-05-11 21:18:09 +05:30
Harendra Kumar
684d2786eb Add concatParse to chain parsers on a stream
Add mconcatTo, update fold docs
Add fold docs/snippets using Monoids.
Add benchmark for sum using foldMap
Add concatParse benchmark
Add splitParseTill, update docs
2020-05-11 20:54:22 +05:30
Harendra Kumar
899cab5cd4 Make License Identifier SPDX compliant 2020-04-24 03:57:46 +05:30
Harendra Kumar
d7866f732d INLINE some/many implement *>/<*
Benchmarks that improved:

ParserK(cpuTime)
Benchmark                   default(0)(μs) default(1) - default(0)(%)
--------------------------- -------------- --------------------------
o-n-heap/parserK/sequenceA_       11183.17                     -32.75
o-n-heap/parserK/manyAlt          41514.00                     -40.82
o-n-heap/parserK/someAlt          68026.25                     -61.77
2020-04-24 02:59:40 +05:30
Harendra Kumar
dde9041833 Use parserK by default and rewrite to ParserD 2020-04-24 00:30:01 +05:30
Harendra Kumar
a03e2872a6 rename Parser module to ParserD
The top level module "Parser" will be using both ParserK and ParserD.
2020-04-24 00:30:01 +05:30
Harendra Kumar
12fef4390f Add a CPS style parser implementation
CPS performs much better for parsing operations like "sequence" and
"choice" on large containers. Given that applicative "sequence" does
not scale, I guess the Monad instance as well won't scale for direct
implementation.
2020-04-24 00:30:01 +05:30
Pranay Sashank
451239bf9c Bump template-haskell upper bound < 2.17.
- GHC 8.10.1 ships with template-haskell 2.16.
2020-04-20 17:29:07 +05:30
Harendra Kumar
f51bbb25bd Rename some parsers and add some TBD and comments 2020-04-16 23:11:49 +05:30
Harendra Kumar
c8bbb0a1c8 Add lookAhead 2020-04-16 23:11:22 +05:30
Harendra Kumar
5f4de8630c add benchmark for takeWhile 2020-04-16 23:10:50 +05:30
Harendra Kumar
88e55f7051 Add Monad and MonadPlus instances 2020-04-16 21:15:02 +05:30
Harendra Kumar
fc24e44be1 fix ci to build benchmarks as well 2020-04-16 18:21:04 +05:30
Harendra Kumar
202c33d6e8 Add Alternative instance, combinators and parsers
parsers: peek, satisfy, eof, yield, yieldM, die, dieM
combinators: shortest, longest, alt, many, some, manyTill
2020-04-14 23:34:08 +05:30
Harendra Kumar
8921064283 Add teeWith - distribute input to 2 parsers
This is perhaps not an ideal implementation but something to play with.
2020-04-14 22:51:53 +05:30
Harendra Kumar
f6327e5b31 Use exceptions instead of Either return in extract
Also instead of returning wrapped state in "Stop" return type, return
the final extracted value.

  a) This makes a lot of code simpler because extract and error handling
     is not required at Stop.

  b) Not returning internal state indicates that the parse has ended and
     state is not supposed to be used from this point onwards.

  c) It may add a little complexity in the parser code as the parser has to
     extract the value from state at Stop.

  d) However, extract is still needed. But it is only needed if the fold
     remains partial when the stream stops. In such case we may have to
     use exception handling to detect error, and to distinguish the parse
     errors from any other types of errors. But since this is not common
     case it does not come in the fast path.

Note that we could remove extract altogether but that means we will have to
store the intermediate fold values in the driver loop which impacts
performance.
2020-04-14 22:51:53 +05:30
Harendra Kumar
f1eb9a18c2 rename parseChunks to splitParse 2020-04-09 04:19:00 +05:30
Harendra Kumar
b9c461f7b9 rename some parsers, add some parsers
rename endOn etc to sepBy etc.
add sepByMax
add unimplemented skeletons for wordBy, groupBy
2020-04-09 04:19:00 +05:30
Harendra Kumar
252e08eb51 Add parser benchmarks 2020-04-09 04:19:00 +05:30
Harendra Kumar
94459757dd Fix dates/typo/Functor instance 2020-04-09 04:06:57 +05:30
Harendra Kumar
136bf79bab Rename Parse type and Step constructors
Parse => Parser
Keep => Yield
Back => Skip
2020-04-09 04:06:57 +05:30
Harendra Kumar
cc8cd01bfe Simplify the Parse type
* Return the unused count in Halt instead of in extract.
* Use "Back 0" instead of "Hold"

Performance seems equivalent with these changes.
2020-04-09 04:06:57 +05:30
Harendra Kumar
df633139c2 Move benchmark code for parsers to its own module 2020-04-09 04:06:57 +05:30
Harendra Kumar
2723c15d36 Implement stream parsing
This is the initial version of stream parsing. It implements a "Parse"
type, some parsers based on that type, applicative composition, operations to
run parsers (parse) and to run parsers over chunks of a stream (parseChunks).

Parsers are just an extension of Folds in Streamly.Data.Fold. Parsers just add
backtracking and failure capabilities to folds.

Operations like splitOn to split a stream on a predicate can now be expressed
using a parser applied repeatedly on a stream. For example, line splitting can
be done using parsers. Parsers are as fast as fastest custom code for
line splitting.
2020-04-09 04:06:57 +05:30
adithyaov
08d1dd0670 Remove unecessary paths from hs-src-dirs 2020-04-08 19:38:33 +05:30
adithyaov
633e88f8c5 Move unfold benchmarks out of prelude. Make a seperate exec. 2020-04-08 19:38:33 +05:30
adithyaov
24e481c00a Mv multiple modules from b/ to b/Streamly/Benchmark/Prelude
benchmark/Adaptive.hs -> benchmark/Streamly/Benchmark/Prelude/Adaptive.hs
benchmark/Concurrent.hs -> benchmark/Streamly/Benchmark/Prelude/Concurrent.hs
benchmark/LinearAsync.hs -> benchmark/Streamly/Benchmark/Prelude/LinearAsync.hs
benchmark/LinearRate.hs -> benchmark/Streamly/Benchmark/Prelude/LinearRate.hs
benchmark/NestedConcurrent.hs -> benchmark/Streamly/Benchmark/Prelude/NestedConcurrent.hs
benchmark/Parallel.hs -> benchmark/Streamly/Benchmark/Prelude/Parallel.hs
2020-04-08 19:38:33 +05:30
adithyaov
18949ef414 Move b/NestedOps.hs and b/NestedUnfoldOps.hs to b/Streamly/Benchmark 2020-04-08 19:38:33 +05:30
adithyaov
82e19d6cea Move benchmark/Array* to benchmark/Streamly/Benchmark/Memory/* 2020-04-08 19:38:33 +05:30
adithyaov
b6d787fac1 Multiple changes corresponding to the fold benchmark.
1. Removed rts options at compile time for fold benchmark.
2. Added fold-o-1-space and fold-o-1-heap benchmark to bench.sh
3. Added fold-o-1-space and fold-o-1-heap to bench.sh
2020-04-08 15:39:47 +05:30
adithyaov
9797d7615d Make a sandalone fold executable. 2020-03-29 18:40:51 +05:30
adithyaov
18c903f5c4 Seperate folds from Prelude in benchmarks. 2020-03-18 11:31:01 +05:30
adithyaov
f2011dfcd7 Keep signature/pragma and definitions for each benchmark together 2020-03-02 16:59:03 +05:30
Harendra Kumar
5e1736c4f1 Comment out foldlS benchmark
It takes too much time, holding up benchmarking for too long.
2020-02-28 21:20:37 +05:30
Harendra Kumar
6c20dae0cb remove "nested" and "nested-unfold" benchmarks
* These benchmarks no longer exist.
* Also remove some code duplication
2020-02-28 21:20:37 +05:30
Harendra Kumar
e76546fbb1 format some parts of the benchmarking code 2020-02-28 19:58:06 +05:30
adithyaov
1f502b1c1d Prepend unused functions with _ to suppress -Wunused-top-binds 2020-02-28 19:58:06 +05:30
adithyaov
e7c5fd43fe Export all groups in lib/Streamly/Benchmark/Prelude.hs 2020-02-28 19:58:06 +05:30
adithyaov
879d5d5aa5 Merge LinearRate.hs into Prelude.hs
* LinearRate.hs -> lib/Streamly/Benchmark/Prelude.hs
* Modify LinearRate.hs accordingly
2020-02-28 19:58:06 +05:30
adithyaov
7f5c73f645 Merge Parallel.hs into Prelude.hs
* Parallel.hs -> lib/Streamly/Benchmark/Prelude.hs
* Modify Parallel.hs accordingly
2020-02-28 19:58:06 +05:30
adithyaov
fa8a2cf867 Merge LinearAsync.hs into Prelude.hs
* LinearAsync.hs -> lib/Streamly/Benchmark/Prelude.hs
* Modify LinearAsync.hs accordingly
2020-02-28 19:58:06 +05:30
adithyaov
b62c02f44a Merge O_n_Stack.hs into Prelude.hs
* Benchmark/Prelude/Serial/O_n_Stack ->
  lib/Streamly/Benchmark/Prelude.hs
* Modify O_n_Stack.hs accordingly
2020-02-28 19:58:06 +05:30
adithyaov
69a81af68d Merge O_n_Heap.hs into Prelude.hs
* Benchmark/Prelude/Serial/O_n_Heap ->
  lib/Streamly/Benchmark/Prelude.hs
* Modify O_n_Heap.hs accordingly
2020-02-28 19:58:06 +05:30
adithyaov
8544b1f1e7 Merge O_n_Space.hs into Prelude.hs
* Benchmark/Prelude/Serial/O_n_Space ->
  lib/Streamly/Benchmark/Prelude.hs
* Modify O_n_Space.hs accordingly
2020-02-28 19:58:06 +05:30
adithyaov
4d59cb3afe Merge lib/B/Groups.hs into lib/B/Prelude.hs
* Remove lib/B/Group.hs
* The idea: Have all the groups in Prelude and
  export only the groups, that way, all the functions
  aren't compiled multiple times (without and with
  inlining).
2020-02-28 19:58:06 +05:30
adithyaov
2dacf99488 Move and split benchmarks from O_1_Space.hs to Groups.hs
* Streamly/Benchmark/Prelude/O_1_Space.hs ->
lib/Streamly/Benchmark/Groups.hs

* Modify O_1_Space.hs accordingly
2020-02-28 19:58:06 +05:30
Harendra Kumar
eccf24a4b1 Add singletonM, update some docs 2020-02-26 13:44:25 +05:30
Harendra Kumar
678a404311 Add some inspection tests for SPEC constructor 2020-02-22 14:12:49 +05:30
Harendra Kumar
f39b982d24 Disable lib-base build for GHCJS
ghcjs-8.4 seems to be unable to build it.
2020-02-21 17:15:50 +05:30
Harendra Kumar
e36f0702f1 Disable GHCJS build for prelude benchmarks
GHCJS 8.6.5 panics while building lib-prelude
2020-02-21 16:33:49 +05:30
Harendra Kumar
166bd93267 refactor "base" stream benchmarks
push the benchmark definitions from the top level "BaseStreams.hs" file to the
individual stream modules to improve modularity.
2020-02-21 16:32:46 +05:30
Harendra Kumar
ae30f2fc9e classify "base" stream benchmarks by space usage 2020-02-21 16:32:46 +05:30