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>
This commit is contained in:
Keith Packard 2012-04-16 11:28:36 -07:00 committed by Akira TAGOH
parent 94c2cc58a0
commit 9e62fcedfe
2 changed files with 4 additions and 1 deletions

View File

@ -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

View File

@ -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)