ReactiveX/RxJava — pull request #1929 by benjchristensen (2014-12-05 08:09:27+00:00)
Title: Experimental: ObjectPool with WeakReferences

An experimental implementation of ObjectPool that removes the explicit release and uses WeakReferences.

Part of exploration for https://github.com/ReactiveX/RxJava/issues/1908

The perf numbers on `observeOn` suggest none of this matters :-)

```
1.x Branch

Benchmark (size) Mode Samples Score Score error Units
r.o.OperatorObserveOnPerf.observeOnComputation 1 thrpt 5 108090.165 3468.773 ops/s
r.o.OperatorObserveOnPerf.observeOnComputation 1000 thrpt 5 7010.679 283.868 ops/s
r.o.OperatorObserveOnPerf.observeOnComputation 1000000 thrpt 5 13.588 0.354 ops/s
r.o.OperatorObserveOnPerf.observeOnImmediate 1 thrpt 5 16268519.793 707702.931 ops/s
r.o.OperatorObserveOnPerf.observeOnImmediate 1000 thrpt 5 149998.180 31025.889 ops/s
r.o.OperatorObserveOnPerf.observeOnImmediate 1000000 thrpt 5 159.109 11.987 ops/s
r.o.OperatorObserveOnPerf.observeOnNewThread 1 thrpt 5 17182.508 629.781 ops/s
r.o.OperatorObserveOnPerf.observeOnNewThread 1000 thrpt 5 7892.906 139.532 ops/s
r.o.OperatorObserveOnPerf.observeOnNewThread 1000000 thrpt 5 13.489 0.527 ops/s

This PullRequest using WeakReferences

Benchmark (size) Mode Samples Score Score error Units
r.o.OperatorObserveOnPerf.observeOnComputation 1 thrpt 5 108133.231 9569.065 ops/s
r.o.OperatorObserveOnPerf.observeOnComputation 1000 thrpt 5 6389.620 581.448 ops/s
r.o.OperatorObserveOnPerf.observeOnComputation 1000000 thrpt 5 13.181 1.719 ops/s
r.o.OperatorObserveOnPerf.observeOnImmediate 1 thrpt 5 15153898.775 927814.232 ops/s
r.o.OperatorObserveOnPerf.observeOnImmediate 1000 thrpt 5 169459.680 15935.085 ops/s
r.o.OperatorObserveOnPerf.observeOnImmediate 1000000 thrpt 5 154.516 32.170 ops/s
r.o.OperatorObserveOnPerf.observeOnNewThread 1 thrpt 5 15585.688 1205.259 ops/s
r.o.OperatorObserveOnPerf.observeOnNewThread 1000 thrpt 5 7871.875 295.553 ops/s
r.o.OperatorObserveOnPerf.observeOnNewThread 1000000 thrpt 5 14.040 0.628 ops/s

Pooling Disabled (create a new object each time in `borrowObject`)

Benchmark (size) Mode Samples Score Score error Units
r.o.OperatorObserveOnPerf.observeOnComputation 1 thrpt 5 108130.153 10452.845 ops/s
r.o.OperatorObserveOnPerf.observeOnComputation 1000 thrpt 5 6948.319 123.024 ops/s
r.o.OperatorObserveOnPerf.observeOnComputation 1000000 thrpt 5 13.294 1.165 ops/s
r.o.OperatorObserveOnPerf.observeOnImmediate 1 thrpt 5 15107600.987 1565384.083 ops/s
r.o.OperatorObserveOnPerf.observeOnImmediate 1000 thrpt 5 170127.608 16674.301 ops/s
r.o.OperatorObserveOnPerf.observeOnImmediate 1000000 thrpt 5 155.075 20.204 ops/s
r.o.OperatorObserveOnPerf.observeOnNewThread 1 thrpt 5 15730.556 1586.146 ops/s
r.o.OperatorObserveOnPerf.observeOnNewThread 1000 thrpt 5 7911.561 439.432 ops/s
r.o.OperatorObserveOnPerf.observeOnNewThread 1000000 thrpt 5 14.472 0.982 ops/s
```

Need to sleep on this more but wanted to post this in case it triggers thoughts on ideas for anyone else.