Commit Graph

1500 Commits

Author SHA1 Message Date
Harendra Kumar
d35674ea02 Change the order of yld and stp continuations
The names were incorrect as per the definition of the type. This problem
occurred because the order of the arguments was changed at some point but we
missed changing these.
2020-01-19 22:15:05 +05:30
Harendra Kumar
bee5f1d70e Add tail recursion suggestion for optimization 2020-01-19 14:20:28 +05:30
Harendra Kumar
a3c32bc716 Fix foldStreamSVar space leak
Use tail recursion in the worker loops. Run the work item under the saved
monadic state and restore the state after the work is done and before the next
work item is picked.

Benchmarks:

* asyncly/unfoldrM maxThreads 1
* wAsyncly/unfoldrM maxThreads 1
* aheadly/unfoldrM maxThreads 1
2020-01-19 14:19:16 +05:30
Harendra Kumar
37452d9ff9 Do not lose stream state in ahead stream
When executing a stream in ahead composition where we have composed multiple
streams using `ahead`, we are executing each element of the stream using the
fresh state from SVar at the fork point. This fix changes it such that we only
use the fresh state from SVar only at the start of stream execution and not for
each element of the stream. When yielding subsequent elements we have to carry
any state changes made when we yielded the previous elements.
2020-01-18 18:01:31 +05:30
Harendra Kumar
60cee489ae Add exception handling combinators with guaranteed cleanup
The "after", "finally" and "bracket" combinators did not run the "cleanup"
handler in case the stream is lazily partially evaluated e.g. using the lazy
right fold (foldrM), "Streamly.Prelude.head" is an example of such a fold.

Since we run the cleanup action when the stream Stops, the action won't be run
if the stream is not fully drained.

In the new implementation, we use a GC hook to run the cleanup action in case
the stream got garbage collected even before finishing. This will take care of
the lazy right fold cases mentioned above.
2020-01-18 15:02:34 +05:30
Harendra Kumar
f5c55df294 separate "parallel" style benchmarks
As they are not "streaming" and take much longer compared to other concurrent
streams.
2020-01-18 03:06:08 +05:30
Harendra Kumar
fdf7e1fdf9 increase the stream size for linear-async benchmarks
This is to make it the same as other benchmarks. We had to change the size of
the extreme concatMapWith benchmark to keep it in reasonable time limits.
2020-01-16 18:50:30 +05:30
Harendra Kumar
22bfa72599 Add a middle point for concatMapWith benchmark
* We are testing two extreme cases, add a middle case as well where the outer
  and inner streams are of equal size.

* Enable some pure benchmarks as well

* Separate the zip benchmarks in a separate group as they are scalable
  (memory consumption does not increase with stream size) and parallel
  benchmarks are not scalable.
2020-01-16 18:50:30 +05:30
Harendra Kumar
afc02e6970 separate const mem benchmarks from buffered ones
Streaming benchmarks take constant memory whereas the buffering ones take
memory proportional to the stream size. We would like to test them separately.
For streaming benchmarks we can use a very large stream size to make sure there
is no space leak and we are running in constant memory for long time.
2020-01-16 18:50:30 +05:30
Harendra Kumar
880a0729ea Run long benchmarks before release 2020-01-16 18:43:26 +05:30
Harendra Kumar
cc07da8fd8 Add long benchmark support 2020-01-16 02:25:10 +05:30
Harendra Kumar
71f61967ee rename nestedUnfold to nested-unfold 2020-01-16 02:25:10 +05:30
Harendra Kumar
eedd741499 pass stream-size from CLI for nested-unfold 2020-01-16 02:25:10 +05:30
Harendra Kumar
54a1fc770a pass stream-size parameter to child process
gauge --measure-with forks a child process for each benchmark. The options
passed to the main gauge process are not passed to the child process. We use an
environment variable to set the stream-size and pass it on to the child
process.
2020-01-16 02:25:10 +05:30
Harendra Kumar
c1cbe1896c mention left folds vs right folds 2020-01-16 02:20:17 +05:30
Harendra Kumar
7e7cc7e2a1 update learning materials section
move the learning materials section to the top for better discoverability.
2020-01-16 02:14:42 +05:30
Harendra Kumar
290d2f6135 Make some updates to takeByTime/dropByTime
* Document the precise behavior, some changes were made to the earlier behavior
* Make some changes to implementation according to (newly) documented behavior
* TakeByTime: perform the time check before generating the element so that we
  do not drop an element after generation.
