RFR: 8360025: (se) Convert kqueue Selector Implementation to use FFM APIs

Alan Bateman alanb at openjdk.org
Tue Jul 8 14:36:26 UTC 2025


On Fri, 30 May 2025 12:00:28 GMT, Darragh Clarke <dclarke at openjdk.org> wrote:

> This PR aims to Panamize the Java Kqueue implementation, This is based on the work that was previously shared in https://github.com/openjdk/jdk/pull/22307 , The main change since then is that this branch takes advantage of the changes made in https://github.com/openjdk/jdk/pull/25043 to allow for better performance during errno handling.
> 
> These changes feature a lot of Jextract generated files, though alterations have been made in relation to Errno handling and performance improvements.
> 
> I will update this description soon to include performance metrics on a few microbenchmarks, though currently it's roughly 2% to 3% slower with the changes, which is somewhat expected, though there are still a few ideas of possible performance improvements that could be tried. Any suggestions or comments in that area are more than welcome however.

src/java.base/macosx/classes/sun/nio/ch/KQueue.java line 124:

> 122:                         kqfd, keventMS, 1, NULL,
> 123:                         0, NULL);
> 124:             } while ((result == KQUEUE_ERROR_VALUE));

The only case where the syscall should be restarted is EINTR.

src/java.base/macosx/classes/sun/nio/ch/KQueue.java line 152:

> 150:                     return IOStatus.INTERRUPTED;
> 151:                 } else {
> 152:                     throw new IOException("kqueue_poll failed");

The syscall is "kqueue" rather than "kqueue_poll".

src/java.base/macosx/classes/sun/nio/ch/KQueuePoller.java line 41:

> 39:     private final int filter;
> 40:     private final int maxEvents;
> 41:     private final MemorySegment pollArrayRegions;

This is a poll array so I think very confusing to see "Regions" in the name.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25546#discussion_r2166376862
PR Review Comment: https://git.openjdk.org/jdk/pull/25546#discussion_r2166377830
PR Review Comment: https://git.openjdk.org/jdk/pull/25546#discussion_r2166368230


More information about the core-libs-dev mailing list