RFR: 8253478: (se) epoll Selector should use eventfd for wakeup instead of pipe

Brian Burkhalter bpb at openjdk.java.net
Fri Jan 15 23:11:25 UTC 2021


On Fri, 15 Jan 2021 11:28:29 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> This simple benchmark below gives results for the `epoll(7)`-based `Selector` which are three to four percent faster for the version which uses `eventfd(2)` for wakeup.
>> 
>> @State(Scope.Thread)
>> public class EventFDBench {
>>     private Selector sel;
>> 
>>     @Setup(Level.Iteration)
>>     public void setup() throws IOException {
>>         sel = Selector.open();
>>     }
>> 
>>     @Benchmark
>>     public int test() throws IOException {
>>         return sel.wakeup().select();
>>     }
>> }
>
> I did experiments with eventfd(2) a few years ago but didn't see any difference at the time. I think it would be useful to include the PR the results from the JMH runs so that there is at least some record of the results.
> 
> As regards the patch, I would have expected the only native code is be the method that creates the eventfd instance. The set/reset methods can be implemented with IOUtil.write1/drain1. Also I think the EventFD constructor needs a flag so decide the blocking mode, alternative we ignore it and using the existing IOUtil.configureBlocking.

Benchmark output for commit 3:

 fork, 5 10s warmup iterations, 10 10s measurement iterations, 1 thread
pipe wakeup

Result "org.sample.EventFDBench.test":
  674120.350 ±(99.9%) 2246.122 ops/s [Average]
  (min, avg, max) = (671278.574, 674120.350, 676866.600), stdev = 1485.671
  CI (99.9%): [671874.229, 676366.472] (assumes normal distribution)

Result "org.sample.EventFDBench.test":
  676831.218 ±(99.9%) 2353.488 ops/s [Average]
  (min, avg, max) = (673745.955, 676831.218, 678758.514), stdev = 1556.686
  CI (99.9%): [674477.731, 679184.706] (assumes normal distribution)

Result "org.sample.EventFDBench.test":
  675830.928 ±(99.9%) 3052.319 ops/s [Average]
  (min, avg, max) = (671286.540, 675830.928, 679293.739), stdev = 2018.920
  CI (99.9%): [672778.609, 678883.246] (assumes normal distribution)

eventfd wakeup

Result "org.sample.EventFDBench.test":
  698126.388 ±(99.9%) 2776.885 ops/s [Average]
  (min, avg, max) = (694253.565, 698126.388, 700086.784), stdev = 1836.738
  CI (99.9%): [695349.503, 700903.273] (assumes normal distribution)

Result "org.sample.EventFDBench.test":
  699992.095 ±(99.9%) 3653.650 ops/s [Average]
  (min, avg, max) = (695504.040, 699992.095, 702932.998), stdev = 2416.663
  CI (99.9%): [696338.445, 703645.746] (assumes normal distribution)

Result "org.sample.EventFDBench.test":
  702140.433 ±(99.9%) 3019.100 ops/s [Average]
  (min, avg, max) = (698291.810, 702140.433, 704818.744), stdev = 1996.948
  CI (99.9%): [699121.333, 705159.533] (assumes normal distribution)


1 fork, 5 10s warmup iterations, 10 10s measurement iterations, 6 threads
pipe wakeup

Result "org.sample.EventFDBench.test":
  3223142.871 ±(99.9%) 94755.560 ops/s [Average]
  (min, avg, max) = (3120710.890, 3223142.871, 3283407.281), stdev = 62674.936
  CI (99.9%): [3128387.312, 3317898.431] (assumes normal distribution)

Result "org.sample.EventFDBench.test":
  3260747.260 ±(99.9%) 11514.840 ops/s [Average]
  (min, avg, max) = (3248875.268, 3260747.260, 3268729.421), stdev = 7616.354
  CI (99.9%): [3249232.419, 3272262.100] (assumes normal distribution)

Result "org.sample.EventFDBench.test":
  3243306.245 ±(99.9%) 56893.385 ops/s [Average]
  (min, avg, max) = (3160345.608, 3243306.245, 3277487.093), stdev = 37631.452
  CI (99.9%): [3186412.859, 3300199.630] (assumes normal distribution)

eventfd wakeup

Result "org.sample.EventFDBench.test":
  3340323.956 ±(99.9%) 38169.834 ops/s [Average]
  (min, avg, max) = (3280464.427, 3340323.956, 3355415.702), stdev = 25246.982
  CI (99.9%): [3302154.122, 3378493.790] (assumes normal distribution)

Result "org.sample.EventFDBench.test":
  3344287.954 ±(99.9%) 46249.831 ops/s [Average]
  (min, avg, max) = (3261670.180, 3344287.954, 3363007.332), stdev = 30591.400
  CI (99.9%): [3298038.123, 3390537.786] (assumes normal distribution)

Result "org.sample.EventFDBench.test":
  3353728.294 ±(99.9%) 40760.876 ops/s [Average]
  (min, avg, max) = (3285776.202, 3353728.294, 3372002.914), stdev = 26960.796
  CI (99.9%): [3312967.418, 3394489.170] (assumes normal distribution)

-------------

PR: https://git.openjdk.java.net/jdk/pull/2082


More information about the nio-dev mailing list