Experimental: configure option to call posix_fadvise(POSIX_FADV_DONTNEED) on each indexed file. If enabled, can be disabled at run time by setting NO_NOCACHE_INDEXED in the environment.
This commit is contained in:
parent
2678b304c5
commit
905f94b961
@ -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
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -47,6 +47,10 @@
|
||||
#include "rclinit.h"
|
||||
#include "extrameta.h"
|
||||
#include "utf8fn.h"
|
||||
#if defined(NOCACHE_INDEXED) && !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user