An experiment to improve the efficiency of the cat utility

Ariadne Conill, creator of the Audacious music player, pioneer of the IRCv3 protocol, and leader of the Alpine Linux security team, has done research on how to optimize the cat utility that prints one or more files to standard output. To improve the performance of cat on Linux, two optimizations have been proposed based on the use of the sendfile and splice system calls to directly copy data between file descriptors at the kernel level without context switching to user space.

The base implementation, using traditional read and write calls resulting in a context switch, when copying a 4GB file from tmpfs showed a throughput of 3.6 GB/s. The sendfile-based variant increased performance to 6.4 GB/s, and the splice-based variant to 11.6 GB/s, i.e. turned out to be faster than the original version by more than 3 times.

Source: opennet.ru

Add a comment