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. 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. 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
I have a patch to let nio use kqueue(), I have roughly tested it, and it works fine. http://people.freebsd.org/~davidxu/patch/jdk16_nio_kqueue.patch just cd into /usr/ports/jdk16, and type following commands: make extract make patch cd work patch < this_patch_file cd .. make install note that the patch does not make kqueue method be default, you should specify it on comand line like following: java -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.KqueueSelectorProvider <application class> Regards, David Xu
glewis 2010-08-07 18:44:12 UTC FreeBSD ports repository Modified files: java/jdk16 Makefile Added files: java/jdk16/files patch-nio-kqueue Log: . Add a new NIO selector that uses kqueue(2) and make it the default. PR: 115773 Submitted by: davidxu@ Revision Changes Path 1.179 +1 -1 ports/java/jdk16/Makefile 1.1 +699 -0 ports/java/jdk16/files/patch-nio-kqueue (new) _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
State Changed From-To: open->closed I've committed David's patch. Thanks David!