Skip to content

2.x: improve performance of Observable.flatMapIterable#4612

Merged
akarnokd merged 1 commit intoReactiveX:2.xfrom
akarnokd:PerfWork
Sep 27, 2016
Merged

2.x: improve performance of Observable.flatMapIterable#4612
akarnokd merged 1 commit intoReactiveX:2.xfrom
akarnokd:PerfWork

Conversation

@akarnokd
Copy link
Member

This PR improves the performance of flatMapIterable by inlining the consumption of the generated Iterable. The performance improvement comes from direct iteration and emission plus removing the overhead of the regular flatMap as such source mappings are inherently synchronous.

Benchmark

i7 4790, Windows 7 x64, Java 8u102, JMH 1.13, ops/s - bigger is better

image

10x overhead reduction in flattening a single element Iterable.

image

Half the overhead compared to (an already optimized) Flowable.flatMapIterable.

image

Nice improvement on the cross-range benchmark (stream 1 million element split into N outer and M inner elements where N * M = 1 million):

image

Also quite better than Flowable.flatMapIterable.

@akarnokd akarnokd added this to the 2.0 RC4 milestone Sep 27, 2016
@codecov-io
Copy link

Current coverage is 78.10% (diff: 83.92%)

Merging #4612 into 2.x will decrease coverage by 0.03%

@@                2.x      #4612   diff @@
==========================================
  Files           553        554     +1   
  Lines         36128      36182    +54   
  Methods           0          0          
  Messages          0          0          
  Branches       5559       5564     +5   
==========================================
+ Hits          28231      28261    +30   
- Misses         5891       5909    +18   
- Partials       2006       2012     +6   

Powered by Codecov. Last update d85d40e...1bb4e03

@akarnokd akarnokd merged commit ab21265 into ReactiveX:2.x Sep 27, 2016
@akarnokd akarnokd deleted the PerfWork branch September 27, 2016 13:43
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.

3 participants