* TakeByTime now yields at least one element if the duration is non-zero
* dropByTime does not check the time after the drop duration is over
* Add inspection tests
* make the tests for shorter duration, earlier tests took too long
2020-01-16 02:02:37 +05:30
adithyaov
1979370373 Add takeByTime and dropByTime combinators 2020-01-16 02:02:37 +05:30
Harendra Kumar
750c7fe94a add "where" clause, variable naming, StreamD style 2020-01-13 01:24:49 +05:30
Harendra Kumar
83cbe5d14c Add distribute_ 2020-01-09 15:53:47 +05:30
Harendra Kumar
43179a2371 Add notes about abstract and aggregate parent modules 2020-01-08 23:47:43 +05:30
Harendra Kumar
2c77298837 update the examples and add comments 2020-01-08 21:03:20 +05:30
Harendra Kumar
ef958917ee use "seq" on "value"
It improves many benchmarks significantly.
2020-01-08 18:15:43 +05:30
Harendra Kumar
8ec2ebe188 Accept stream size via a CLI option
Use --stream-size to accept the stream size.  The CLI argument position
is not fixed anymore so it can be specified anywhere on the command line. The
remaining arguments are used by gauge.
2020-01-08 18:15:43 +05:30
adithyaov
f684e266af Remove cpp-options that control length in nested*
* This includes nested, nested-concurrent
* Modules removed: nested-concurrent-long
* CPP options removed: -DLONG_BENCHMARKS
2020-01-08 18:15:43 +05:30
adithyaov
65ed762cbc Remove cpp-options that control length in linear*
* This includes linear, linear-async, linear-rate
* Modules removed: linear-long, linear-async-long
* CPP options removed: -DLINEAR_ASYNC
2020-01-08 18:15:43 +05:30
Harendra Kumar
c2b99edba7 update changelog for concurrent perf improvement 2020-01-08 18:07:53 +05:30
Harendra Kumar
1d0193882f remove hidden haddock build options
Now that we have unhidden those.
2020-01-08 02:02:33 +05:30
Pranay Sashank
3422440ba1 Re-enable coverage build on circle ci. 2020-01-07 11:18:21 +05:30
Pranay Sashank
6b6663828f Enable CI builds only for push and PRs to master. 2020-01-07 11:15:25 +05:30
Pranay Sashank
b05f7b43b4 Relax minimum bounds on containers.
- We should try to match any of the core libraries version bounds
with the min and max versions of ghc we support. This would allow
the users to use the library together with another one that uses
the ghc api with ease, preventing any possible version conflicts.
2020-01-06 13:06:57 +05:30
Pranay Sashank
04a3b1e4d4 Add support for Github ci.
- Build using GHC 8.8.1 and 8.6.5 on Github ci.
- Remove the above builds travis.
2020-01-04 20:03:02 +05:30
Harendra Kumar
ff99b4c1d0 Add nested-concurrent benchmark 2020-01-04 16:43:54 +05:30
Pranay Sashank
57c2ddcc34 Strictify Fold accumulator in groupsOf & groupsOf2.
- Update Changelog.md to reflect the change in `chunksOf`.
2020-01-03 12:01:52 +05:30
Pranay Sashank
511828b228 Fix typo in INSTALL.md and disable tests for ghcjs in ci. 2020-01-03 11:54:32 +05:30
Pranay Sashank
5b1da6b36a Update docs. 2020-01-03 11:54:32 +05:30
Pranay Sashank
e3a11ad9d9 Unhide haddock documentation for Internal modules. 2020-01-03 11:54:32 +05:30
adithyaov
5faf292267 Mv bemchmarks & change INLINABLE to INLINE - lastN
* Move benchmarks of lastN under serially/fold
* Changing INLINEABLE to INLINE on lastN allows fusion, increasing the perf
2020-01-02 16:51:43 +05:30
adithyaov
665e7df271 Add & use withForeignPtrM in Ring folds
* BUG fix
* Modified functions: unsafeFoldRingM & unsafeFoldRingFullM
* This does a touchForeignPtr to ringStart after the fold
2020-01-02 16:51:43 +05:30
adithyaov
5aa8e44d24 Add tests to lastN 2020-01-02 16:51:43 +05:30
adithyaov
46643d15b3 Add lastN combinator 2020-01-02 16:51:43 +05:30
Harendra Kumar
b83c2c28fc Add tapOffsetEvery to tap one in n elements 2019-12-31 02:07:02 +05:30
Harendra Kumar
5073377ba9 Add modular stream stats counting
* pollCounts to poll the element count in another thread
* delayPost to introduce a delay in polling
* rollingMap to compute diff of successive elements

These combinators can be used to compute and report the element
processing rate in a stream.
2019-12-31 00:22:41 +05:30
Harendra Kumar
135063fb0c use Prim Var instead of IORef 2019-12-30 19:56:31 +05:30
Harendra Kumar
9710c7b639 Change newVar signature, add modifyVar' 2019-12-30 19:56:31 +05:30
Harendra Kumar
4374014c94 Add fromPrimVar - generate a stream from a Prim Var 2019-12-30 19:56:31 +05:30
Harendra Kumar
97ecb28266 Add a mutable variable for Prim types 2019-12-30 19:56:31 +05:30
adithyaov
d6afd92d98 Add rollingHashFirstN, drainN and drainWhile 2019-12-30 15:57:34 +05:30
adithyaov
511fe85cc6 Use StreamD for iterate and iterateM 2019-12-30 15:37:03 +05:30
adithyaov
0d49be3233 Modify .gitignore 2019-12-30 15:36:35 +05:30