These are chat archives for ReactiveX/RxJava

7th
Jul 2016
Ari Lacenski
@tensory
Jul 07 2016 07:09
If you're using the Schedulers.io scheduler to observeOn, but you want to do some computation on the emitted values before writing back to an io location, should you observeOn a different thread?
Ben Christensen
@benjchristensen
Jul 07 2016 16:21

@tensory that's not necessary since that would just add more scheduling overhead and not really save the CPUs. For computational work there is a finite amount of work the CPUs can do, so moving to another thread isn't going to change anything, just use more CPU to move the work.

The reason that Schedulers.io() exists is to provide threads that you can block ... without blocking the event loops on Schedulers.computation(). The io() thread pool is unbounded, so keeps growing if you block threads and ask for more. The computation() pool is bounded to the number of CPUs, so you don't want to block them.

So, you can always do blocking IO + computation on the io() threads. On the computation threads though, only do computation, never blocking IO.

Ari Lacenski
@tensory
Jul 07 2016 23:02
Okay, thank you, @benjchristensen. I was concerned about adding too much work on the io thread, but I didn't realize it was a thread pool.