to be a little bit more precise, you will copy 64Mb the first time then
64Mb - 64kb the second time and so on

Jeff



On Thu, Jan 10, 2013 at 12:11 PM, Emmanuel Lécharny <elecha...@gmail.com>wrote:

> Le 1/10/13 10:56 AM, Jeff MAURY a écrit :
> > The performance gain is not related to the nature of the buffer; I mean
> > writing to an HeapBuffer vs writing to a DirectBuffer but related to
> > writing the buffer to the socket: if you write an HeapBuffer to a socket,
> > my guess is that it will be copied to a DirectBuffer before it gets
> written
> > to the socket which is not the case for a DirectBuffer
>
> This is exactly what happens. Internally, for each call to the
> channel.write(HeapBuffer), there is a call to DirectBuffer.pu(HeapBuffer).
>
> You can imagine how costly this is when the HeapBuffer is 64 Mb big, and
> we send only a fragment of it for each round... If the SendBufferSize is
> 64Kb, in this case, you will just copy the 64Mb 1000 times.
>
> Good catch btw, Jeff !
>
>
> --
> 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

Reply via email to