Skip to content

Performance improvement for cat without arguments

Jeremy Soller requested to merge Tommoa:master into master

Created by: Tommoa

std::io::copy() has a tendency to be slow (most likely because its streamed), so adding an additional function that simply reads into a buffer then outputs it gives a relatively significant performance boost.

Of course, usually the speed of cat isn't something that is important, but this lets the coreutils beat gnu-coreutils (around 2.4-2.6 GB/s on my machine) and may improve quality of life for people that use cat to copy files for some reason.

When using flags, cat still has a tendency to be ridiculously slow (116 MB/s on my machine vs 685 MB/s for gnu-cat), but it still is an improvement compared to how it was before (58 MB/s).

Testing was done on an Intel m3-6Y30 using cat /dev/zero | pipebench -q > /dev/null

Merge request reports