X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_open.c;h=3740750fb73e6839ead4d5c7a13a54e02547ad1c;hb=36b14cdfdbba7713d65c4d416b27c94b495b154a;hp=08c798482e94eb4349cd183ad2add4b3f7b2c9f7;hpb=4af79d1fe0fbb9655cf28a0989d2e98b94b37460;p=rrdtool.git diff --git a/src/rrd_open.c b/src/rrd_open.c index 08c7984..3740750 100644 --- a/src/rrd_open.c +++ b/src/rrd_open.c @@ -87,6 +87,19 @@ rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr) rrd_set_error("opening '%s': %s",file_name, rrd_strerror(errno)); return (-1); } + +#ifdef HAVE_POSIX_FADVISE + /* In general we need no read-ahead when dealing with rrd_files. + When we stop reading, it is highly unlikely that we start up again. + In this manner we actually save time and diskaccess (and buffer cache). + Thanks to Dave Plonka for the Idea of using POSIX_FADV_RANDOM here. */ + if (0 != posix_fadvise(fileno(*in_file), 0, 0, POSIX_FADV_RANDOM)) { + rrd_set_error("setting POSIX_FADV_RANDOM on '%s': %s",file_name, rrd_strerror(errno)); + fclose(*in_file); + return(-1); + } +#endif + /* if (rdwr == RRD_READWRITE) {