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