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

Alan Bateman alanb at openjdk.java.net
Thu Jan 21 10:28:00 UTC 2021


On Wed, 20 Jan 2021 18:03:18 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Please review this change which modifies the Linux `epoll(7)`-based `Selector` to use `eventfd(2)` instead of `pipe(2)` in its wakeup mechanism. The change passes all tier 1-tier 3 tests on Linux. Based on rudimentary testing, there does not appear to be any appreciable change in performance. One improvement however is that only one file descriptor instead of two is used for the wakeup. No test is included as the code is covered well by existing tests.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8253478: EventFD update: constructors; make native methods private

src/java.base/linux/classes/sun/nio/ch/EventFD.java line 79:

> 77:      * @return the number of bytes written; should equal 8
> 78:      */
> 79:     static private native int set0(int efd) throws IOException;

Minor nit but we usually put the private modifier first.

src/java.base/linux/classes/sun/nio/ch/EventFD.java line 51:

> 49:     EventFD(boolean blocking) throws IOException {
> 50:         efd = eventfd0();
> 51:         IOUtil.configureBlocking(IOUtil.newFD(efd), blocking);

This looks okay but the addition of the blocking parameter means you can go back to one of the early iterations and just calling eventfd with the EFD_NONBLOCK. Up to you.

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

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


More information about the nio-dev mailing list