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
