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

FromIterable overhead reduction. #3137

Merged
merged 1 commit into from
Aug 12, 2015
Merged

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Aug 7, 2015

Some restructuring reduces the overhead of operators:

  • extending AtomicLong gives access to atomic intrinsics for the request accounting
  • loading the final fields into local variables prevents them from being reloaded from cache due to the atomics around them
  • request() is hot but generally too large due to the fastpath/slowpath fit and JIT may not want to pick it up early. By refactoring the two paths into two separate methods, it becomes inline friendly for the either of the paths.

Benchmark results on my i7 4770K, Windows 7 x64, Java 8u51:

image

The benchmark from #3118 gives this result:

image

@davidmoten
Copy link
Collaborator

benchmark improvements are spectacular!

@akarnokd
Copy link
Member Author

I don't want to merge this until somebody else verifies the improvement on a different processor/OS.

@stealthcode
Copy link

@akarnokd I can run it. How are you generating the benchmark reports in the image?

@akarnokd
Copy link
Member Author

I have a tool for displaying JMH results: https://github.com/akarnokd/jmh-compare-gui . Then I take a screenshot and cut it around.

@stealthcode
Copy link

Here are the results from my laptop (2.2GHz intel Core i7; OS X Yosemite 10.10.4 Java 1.8u51).

Benchmark                          (size)   Mode   Samples        Score  Score error    Units
r.o.FromIterablePerf.direct             1  thrpt         5 22874735.514   569868.213    ops/s
r.o.FromIterablePerf.direct          1000  thrpt         5   287497.063    13353.846    ops/s
r.o.FromIterablePerf.direct       1000000  thrpt         5      278.303       45.706    ops/s
r.o.FromIterablePerf.from               1  thrpt         5  9434804.935   160084.549    ops/s
r.o.FromIterablePerf.from            1000  thrpt         5   226639.074    82633.950    ops/s
r.o.FromIterablePerf.from         1000000  thrpt         5      245.069        5.076    ops/s
r.o.FromIterablePerf.fromUnsafe         1  thrpt         5 23373598.288   769396.099    ops/s
r.o.FromIterablePerf.fromUnsafe      1000  thrpt         5   288430.485     8187.201    ops/s
r.o.FromIterablePerf.fromUnsafe   1000000  thrpt         5      286.498       11.960    ops/s

Seems comparable.

akarnokd added a commit that referenced this pull request Aug 12, 2015
FromIterable overhead reduction.
@akarnokd akarnokd merged commit 6362dfe into ReactiveX:1.x Aug 12, 2015
@akarnokd akarnokd deleted the FromIterablePerf branch August 12, 2015 20: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.

3 participants