Ariadne Conill, creator of the Audacious audio player, initiator of the IRCv3 protocol development, and leader of the Alpine Linux security team, conducted a study on how to optimize the cat utility, which outputs one or more files to the standard output stream. Two optimization options have been proposed for improving cat's performance in Linux, based on the use of the sendfile and splice system calls for direct data copying between file descriptors at the kernel level without context switching to user space.
The basic implementation, using traditional read and write calls that cause context switching, showed a performance of 3.6 GB/s when copying a 4GB file from tmpfs. The sendfile-based variant improved performance to 6.4 GB/s, while the splice-based variant achieved 11.6 GB/s, making it over three times faster than the original implementation.
Source: opennet.ru
