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: Add fusion support to ObservableSwitchMap inner source #5919

Merged
merged 1 commit into from
Mar 15, 2018

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Mar 15, 2018

This PR improves the performance of the Observable.switchMap operator by adding fusion support as well as upgrading the Completable and Single conversion to Observable to be fuseable. The PR also fixes an error in the DeferredScalarDisposable implementation as the protocol requires calling with null.

The plain (Observable.switchMap(Observable)) conversion has promising performance improvements:

image

The conversion Observable.switchMap(Maybe.toObservable) has promising performance improvements:

image

The conversion Observable.switchMap(Completable.toObservable) is also promising, but there is a 11% loss in the scalar case for some reason:

image

Finally, the conversion Observable.switchMap(Single.toObservable) got a bigger hit for the scalar case, 21% loss, but the rest are impressive:

image

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

I don't know why those losses appeared. The change to ObserverCompletableObserver has only structural change but no code path change. The SingleToObservableObserver now supports fusion which means longer code path on a success value.

@codecov
Copy link

codecov bot commented Mar 15, 2018

Codecov Report

Merging #5919 into 2.x will decrease coverage by <.01%.
The diff coverage is 96.42%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #5919      +/-   ##
============================================
- Coverage     98.24%   98.24%   -0.01%     
+ Complexity     6019     6015       -4     
============================================
  Files           656      656              
  Lines         44004    44040      +36     
  Branches       6094     6102       +8     
============================================
+ Hits          43233    43265      +32     
- Misses          230      233       +3     
- Partials        541      542       +1
Impacted Files Coverage Δ Complexity Δ
...x/internal/observers/DeferredScalarDisposable.java 97.91% <100%> (+0.04%) 20 <0> (ø) ⬇️
...operators/completable/CompletableToObservable.java 100% <100%> (ø) 2 <0> (ø) ⬇️
.../internal/operators/single/SingleToObservable.java 100% <100%> (ø) 3 <0> (ø) ⬇️
...rnal/operators/observable/ObservableSwitchMap.java 94.68% <95.45%> (+4.68%) 3 <0> (ø) ⬇️
...a/io/reactivex/internal/util/QueueDrainHelper.java 95.83% <0%> (-4.17%) 55% <0%> (-3%)
...ternal/operators/observable/ObservablePublish.java 96.46% <0%> (-2.66%) 11% <0%> (+1%)
...activex/internal/observers/QueueDrainObserver.java 97.43% <0%> (-2.57%) 21% <0%> (-1%)
...nternal/operators/parallel/ParallelSortedJoin.java 92.7% <0%> (-2.19%) 2% <0%> (ø)
.../internal/disposables/ListCompositeDisposable.java 98% <0%> (-2%) 34% <0%> (-1%)
.../io/reactivex/disposables/CompositeDisposable.java 98.14% <0%> (-1.86%) 39% <0%> (-1%)
... and 29 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 e25ab24...f82e994. 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