summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-04-16 11:28:36 -0700
committerAkira TAGOH <akira@tagoh.org>2012-04-17 12:20:25 +0900
commit9e62fcedfe774a13843cc0982bc3e535369b99eb (patch)
tree34587b65b5452cc2efe0df938afeef18b32429fe
parent94c2cc58a091138aa8c507d6239eca69520b65f0 (diff)
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 <keithp@keithp.com>
-rw-r--r--configure.in2
-rw-r--r--src/fccache.c3
2 files changed, 4 insertions, 1 deletions
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)