Use posix_fadvise() on input files, where available.

This commit is contained in:
Andrew Wood
2023-08-28 13:10:38 +01:00
parent 7d07db6526
commit b1ef744058
7 changed files with 18 additions and 3 deletions
+3
View File
@@ -61,6 +61,9 @@
/* Define to 1 if you have the <minix/config.h> header file. */
#undef HAVE_MINIX_CONFIG_H
/* Define to 1 if you have the `posix_fadvise' function. */
#undef HAVE_POSIX_FADVISE
/* Define to 1 if you have the `posix_memalign' function. */
#undef HAVE_POSIX_MEMALIGN
+6
View File
@@ -165,6 +165,11 @@ unsigned long long pv_calc_total_size(pvstate_t state)
return total;
}
#if HAVE_POSIX_FADVISE
/* Advise the OS that we will only be reading sequentially. */
(void) posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
#endif
while (1) {
unsigned char scanbuf[1024];
int numread, j;
@@ -275,6 +280,7 @@ int pv_next_file(pvstate_t state, int filenum, int oldfd)
if (0 == strcmp(state->input_files[filenum], "-")) {
state->current_file = "(stdin)";
}
#ifdef O_DIRECT
/*
* Set or clear O_DIRECT on the file descriptor.
+6
View File
@@ -114,6 +114,12 @@ int pv_main_loop(pvstate_t state)
pv_crs_fini(state);
return state->exit_status;
}
#if HAVE_POSIX_FADVISE
/* Advise the OS that we will only be reading sequentially. */
(void) posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
#endif
#ifdef O_DIRECT
/*
* Set or clear O_DIRECT on the output.