Slow writes from outside an I/O-worker?

ArvidSvensson arvid.svensson at gmail.com
Wed Sep 21 14:22:20 EDT 2011


Hi there,
I'm trying to burst data from a server to a clients and I can't get any
speed out of Netty's NIO channel.

If I do the following with a *Nio*ServerSocketChannelFactory I get poor
performance. The profiler tells me Channel#write eats CPU and I only get
~20k messages/s @ ~20 bytes each to the client. I get ~20k both over network
and localhost loop-back. If I do the same with a
*Oio*ServerSocketChannelFactory I roughly double to ~40k messages/s over
network and well above 100k messages/s on localhost loop-back.

while (true) {
    Object message = nextMessage();
    ChannelFuture future = channel.write(message); // call write from
non-I/O worker.
    future.awaitUninterruptibly();
}


If I do the following with a *Oio*ServerSocketChannelFactory it hangs. If I
do it with *Nio*ServerSocketChannelFactory I almost match the ~40k
messages/s.

Object message = nextMessage();
ChannelFuture future = channel.write(message); // call write from non-I/O
worker.
future.addListener(new ChannelFutureListener() {
    public void operationComplete(ChannelFuture future) { 
         Object message = nextMessage();
         channel.write(message).addListener(this); // call write from I/O
worker.
    }
});

Why is it so expensive to call (NIO) Channel#write from a non-I/O worker?

If I have the next message available when the previous future signals
operationComplete everything is fine since I can call write on the
I/O-worker. However, If I miss that moment I'm forced to write to the
channel from a non-I/O worker again takin a bit hit.

--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Slow-writes-from-outside-an-I-O-worker-tp6817213p6817213.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list