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: Optimize ObservableConcatMapCompletable #5915

Merged
merged 1 commit into from
Mar 15, 2018

Conversation

akarnokd
Copy link
Member

This PR reduces the overhead in the Observable.concatMapCompletable operator by:

  • adding front-queue fusion to eliminate queue allocations (although this didn't improve the performance beyond a +/- 3% noise),
  • moving the error and errorMode fields into local variables, saving on the mandatory volatile re-read of other fields,
  • adding a scalar shortcut in case the upstream is known to be 0-1.

Benchmark comparison:

i7 4770K, Windows 7 x64, Java 8u162

The PR improves the dedicated case considerably:

image

and it is now better across the board compared to a toFlowable conversion and the main concatMap:

image

@akarnokd akarnokd added this to the 2.2 milestone Mar 15, 2018
@codecov
Copy link

codecov bot commented Mar 15, 2018

Codecov Report

Merging #5915 into 2.x will decrease coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##                2.x   #5915      +/-   ##
===========================================
- Coverage     98.24%   98.2%   -0.04%     
- Complexity     5997    6004       +7     
===========================================
  Files           655     655              
  Lines         43927   43963      +36     
  Branches       6084    6090       +6     
===========================================
+ Hits          43156   43174      +18     
+ Misses          237     233       -4     
- Partials        534     556      +22
Impacted Files Coverage Δ Complexity Δ
...perators/mixed/ObservableConcatMapCompletable.java 99.32% <100%> (-0.68%) 7 <6> (+5)
.../operators/observable/ObservableFlatMapSingle.java 88.8% <0%> (-7.47%) 2% <0%> (ø)
...l/operators/observable/ObservableFlatMapMaybe.java 90.19% <0%> (-4.58%) 2% <0%> (ø)
...nternal/operators/parallel/ParallelReduceFull.java 91.08% <0%> (-3.97%) 2% <0%> (ø)
...tivex/internal/observers/FutureSingleObserver.java 94.33% <0%> (-3.78%) 24% <0%> (-1%)
...activex/internal/observers/QueueDrainObserver.java 97.43% <0%> (-2.57%) 21% <0%> (-1%)
...perators/mixed/ObservableSwitchMapCompletable.java 97.87% <0%> (-2.13%) 2% <0%> (ø)
...x/internal/operators/flowable/FlowablePublish.java 97.02% <0%> (-2.13%) 11% <0%> (ø)
...ernal/operators/flowable/FlowableFlatMapMaybe.java 91.78% <0%> (-1.94%) 2% <0%> (ø)
...vex/internal/operators/single/SingleTakeUntil.java 98.27% <0%> (-1.73%) 2% <0%> (ø)
... and 27 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 4bc516c...273ee1c. Read the comment docs.

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.

2 participants