From 47076e3c7c22fc7557f388ad3d47228b922da71e Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Tue, 20 Jul 2010 18:51:01 +0100 Subject: provide POSIX_FADV_SEQUENTIAL hint to appropriate utils Following on from commit dae35bac, 01-03-2010, "sort: inform the system about our input access pattern" apply the same hint to all appropriate utils. This currently gives around a 5% speedup for reading large files from fast flash devices on GNU/Linux. * src/base64.c: Call fadvise (..., FADVISE_SEQUENTIAL); * src/cat.c: Likewise. * src/cksum.c: Likewise. * src/comm.c: Likewise. * src/cut.c: Likewise. * src/expand.c: Likewise. * src/fmt.c: Likewise. * src/fold.c: Likewise. * src/join.c: Likewise. * src/md5sum.c: Likewise. * src/nl.c: Likewise. * src/paste.c: Likewise. * src/pr.c: Likewise. * src/ptx.c: Likewise. * src/shuf.c: Likewise. * src/sum.c: Likewise. * src/tee.c: Likewise. * src/tr.c: Likewise. * src/tsort.c: Likewise. * src/unexpand.c: Likewise. * src/uniq.c: Likewise. * src/wc.c: Likewise, unless we don't actually read(). --- src/expand.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/expand.c') diff --git a/src/expand.c b/src/expand.c index be50063b6..249255d15 100644 --- a/src/expand.c +++ b/src/expand.c @@ -40,6 +40,7 @@ #include #include "system.h" #include "error.h" +#include "fadvise.h" #include "quote.h" #include "xstrndup.h" @@ -243,13 +244,14 @@ next_file (FILE *fp) if (STREQ (file, "-")) { have_read_stdin = true; - prev_file = file; - return stdin; + fp = stdin; } - fp = fopen (file, "r"); + else + fp = fopen (file, "r"); if (fp) { prev_file = file; + fadvise (fp, FADVISE_SEQUENTIAL); return fp; } error (0, errno, "%s", file); -- cgit v1.2.3-54-g00ecf