diff --git a/src/common/autoconfig.h.in b/src/common/autoconfig.h.in index c4afb414..d15a05a4 100644 --- a/src/common/autoconfig.h.in +++ b/src/common/autoconfig.h.in @@ -114,6 +114,9 @@ /* Define to the sub-directory where libtool stores uninstalled libraries. */ #undef LT_OBJDIR +/* Evict indexed files from page cache */ +#undef NOCACHE_INDEXED + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT diff --git a/src/configure.ac b/src/configure.ac index 2665f6d1..df0fc132 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -483,6 +483,11 @@ if test X$enableQT = Xyes ; then ##################### End QT stuff fi +AC_ARG_ENABLE([nocache], + AS_HELP_STRING([--enable-nocache], [Evict indexed files from page cache])) +AS_IF([test "x$enable_nocache" = "xyes"], [ + AC_DEFINE(NOCACHE_INDEXED, 1, [Evict indexed files from page cache]) +]) ### X11: this is needed for the session monitoring code (in recollindex -m) AC_ARG_ENABLE(x11mon, diff --git a/src/index/fsindexer.cpp b/src/index/fsindexer.cpp index 97a4d461..f43236f5 100644 --- a/src/index/fsindexer.cpp +++ b/src/index/fsindexer.cpp @@ -47,6 +47,10 @@ #include "rclinit.h" #include "extrameta.h" #include "utf8fn.h" +#if defined(NOCACHE_INDEXED) && !defined(_WIN32) +#include +#include +#endif using namespace std; @@ -862,6 +866,20 @@ FsIndexer::processonefile(RclConfig *config, m_purgeCandidates.record(parent_udi); } } +#if defined(NOCACHE_INDEXED) && !defined(_WIN32) && defined(POSIX_FADV_DONTNEED) + // See framagit issue 26. If this appears to be a good idea + // after all (not sure), we'll need a command line switch to + // control it. For now it's compile-time only. + if (nullptr == getenv("NO_NOCACHE_INDEXED")) { + int fd = open(fn.c_str(), O_RDONLY); + if (fd >= 0) { + if (posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED)) { + LOGSYSERR("processonefile", "posix_fadvise", fn); + } + close(fd); + } + } +#endif } // If we had no instance with a null ipath, we create an empty