From 55efc5f3ee485b3e31a91c331f07c89aeccc4e89 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Fri, 6 Mar 2009 22:30:55 +0000 Subject: cat,cp,mv,install,split: Set the minimum IO block size used to 32KiB This is following on from this change: [02c3dc9d 2008-03-06 cat: use larger buffer sizes ...] which increased the IO block size used by cat by 8 times, but also capped it at 32KiB. * NEWS: Mention the change in behavior. * src/system.h: Add a new io_blksize() function that returns the max of ST_BLKSIZE or 32KiB, as this was seen as a good value for a minimum block size to use to get good performance while minimizing system call overhead. * src/cat.c: Use it. * src/copy.c: ditto * src/split.c: ditto --- src/cat.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/cat.c') diff --git a/src/cat.c b/src/cat.c index 04eb204d4..18fa1f150 100644 --- a/src/cat.c +++ b/src/cat.c @@ -78,12 +78,6 @@ static char *line_num_end = line_buf + LINE_COUNTER_BUF_LEN - 3; /* Preserves the `cat' function's local `newlines' between invocations. */ static int newlines2 = 0; -static inline size_t -compute_buffer_size (struct stat st) -{ - return MIN (8 * ST_BLKSIZE (st), 32 * 1024); -} - void usage (int status) { @@ -642,7 +636,7 @@ main (int argc, char **argv) if (fstat (STDOUT_FILENO, &stat_buf) < 0) error (EXIT_FAILURE, errno, _("standard output")); - outsize = compute_buffer_size (stat_buf); + outsize = io_blksize (stat_buf); /* Input file can be output file for non-regular files. fstat on pipes returns S_IFSOCK on some systems, S_IFIFO on others, so the checking should not be done for those types, @@ -706,7 +700,7 @@ main (int argc, char **argv) ok = false; goto contin; } - insize = compute_buffer_size (stat_buf); + insize = io_blksize (stat_buf); /* Compare the device and i-node numbers of this input file with the corresponding values of the (output file associated with) -- cgit v1.2.3-54-g00ecf