Directly write CompositeByteBuf if possible without memory copy. Related to [#2719]
Motivation: In linux it is possible to write more then one buffer withone syscall when sending datagram messages. Modifications: Not copy CompositeByteBuf if it only contains direct buffers. Result: More performance due less overhead for copy.
This commit is contained in:
parent
fcb80e34ca
commit
b4feb7ac19
@ -372,6 +372,14 @@ public final class EpollDatagramChannel extends AbstractEpollChannel implements
|
||||
return msg;
|
||||
}
|
||||
|
||||
if (content.isDirect() && content instanceof CompositeByteBuf) {
|
||||
// Special handling of CompositeByteBuf to reduce memory copies if some of the Components
|
||||
// in the CompositeByteBuf are backed by a memoryAddress.
|
||||
CompositeByteBuf comp = (CompositeByteBuf) content;
|
||||
if (comp.isDirect() && comp.nioBufferCount() <= Native.IOV_MAX) {
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
// We can only handle direct buffers so we need to copy if a non direct is
|
||||
// passed to write.
|
||||
return new DatagramPacket(newDirectBuffer(packet, content), packet.recipient());
|
||||
|
Loading…
Reference in New Issue
Block a user