From 9e62fcedfe774a13843cc0982bc3e535369b99eb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Apr 2012 11:28:36 -0700 Subject: Use posix_fadvise to speed startup Given that fontconfig will scan all of the cache file data during the first font search, ask the kernel to start reading the pages right away. Signed-off-by: Keith Packard --- configure.in | 2 +- src/fccache.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 1af2367..9c9de30 100644 --- a/configure.in +++ b/configure.in @@ -133,7 +133,7 @@ AC_TYPE_PID_T # Checks for library functions. AC_FUNC_VPRINTF AC_FUNC_MMAP -AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr strtol getopt getopt_long sysconf ftruncate chsize rand random lrand48 random_r rand_r regcomp regerror regexec regfree]) +AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr strtol getopt getopt_long sysconf ftruncate chsize rand random lrand48 random_r rand_r regcomp regerror regexec regfree posix_fadvise]) # # regex diff --git a/src/fccache.c b/src/fccache.c index db7561f..343ece9 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -609,6 +609,9 @@ FcDirCacheMapFd (int fd, struct stat *fd_stat, struct stat *dir_stat) { #if defined(HAVE_MMAP) || defined(__CYGWIN__) cache = mmap (0, fd_stat->st_size, PROT_READ, MAP_SHARED, fd, 0); +#ifdef HAVE_POSIX_FADVISE + posix_fadvise (fd, 0, fd_stat->st_size, POSIX_FADV_WILLNEED); +#endif if (cache == MAP_FAILED) cache = NULL; #elif defined(_WIN32) -- cgit v1.2.3