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

Revert use of CurrentThreadScheduler for Observable.from #724

Conversation

benjchristensen
Copy link
Member

Use ImmediateScheduler as performance is 4x faster and CurrentThreadScheduler currently offers no benefit (it doesn’t solve the unsubscribe problem).

Performance numbers:

 * Observable.from(Arrays.asList(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), scheduler);
 *
 * --- Schedulers.immediate() ---
 *
 * Run: 0 - 1,849,947 ops/sec
 * Run: 1 - 2,076,067 ops/sec
 * Run: 2 - 2,114,688 ops/sec
 * Run: 3 - 2,114,301 ops/sec
 * Run: 4 - 2,102,543 ops/sec
 *
 * --- Schedulers.currentThread() ---
 *
 * Run: 0 - 548,862 ops/sec
 * Run: 1 - 559,955 ops/sec
 * Run: 2 - 581,412 ops/sec
 * Run: 3 - 562,187 ops/sec
 * Run: 4 - 565,723 ops/sec

 * Observable.from(Arrays.asList(1L), scheduler);
 *
 * --- Schedulers.immediate() ---
 *
 * Run: 10 - 4,113,672 ops/sec
 * Run: 11 - 4,068,351 ops/sec
 * Run: 12 - 4,070,318 ops/sec
 * Run: 13 - 4,161,793 ops/sec
 * Run: 14 - 4,156,725 ops/sec
 *
 * --- Schedulers.currentThread() ---
 *
 * Run: 10 - 1,692,286 ops/sec
 * Run: 11 - 1,765,054 ops/sec
 * Run: 12 - 1,763,100 ops/sec
 * Run: 13 - 1,770,907 ops/sec
 * Run: 14 - 1,732,291 ops/sec

Use ImmediateScheduler as performance is 4x faster and CurrentThreadScheduler currently offers no benefit (it doesn’t solve the unsubscribe problem).

Performance numbers:

     * Observable.from(Arrays.asList(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), scheduler);
     *
     * --- Schedulers.immediate() ---
     *
     * Run: 0 - 1,849,947 ops/sec
     * Run: 1 - 2,076,067 ops/sec
     * Run: 2 - 2,114,688 ops/sec
     * Run: 3 - 2,114,301 ops/sec
     * Run: 4 - 2,102,543 ops/sec
     *
     * --- Schedulers.currentThread() ---
     *
     * Run: 0 - 548,862 ops/sec
     * Run: 1 - 559,955 ops/sec
     * Run: 2 - 581,412 ops/sec
     * Run: 3 - 562,187 ops/sec
     * Run: 4 - 565,723 ops/sec

     * Observable.from(Arrays.asList(1L), scheduler);
     *
     * --- Schedulers.immediate() ---
     *
     * Run: 10 - 4,113,672 ops/sec
     * Run: 11 - 4,068,351 ops/sec
     * Run: 12 - 4,070,318 ops/sec
     * Run: 13 - 4,161,793 ops/sec
     * Run: 14 - 4,156,725 ops/sec
     *
     * --- Schedulers.currentThread() ---
     *
     * Run: 10 - 1,692,286 ops/sec
     * Run: 11 - 1,765,054 ops/sec
     * Run: 12 - 1,763,100 ops/sec
     * Run: 13 - 1,770,907 ops/sec
     * Run: 14 - 1,732,291 ops/sec
mattrjacobs added a commit that referenced this pull request Jan 6, 2014
…heduler-usage

Revert use of CurrentThreadScheduler for Observable.from
@mattrjacobs mattrjacobs merged commit 1363f61 into ReactiveX:master Jan 6, 2014
@benjchristensen benjchristensen deleted the revert-current-thread-scheduler-usage branch January 6, 2014 22:05
@cloudbees-pull-request-builder

RxJava-pull-requests #639 ABORTED

jihoonson pushed a commit to jihoonson/RxJava that referenced this pull request Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants