Skip to content

1.x: add a source OnSubscribe which works from an array directly #3477

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

Merged
merged 1 commit into from
Dec 15, 2015

Conversation

akarnokd
Copy link
Member

This specialized OnSubscribe performs ~33% better on longer streams.

Benchmark comparison (i7 4770K, Windows 7 x64, Java 8u66):

image

The slowpath requests the available amount + 1 to trigger a slow path, slowpath2 requests in batches of 128 and replenishes only after all were received.

@akarnokd akarnokd added this to the 1.0.x milestone Oct 28, 2015
akarnokd added a commit to akarnokd/RxJava that referenced this pull request Nov 9, 2015
This change factors out the body of lift() into a named class that gives
access to the operator and source parameters. By using this information,
other operators can perform what I call **operator macro-fusion**.

One such example with this PR is the repeated use of the operator
`mergeWith` which when done in the classical way creates a long
linked-list of sources merged in pairs, often leading to stack overflows
and degraded performance. However, if `mergeWith` can see that it is
applied to an existing mergeWith, the two operators can use a common
list of sources and then turn into a one-level merge() with n + 1
sources (the previous graph will then be GC'd). Don't worry, this
doesn't destroy the original assembled sequence. For example, given `c =
a.mergeWith(b); d = c.mergeWith(e);` both c and d can be freely
subscribed to and still do the same thing.

Note also that this PR conflicts with PR ReactiveX#3477 since the array-based
`merge(from(os))` has a different type.
@stealthcode
Copy link

👍

akarnokd added a commit that referenced this pull request Dec 15, 2015
1.x: add a source OnSubscribe which works from an array directly
@akarnokd akarnokd merged commit 8d3a0c5 into ReactiveX:1.x Dec 15, 2015
@akarnokd akarnokd deleted the FromArray1x branch December 15, 2015 21:11
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