The problem I see if you choose to copy the user buffer into a DirectBuffer is that your memory consumption will double even if the DirectBuffer is not allocated on the heap, it may be problematic
Regards Jeff On Wed, Jan 9, 2013 at 11:44 AM, Emmanuel Lécharny <elecha...@gmail.com>wrote: > Le 1/5/13 1:27 PM, Jeff MAURY a écrit : > > Regarding the message size, I noticed that Mina2 writes only a sub part > of > > the message (size is computed from the receive buffer size if I remember > > correctly) whereas Netty tries to write the buffer buffer to the socket. > So > > If you did the same in Mina3, it may explain why it is slow > > This can perfectly well be the reason for the horible performances we > get when dealing with huge messages : as Jeff suggested, the HeapBuffer > might be copied totally into a DirectBuffer when trying to write the > message, regardless of the SendBufferSize. If so (ouch), we will do that > 1000 times for a 64Mb message and a SendBufferSIze of 64Kb... > > I will experiment another solution for MINA 3 : allocating a > DirectBuffer once for each thread, with a SendBufferSize size, and use > this buffer to write into the socket. I'm also wondering if it would not > be better to copy the HeapBuffer into a DirectBuffer before trying to > write the message, as we may avoid copying the data from the Heap buffer > into the DirectBuffer many times. > > Interesting thread ! > > -- > Regards, > Cordialement, > Emmanuel Lécharny > www.iktek.com > > -- Jeff MAURY "Legacy code" often differs from its suggested alternative by actually working and scaling. - Bjarne Stroustrup http://www.jeffmaury.com http://riadiscuss.jeffmaury.com http://www.twitter.com/jeffmaury