I found Netty documentation says they have "Transparent Zero Copy" feature in their build-in ByteBuffer
. But after the reading, I notice it doesn't mention any kernel space and user space switching, only something about reuse the buffer.
So I wonder is Netty's "Zero Copy" feature different from OS level "Zero Copy"(Which means reduce the copy from user space memory to kernel space memory) ?
According to Wikipedia:
OS-level zero copy involves avoiding copying memory blocks from one location to another (typically from user space to kernel space) before sending data to the hardware driver (network card or disk drive) or vice versa.
Netty zero copy is talking about optimizing data manipulation on Java level (user-space only). Their
ChannelBuffer
allows to read contents of multiple byte buffers without actually copying their content.In other words, while Netty works only in user space, it is still valid to call their approach "zero copy". However, if OS does not use or support true zero copy, it is possible that when data created by Netty-powered program will be sent over the network, data would still be copied from user space to kernel space, and thus true zero-copy would not be achieved.