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

Alan Bateman alanb at openjdk.java.net
Fri Jan 15 11:31:05 UTC 2021


On Thu, 14 Jan 2021 20:44:38 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Yes. I have one based on the Wakeup test but it is rather ugly.
>
> 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.

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

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


More information about the nio-dev mailing list