Buffer Sainity QNA
Trustin Lee
trustin at gmail.com
Thu Oct 20 17:27:07 EDT 2011
Netty pools direct buffers for reads. Once data is read from socket into the direct buffer, we usually copy the read data into a new heap buffer. It is because there's no easy way to manage direct buffer allocation frictionlessly. Unlike a heap buffer, a direct buffer is not garbage collected very well. The current idea is for Netty to implement more efficient and general direct buffer pooling mechanism, but it is pretty difficult to compete with JVM's heap buffer management and the cost of memory copy is often cancelled by efficient memory management of heap buffers.
Another place where memory copy takes place is probably a decoder. It could be improved too by adopting a different approach in consuming inbound data, but I'm still thinking out loud in this topic.
HTH and I love your feed back! Please keep it coming!
Cheers
--
Trustin Lee
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
On Thursday, October 20, 2011 at 2:18 PM, Bill Burke wrote:
> One thing I noticed is that there's a lot of copying going on in Netty.
> Specifically from the NIO ByteBuffer to a ChannelBuffer with every
> request.
>
> On 10/20/11 5:13 PM, Trustin Lee wrote:
> > Netty provides composite buffers and dynamically growing buffers.
> > However, they are usually used for heap buffers rather than dynamic
> > buffers. If you have good control over the life cycle of the direct
> > buffers you allocated, you could write your own ChannelBufferFactory to
> > utilize direct buffers without worrying OOME.
> >
> > HTH
> >
> >
> > On Thursday, October 20, 2011 at 3:51 AM, qballer wrote:
> > > Hi guys,
> > >
> > > I have an ongoing work on some buffer issues I'm facing, you can read
> > > more
> > > http://stackoverflow.com/questions/7780034/looking-for-a-does-everything-buffer-in-java-decided-to-work-with-netty
> > > here.
> > >
> > >
> > > Basically, I'm developing a system that distributes large amounts of
> > > data to
> > > different servers. I would like to work with direct mapped buffers,
> > > because
> > > I think I will enjoy from faster deployment of my data through out the
> > > system. still I don't know what will be my buffer sizes. I'm considering
> > > developing my own Composite Buffer. This will expose the Buffer Chanel
> > > interface, but will hold a collection of direct buffers, I will just
> > > do the
> > > work of "connecting" them, making the user think he has one huge buffer.
> > >
> > >
> > > I would like to hear you opinion on this solution since this is my first
> > > time using such technologies, NIO in general and Netty specifically. I
> > > might
> > > just understandg/doing something all wrong.
> > >
> > >
> > > Specific questions:
> > >
> > > Did any of you guys implemented something like this?
> > > is there any solution like that in The Netty project?
> > > Does my solution makes sense to you or am I missing a core concept of
> > > Netty?
> > > Feel free to share any other input you have.
> > >
> > > Thanks,
> > > Qballer
> > >
> > >
> > > --
> > > View this message in context:
> > > http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Buffer-Sainity-QNA-tp6912457p6912457.html
> > > Sent from the Netty User Group mailing list archive at Nabble.com (http://Nabble.com)
> > > <http://Nabble.com>.
> > > _______________________________________________
> > > netty-users mailing list
> > > netty-users at lists.jboss.org <mailto:netty-users at lists.jboss.org>
> > > https://lists.jboss.org/mailman/listinfo/netty-users
> >
> >
> >
> > _______________________________________________
> > netty-users mailing list
> > netty-users at lists.jboss.org (mailto:netty-users at lists.jboss.org)
> > https://lists.jboss.org/mailman/listinfo/netty-users
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org (mailto:netty-users at lists.jboss.org)
> https://lists.jboss.org/mailman/listinfo/netty-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20111020/cf3c31d9/attachment.html
More information about the netty-users
mailing list