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: improve performance of Observable.flatMapIterable #4612

Merged
merged 1 commit into from Sep 27, 2016

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.

None yet

3 participants