java/115773: java.nio channel selectors should use kqueue/kevent instead of poll

Nick Johnson freebsd at spatula.net
Thu Aug 23 18:10:02 PDT 2007


>Number:         115773
>Category:       java
>Synopsis:       java.nio channel selectors should use kqueue/kevent instead of poll
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-java
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 24 01:10:01 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Nick Johnson
>Release:        FreeBSD 6.2-STABLE i386
>Organization:
morons.org 
>Environment:
System: FreeBSD turing.morons.org 6.2-STABLE FreeBSD 6.2-STABLE #0: Sun Jan 21 16:53:54 PST 2007 root at turing.morons.org:/usr/src/sys/i386/compile/TURING i386

java version "1.5.0_12-p6"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-p6-root_29_jul_2007_13_27)
Java HotSpot(TM) Client VM (build 1.5.0_12-p6-root_29_jul_2007_13_27, mixed mode)


	
>Description:
The FreeBSD Java port uses the poll(2) interface to implement java.nio channels.  
For high performance, especially when large numbers of descriptors are involved, 
it would be nice to use kqueue(2) / kevent(2) instead.
	

>How-To-Repeat:
Currently channel selection for java.nio involves these files in the JVM:

j2se/src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java
j2se/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java
j2se/src/solaris/native/sun/nio/ch/PollArrayWrapper.c

j2se/src/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java
j2se/src/solaris/classes/sun/nio/ch/PollSelectorImpl.java

j2se/src/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java
j2se/src/share/classes/sun/nio/ch/PollSelectorProvider.java

j2se/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
j2se/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
j2se/src/share/classes/sun/nio/ch/SocketChannelImpl.java
j2se/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java
j2se/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java


As well as these files used for building:
j2se/make/java/nio/Makefile
j2se/make/java/nio/mapfile-solaris

        
>Fix:

I think the cleanest thing may be to create a KEventArrayWrapper.c, KEventArrayWrapper.java,
KEventSelectorProvider.java and KEventSelectorImpl.java to handle the low-level kevent(2)
functions.  The Linux EPoll classes and native code could be examined for some ideas on how
to structure these classes.

Then DatagramChannelImpl.java, ServerSocketChannelImpl.java, SocketChannelImpl.java,
SinkChannelImpl.java, SourceChannelImpl.java and DefaultSelectorProvider.java would
need to be updated to point at the new KEvent* handlers.

The AbstractPoll* stuff could probably be ignored / done away with; it looks like it
was done that way to provide for both DevPoll* and Poll*.  The Linux EPoll classes
do not extend from AbstractPoll*.

An alternative might be to just modify the polling classes to wrap calls to use kevent(2),
but this would be fairly messy and possibly just as much work.

If I have some time I may take a stab at this, but if someone else is interested,
please feel free to jump on it- don't wait on me.

        

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-java mailing list