dev@grizzly.java.net

[Fwd: NIO is hard for the uninitiated...we need help]

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Fri, 23 Mar 2007 10:43:42 -0400

Hi,

if peoples are interested to help or share their experience :-)

Thanks!

-- Jeanfrancois

-------- Original Message --------
Subject: NIO is hard for the uninitiated...we need help
Date: Thu, 22 Mar 2007 14:52:10 -0700
From: Charles Oliver Nutter <charles.nutter_at_sun.com>
To: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>, TAKAI Naoto
<takai_at_recompile.net>
CC: Thomas Enebo <Thomas.Enebo_at_Sun.COM>, Ola Bini <ola.bini_at_ki.se>, Nick
Sieger <nicksieger_at_gmail.com>

Hello gentlemen!

It has come time that we finally repair the unfortunate state of JRuby's
IO subsystem. And we need help.

JRuby is targeted at Java 1.4 and higher, so we have access to NIO and
would naturally like to use it. But NIO gives us only the building
blocks to do what we want, and the rest is proving to be quite a challenge.

Our primary areas of concern are as follows:

- RandomAccessFile-like capabilities but fast and buffered. Both Tom and
another contributor have independently been working on their own
implementations, Tom's based on byte[] and the other based on
ByteBuffers. We need help making one or both of these impls
high-performance. We can make them available if you like.

- Socket IO, provided through NIO currently but not efficiently. We have
a NIO-based socket IO subsystem, but it doesn't really buffer like it
should, and as a result we're paying a performance cost. For example,
when I -Xprof a Rails app serving a static file, 92% of the ticks happen
in sun.nio.ch.KQueueArrayWrapper.kevent0, which I imagine is related to
ByteBuffer.wrap.

The code in question is in the JRuby repository:

http://svn.codehaus.org/jruby/trunk/jruby

under the src/org/jruby/util directory

IOHandler = superclass for all IOHandlers

IOHandlerNio = NIO code used primarily for socket IO right now

IOHandlerJavaIO = superclass of the stream and RandomAccessFile-based
IOHandlers

IOHandlerSeekable = RandAccFile-based impl for seekable File IO

IOHandlerUnseekable = stream-based impl for things like stdin and stdout

Both the internal code and the overall design of these classes is
entirely negotiable.

So, can you or other NIO experts you know help us with this effort?

- Charlie