From root@turing.morons.org  Fri Aug 24 01:09:03 2007
Return-Path: <root@turing.morons.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A9C2B16A417
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 24 Aug 2007 01:09:03 +0000 (UTC)
	(envelope-from root@turing.morons.org)
Received: from turing.morons.org (turing.morons.org [208.96.51.42])
	by mx1.freebsd.org (Postfix) with ESMTP id 99C8813C458
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 24 Aug 2007 01:09:03 +0000 (UTC)
	(envelope-from root@turing.morons.org)
Received: by turing.morons.org (Postfix, from userid 0)
	id 8352B1704B; Thu, 23 Aug 2007 18:09:01 -0700 (PDT)
Message-Id: <20070824010901.8352B1704B@turing.morons.org>
Date: Thu, 23 Aug 2007 18:09:01 -0700 (PDT)
From: Nick Johnson <freebsd@spatula.net>
Reply-To: Nick Johnson <freebsd@spatula.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: java.nio channel selectors should use kqueue/kevent instead of poll 
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         115773
>Category:       java
>Synopsis:       [patch] java.nio channel selectors should use kqueue/kevent instead of poll
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-java
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 24 01:10:01 GMT 2007
>Closed-Date:    Sat Aug 07 18:45:04 UTC 2010
>Last-Modified:  Sat Aug  7 18:50:02 UTC 2010
>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@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:

From: David Xu <davidxu@freebsd.org>
To: bug-followup@freebsd.org, freebsd@spatula.net
Cc:  
Subject: Re: java/115773: [request] java.nio channel selectors should use
 kqueue/kevent instead of poll
Date: Mon, 02 Aug 2010 17:20:21 +0800

 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
 
State-Changed-From-To: open->closed 
State-Changed-By: glewis 
State-Changed-When: Sat Aug 7 18:44:42 UTC 2010 
State-Changed-Why:  
I've committed David's patch.  Thanks David! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=115773 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: java/115773: commit references a PR
Date: Sat,  7 Aug 2010 18:44:21 +0000 (UTC)

 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"
 
>Unformatted:
