-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Scheduler correctness improvements. #1158
Conversation
RxJava-pull-requests #1070 FAILURE |
@akarnokd do you need help porting it over to JMH? I can assist with that. |
That would be great, but I don't know how to run a JHM benchmark from NetBeans. |
@akarnokd ideally you run it from the command line as a encapsulated package. Once you write the benchmark, you package it up as a fat jar and then you can execute your test only.. ala: ../gradlew benchmarks '-Pjmh=-f 1 -tu ns -bm avgt -wi 5 -i 5 -r 1 .OperatorSerializePerf.' but just replace the name of the benchmark with yours, otherwise it will run this one or all if you leave it out. Note that with some fiddling around, I did this for netty, you can fake it from your IDE by either writing a custom Junit runner or just doing it like this: https://github.com/netty/netty/blob/master/microbench/src/test/java/io/netty/microbench/util/AbstractMicrobenchmark.java |
Looks like |
True. I'm working on something else right now so I come back later to remove it. |
RxJava-pull-requests #1074 SUCCESS |
I always run them from command line. See comments on how to run here: https://github.com/Netflix/RxJava/blob/master/build.gradle#L92 |
This option also exists with the |
Here is the benchmark code: https://gist.github.com/akarnokd/1f9817e60706569c28e1 Master results: https://gist.github.com/akarnokd/3efcf8f47a1e988073f8 |
I added performance tests for This pull request is far faster on startup (when subscribing to an Observable of 1 item) and somewhat faster on long-running Observables.
New Code
Master
|
One thing I don't like about how this is currently working is that we have to create the This may fit with what @spodila is working on as I believe it will maintain a queue per Going to merge this however as it is better than the current implementation and we'll continue improving this in #1149 |
Scheduler correctness improvements.
Ooops, I forgot to mention there might be some unwanted task executions after |
|
Second round on the scheduler correctness issue.
Sure it looks more heavy as
ScheduledAction
now has its own innerCompositeSubscription
and a shared reference to the parentinnerSubscription
.I've tried to benchmark it with
SchedulerPerformanceTests
but that test is flawed:from
will not actually callonNext
butisUnsubscribed
a lot.The flawed test gives ~ 11M ops/sec on my machine. If I fix the test and run against the master, 5M takes extremely long to finish due to the inherent slowness of add/remove in CompositeSubscription if large. On my 4 core hyperthread enabled machine, I get 50k-150k ops/second for baseline with a 100k loop.
The proposed changes run with the flawed test gives ~10.8M ops/sec. With the test fixed and with the proposed changes, I get ~1.2M ops/sec.