[Fontconfig] [PATCH 1/2] Use posix_fadvise to speed startup
Keith Packard
keithp at keithp.com
Mon Apr 16 11:28:36 PDT 2012
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 at keithp.com>
---
configure.in | 2 +-
src/fccache.c | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/configure.in b/configure.in
index da6ef95..a5e9e33 100644
--- a/configure.in
+++ b/configure.in
@@ -119,7 +119,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])
+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 posix_fadvise])
#
# Checks for iconv
diff --git a/src/fccache.c b/src/fccache.c
index d8102d7..a72dbb6 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -612,6 +612,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)
--
1.7.10
More information about the Fontconfig
mailing list