{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2773","labels_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2773/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2773/comments","events_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2773/events","html_url":"https://github.com/ReactiveX/RxJava/pull/2773","id":58903217,"number":2773,"title":"ObserveOn performance improvements","user":{"login":"akarnokd","id":1269832,"avatar_url":"https://avatars.githubusercontent.com/u/1269832?v=3","gravatar_id":"","url":"https://api.github.com/users/akarnokd","html_url":"https://github.com/akarnokd","followers_url":"https://api.github.com/users/akarnokd/followers","following_url":"https://api.github.com/users/akarnokd/following{/other_user}","gists_url":"https://api.github.com/users/akarnokd/gists{/gist_id}","starred_url":"https://api.github.com/users/akarnokd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akarnokd/subscriptions","organizations_url":"https://api.github.com/users/akarnokd/orgs","repos_url":"https://api.github.com/users/akarnokd/repos","events_url":"https://api.github.com/users/akarnokd/events{/privacy}","received_events_url":"https://api.github.com/users/akarnokd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ReactiveX/RxJava/labels/Enhancement","name":"Enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-25T13:44:43Z","updated_at":"2015-03-04T21:58:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ReactiveX/RxJava/pulls/2773","html_url":"https://github.com/ReactiveX/RxJava/pull/2773","diff_url":"https://github.com/ReactiveX/RxJava/pull/2773.diff","patch_url":"https://github.com/ReactiveX/RxJava/pull/2773.patch"},"body":"Further optimizations to ```observeOn```.\r\n\r\n  - Using SpscArrayQueue directly in observeOn instead of ```RingBuffer``` to avoid the synchronization block\r\n  - Split tracking structure to serial (SubscriptionList) and timed (CompositeSubscription) in ```EventLoopsScheduler``` which improves the sequential scheduling performance because a completing task's subscription will be most likely the first item in the underlying LinkedList.\r\n\r\nBenchmark: (i7 920, Window 7 x64, Java 1.8u31, 5x1s warmup, 5x5s iteration)\r\n```\r\nBenchmark      (size)         1.x    1.x error      this PR   this error\r\nobserveOn           1  162326,012     2458,085   166536,559     3154,174\r\nobserveOn          10  132471,205     1857,434   142517,407     3734,424 ++\r\nobserveOn         100   43282,527     2145,910   112238,179     2270,103 ++\r\nobserveOn        1000   11779,482      173,370    25726,564      309,193 ++\r\nobserveOn        2000    6756,211       89,196    12123,276      276,470 ++\r\nobserveOn        3000    4736,893      253,796     9342,673      263,667 ++\r\nobserveOn        4000    3661,874       51,359     7346,015      123,049 ++\r\nobserveOn       10000    1519,282      108,503     1546,547       21,885\r\nobserveOn      100000     151,193        2,569      156,160        1,974\r\nobserveOn     1000000      15,373        1,310       15,660        0,153\r\nsubscribeOn         1  161290,037     2867,882   164952,259      797,408\r\nsubscribeOn        10  151842,821     2448,734   147906,491     4373,682\r\nsubscribeOn       100  136418,065     1773,558   136889,052     2362,203\r\nsubscribeOn      1000   58389,066     4559,030    59482,225     1372,692\r\nsubscribeOn      2000   34089,152     9318,205    36581,203     1264,100\r\nsubscribeOn      3000   26712,331     1265,442    26519,320     1319,293\r\nsubscribeOn      4000   20118,326     2018,439    20163,395      839,709\r\nsubscribeOn     10000    8914,213      677,164     9059,934      200,158\r\nsubscribeOn    100000     958,038       43,349      965,663       60,708\r\nsubscribeOn   1000000      91,849        2,148       92,706        1,202\r\n```\r\nNotes:\r\n  - At ```size = 1```, the throughput varies in a +/- 3000 range on each run, and since the changes don't touch the scalar optimization, there is no real improvement there.\r\n  - At ```size = 10.000``` my system reached either the cache capacity or the OS scheduler's time resolution so there no improvement there on.\r\n  - At ```size = 100.000``` and ```size = 1.000.000``` the throughput doubles if I introduce some extra delay (i.e., via sleep(1) or some extra work).\r\n  - The benchmark generates a lot of garbage due to boxing: switching to a constant emitter increases the throughput ```subscribeOn(1.000.000)``` from 91 to 136. \r\n\r\nSince it conflicts with #2772 anyway, this is PR is to let others verify the optimizations actually work on other OSes, because on my Windows, I sometimes get significant variance in the throughput during iterations. Increased iteration time may be required as well."},"comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/comments/77258853","html_url":"https://github.com/ReactiveX/RxJava/pull/2773#issuecomment-77258853","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/2773","id":77258853,"user":{"login":"benjchristensen","id":813492,"avatar_url":"https://avatars.githubusercontent.com/u/813492?v=3","gravatar_id":"","url":"https://api.github.com/users/benjchristensen","html_url":"https://github.com/benjchristensen","followers_url":"https://api.github.com/users/benjchristensen/followers","following_url":"https://api.github.com/users/benjchristensen/following{/other_user}","gists_url":"https://api.github.com/users/benjchristensen/gists{/gist_id}","starred_url":"https://api.github.com/users/benjchristensen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjchristensen/subscriptions","organizations_url":"https://api.github.com/users/benjchristensen/orgs","repos_url":"https://api.github.com/users/benjchristensen/repos","events_url":"https://api.github.com/users/benjchristensen/events{/privacy}","received_events_url":"https://api.github.com/users/benjchristensen/received_events","type":"User","site_admin":false},"created_at":"2015-03-04T21:58:47Z","updated_at":"2015-03-04T21:58:47Z","body":"Do you mind rebasing this so we don't have the development path in the log?"}}