From ea3787e393f8bbac7e266529808003632dff50be Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Sat, 5 Oct 2024 15:00:08 +0100 Subject: [PATCH] Call posix_fadvise() each time we open a new file, not just on the first one. --- docs/NEWS.md | 1 + src/pv/loop.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docs/NEWS.md b/docs/NEWS.md index d6359c1..0409f3f 100644 --- a/docs/NEWS.md +++ b/docs/NEWS.md @@ -9,6 +9,7 @@ * fix: surround average rate ("`--average-rate`") with brackets rather than square brackets * fix: correct a memory leak in "`--watchfd PID`" * fix: make "`--direct-io`" work correctly with "`--output`" instead of assuming stdout + * fix: call `posix_fadvise()` on every input, not just the first one * fix: write UTC timestamps in debugging mode to avoid lockups in signal handlers * cleanup: removed TODO.md, since it's just an outdated copy of the issue tracker * cleanup: re-ordered structure members to reduce padding diff --git a/src/pv/loop.c b/src/pv/loop.c index ae57fdf..eb69cd5 100644 --- a/src/pv/loop.c +++ b/src/pv/loop.c @@ -258,6 +258,10 @@ int pv_main_loop(pvstate_t state) if (input_fd >= 0) { eof_in = false; eof_out = false; +#if HAVE_POSIX_FADVISE + /* Advise the OS that we will only be reading sequentially. */ + (void) posix_fadvise(input_fd, 0, 0, POSIX_FADV_SEQUENTIAL); +#endif } }