[PATCH 1/2] Use posix_fadvise to speed startup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig


[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux