cat: use larger buffer sizes to reduce read/write-syscall overhead
commit02c3dc9de8d3cf26b319b7a7b144878a2afb91bb
authorJim Meyering <meyering@redhat.com>
Fri, 6 Mar 2009 09:27:43 +0000 (6 10:27 +0100)
committerJim Meyering <meyering@redhat.com>
Fri, 6 Mar 2009 13:41:47 +0000 (6 14:41 +0100)
tree9f1bd130e682decd35b72995b1b3d75bafdaeced
parent8b638f994abefde84746b3d8a08893c9ffeb7799
cat: use larger buffer sizes to reduce read/write-syscall overhead

* src/cat.c (max): Remove definition.  Use MAX from system.h instead.
(compute_buffer_size): New function to compute the input and output
buffer sizes, which are now set at 8 times st_blksize with a maximum
of 32KiB. Previously the typical block sizes used were 1KiB for pipes
and 4KiB for files, and now will be 8KiB and 32KiB respectively.
(main): Use it.
This change can double throughput on modern systems.  For timings,
see http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/16040
Suggestion from Tzvi Rotshtein.
THANKS
src/cat.c