Lots of CPU going in Channel.write() (Yourkit profile attached)

Utkarsh Srivastava utkarsh at gmail.com
Fri Sep 11 02:37:07 EDT 2009


Hi,
I recently rewrote an application that was not using Netty (or even NIO) so
as to use Netty. Netty has been great to use, the API, the doc, everything.
Thanks for the good work.

Using netty 3.1.2.GA, my application basically blasts out messages to 2
servers. I would expect to be able to saturate the network pipe. I am able
to do so at larger message sizes (e.g. 16K).

But for small messages (e.g. 1K), the application doesn't saturate the
network but becomes CPU bound. I profiled the application using Yourkit and
one place that I noticed that had a high CPU consumption but shouldn't was
channel.write().

The breakdown of that method is attached. What is strange is 19% of the time
going in NioClientSocketPipelineSink.eventSunk() and its own time is
nontrivial (170 ms = 7%). Looking at the code, I don't see any place where
that CPU can be spent (since NIOWorker.write() and
NIOSocketChannel$WriteBuffer.offer() have their own separate contributions
of 9 and 3% respectively. So this is extremely puzzling. Anybody have
thoughts on this?

Also, is it necessary to make that system call every time to check if the
channel is connected? That alone is taking up 6%.

Thanks
Utkarsh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20090910/07b49532/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Picture 3.png
Type: image/png
Size: 153556 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20090910/07b49532/attachment-0001.png 


More information about the netty-users mailing list