[Fontconfig] [PATCH 1/2] Use posix_fadvise to speed startup

Akira TAGOH akira at tagoh.org
Mon Apr 16 18:40:00 PDT 2012


Thanks for the patch. I just wonder if it's needed prior to read()
too, particularly with POSIX_FADV_NOREUSE?

What do you think?

On Tue, Apr 17, 2012 at 3:28 AM, Keith Packard <keithp at keithp.com> wrote:
> 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
>
> _______________________________________________
> Fontconfig mailing list
> Fontconfig at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/fontconfig



-- 
Akira TAGOH


More information about the Fontconfig mailing list