Abstract


Zero Copy


  • Zero copy means CPU does not perform the task of copying data from one memory area to another with the help of DMA or in which unnecessary data copies are avoided

Benefits of zero copy

The CPU is consistently involved in copying data between the OS buffer in kernel space and the Kafka buffer in user space, and vice versa. Expensive context switching is also involved.

Using system calls like sendfile(2), data is copied directly from the OS buffer to the NIC buffer.

Unlike read and write, which require transferring data to and from user space, copying with sendfile occurs entirely within kernel space. The actual data transfer is offloaded to the DMA, freeing the CPU for other computational tasks.

sendfile is particularly useful when the application in user space does not need to process the data, and the data is ready to be sent out via the NIC (Network Interface Card).

References