Skip to content
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

2.x: benchmark (0..1).flatMap, andThen & flattenAs performance #6017

Merged
merged 1 commit into from
May 23, 2018

Conversation

akarnokd
Copy link
Member

This PR adds JMH benchmarks to measure the overhead of {Single|Maybe}.flatMap{Publisher|Observable}, {Single|Maybe}.flattenAs{Flowable|Observable} and Completable.andThen({Publisher|Observable}).

Results

on i7 4770K, Windows 7 x64, Java 8u172, JMH 1.20 (larger is better):

comparing based on the final output type

image

Observable should be generally lower overhead yet some cases it has more overhead.

comparing what to flatten

(flatMapHide = without fusion, flatMap = reactive source, flattenAs = list source)

image

The hide case is expected to have the most overhead, yet the two reactive classes have uneven boosts with a supposedly fuseable cases:

image

comparing based on source type

image

Single and Maybe should be practically the same here, yet in some cases Maybe is quite worse. Also Completable should effectively win over the others on each line.


Plenty of optimization opportunities.

@akarnokd akarnokd added this to the 2.2 milestone May 23, 2018
@akarnokd akarnokd changed the title 2.x: benchmark (0..1).flatMap and flattenAs performance 2.x: benchmark (0..1).flatMap, andThen & flattenAs performance May 23, 2018
@codecov
Copy link

codecov bot commented May 23, 2018

Codecov Report

Merging #6017 into 2.x will increase coverage by 0.05%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6017      +/-   ##
============================================
+ Coverage     98.22%   98.28%   +0.05%     
- Complexity     6160     6162       +2     
============================================
  Files           659      659              
  Lines         44519    44519              
  Branches       6201     6201              
============================================
+ Hits          43728    43754      +26     
+ Misses          243      228      -15     
+ Partials        548      537      -11
Impacted Files Coverage Δ Complexity Δ
...java/io/reactivex/processors/PublishProcessor.java 98.19% <0%> (-1.81%) 42% <0%> (-1%)
...perators/mixed/ObservableConcatMapCompletable.java 98.49% <0%> (-1.51%) 3% <0%> (ø)
...internal/operators/flowable/FlowableSwitchMap.java 95.28% <0%> (-1.42%) 3% <0%> (ø)
...l/operators/observable/ObservableFlatMapMaybe.java 89.54% <0%> (-1.31%) 2% <0%> (ø)
...ernal/operators/flowable/FlowableFromIterable.java 95.18% <0%> (-1.07%) 5% <0%> (ø)
...perators/mixed/ObservableSwitchMapCompletable.java 98.94% <0%> (-1.06%) 3% <0%> (ø)
.../operators/mixed/FlowableConcatMapCompletable.java 99.14% <0%> (-0.86%) 2% <0%> (ø)
.../operators/maybe/MaybeFlatMapIterableFlowable.java 97.54% <0%> (-0.82%) 2% <0%> (ø)
...vex/internal/operators/flowable/FlowableCache.java 97.94% <0%> (-0.69%) 10% <0%> (-1%)
...rnal/operators/observable/ObservableSwitchMap.java 94.68% <0%> (-0.54%) 3% <0%> (ø)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ff403e...b428b9f. Read the comment docs.

@akarnokd akarnokd merged commit b9f5ef8 into ReactiveX:2.x May 23, 2018
@akarnokd akarnokd deleted the BinaryFlatMapPerf branch May 23, 2018 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant