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

Optimize Observable.concat and Observable.concatDelayError #644

Closed
alexandru opened this issue Apr 10, 2018 · 2 comments
Closed

Optimize Observable.concat and Observable.concatDelayError #644

alexandru opened this issue Apr 10, 2018 · 2 comments

Comments

@alexandru
Copy link
Member

Currently we've got these functions on the companion object:

  def concat[A](sources: Observable[A]*): Observable[A] =
    Observable.fromIterable(sources).concatMap[A](identity)

  def concatDelayError[A](sources: Observable[A]*): Observable[A] =
    Observable.fromIterable(sources).concatMapDelayErrors[A](identity)

They are defined in terms of concatMap, however we can define them in terms of ++, the strict implementation (not the one with the by-name param, after #643 happens).

So the challenge, should you choose to accept it:

  1. provide an implementation based on ConcatObservable instead of fromIterable and concatMap
  2. prove that it is better by a benchmark, you can dump a quick benchmark in the benchmarks sub-project ... but don't commit it in the PR
@agajek
Copy link

agajek commented Jul 7, 2018

I've tried to provide some implementation by stacking sources into ConcatObservable. It ended up with sth like that:

def concat[A](sources: Observable[A]*): Observable[A] =
    sources.toList.foldLeft(Observable.empty[A])((acc, a) => new ConcatObservable[A](acc, a))

In benchmark I've generated 3k Observable containing pure Int and then applied my implementation of concat to them. But the performance was terrible.
Current implementation is:

ObservableConcatBenchmark.concatObservable    3000  thrpt   20  139531619.493 ± 6637768.282  ops/s

and mine:

ObservableConcatBenchmark.concatObservable    3000  thrpt   20  12198.799 ± 1458.540  ops/s

Is the sth I need to put attention while implementing this?

@alexandru alexandru modified the milestones: 3.0.0-RC2, 3.0.0 Nov 6, 2018
@alexandru
Copy link
Member Author

No longer relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants