New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Task/Coeval optimizations #410

merged 9 commits into from Aug 10, 2017


None yet
1 participant

alexandru commented Aug 10, 2017

Given Iterant and its contract of protecting against "user provided code", just like Observable, there are operators like mapEval that need to do handleErrorWith on each F[A] generated for each item of the source, which gets to be fairly expensive, even if the generated F[A] reference does not fail. Substitute F[A] for Task[A], Coeval[A], IO[A], etc.

Did some optimizations to improve the performance of handleErrorWith that are never applied due to the source not failing. For Coeval the results are fantastic, being indeed a no-op (see happyPath and compare it with justFlatMap):

Coeval Benchmark Monix 2.3.0 Monix 3.0.0 Units
handleError 2342.724 2507.869 ops/s
happyPath 2701.378 6014.069
justFlatMap 5948.891 6069.314

On the other hand, for Task I didn't get the same improvements, only marginal ones and I suspect this has more to do with the upgraded Scala compiler and options (2.12.3):

Task Benchmark Monix 2.3.0 Monix 3.0.0 Units
handleError 2440.088 2545.118 ops/s
happyPath 2650.043 2748.336
justFlatMap 6078.617 6468.674

This is a puzzle actually, because the code for both Coeval and Task is really, really similar and I've introduced the same optimizations.

The effort is not lost on Task though. Due to multiple trials and errors, I managed to remove some memory inefficiency, so due to these improvements a flatMap loop should create less junk.


This comment has been minimized.

codecov bot commented Aug 10, 2017

Codecov Report

Merging #410 into master will increase coverage by 0.03%.
The diff coverage is 96.87%.

@@            Coverage Diff             @@
##           master     #410      +/-   ##
+ Coverage    88.2%   88.23%   +0.03%     
  Files         336      336              
  Lines        9069     9135      +66     
  Branches     1232     1233       +1     
+ Hits         7999     8060      +61     
- Misses       1070     1075       +5

@alexandru alexandru merged commit 9845f5f into monix:master Aug 10, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

@alexandru alexandru added this to the 3.0.0 milestone Jan 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment