[Mesa-dev] [PATCH 1/4] util/disk_cache: add thread queue to disk cache

Grazvydas Ignotas notasas at gmail.com
Mon Mar 13 09:58:38 UTC 2017


On Mon, Mar 13, 2017 at 3:01 AM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> Reviewed-by: Marek Olšák <marek.olsak at amd.com>
> ---
>  src/util/disk_cache.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
> index facdcec..3b1cffc 100644
> --- a/src/util/disk_cache.c
> +++ b/src/util/disk_cache.c
> @@ -34,39 +34,43 @@
>  #include <sys/mman.h>
>  #include <unistd.h>
>  #include <fcntl.h>
>  #include <pwd.h>
>  #include <errno.h>
>  #include <dirent.h>
>  #include "zlib.h"
>
>  #include "util/crc32.h"
>  #include "util/u_atomic.h"
> +#include "util/u_queue.h"
>  #include "util/mesa-sha1.h"
>  #include "util/ralloc.h"
>  #include "main/errors.h"
>
>  #include "disk_cache.h"
>
>  /* Number of bits to mask off from a cache key to get an index. */
>  #define CACHE_INDEX_KEY_BITS 16
>
>  /* Mask for computing an index from a key. */
>  #define CACHE_INDEX_KEY_MASK ((1 << CACHE_INDEX_KEY_BITS) - 1)
>
>  /* The number of keys that can be stored in the index. */
>  #define CACHE_INDEX_MAX_KEYS (1 << CACHE_INDEX_KEY_BITS)
>
>  struct disk_cache {
>     /* The path to the cache directory. */
>     char *path;
>
> +   /* Thread queue for compressing and writing cache entries to disk */
> +   struct util_queue cache_queue;
> +
>     /* A pointer to the mmapped index file within the cache directory. */
>     uint8_t *index_mmap;
>     size_t index_mmap_size;
>
>     /* Pointer to total size of all objects in cache (within index_mmap) */
>     uint64_t *size;
>
>     /* Pointer to stored keys, (within index_mmap). */
>     uint8_t *stored_keys;
>
> @@ -370,39 +374,49 @@ disk_cache_create(const char *gpu_name, const char *timestamp)
>           }
>        }
>     }
>
>     /* Default to 1GB for maximum cache size. */
>     if (max_size == 0)
>        max_size = 1024*1024*1024;
>
>     cache->max_size = max_size;
>
> +   /* A limit of 32 jobs was choosen as observations of Deus Ex start-up times
> +    * showed that we reached at most 11 jobs on an Intel i5-6400 CPU at 2.70GHz
> +    * (a fairly modist desktop CPU). 1 thread was choosen because we don't

modest, chosen?

with that, FWIW:
Reviewed-by: Grazvydas Ignotas <notasas at gmail.com>

Gražvydas


More information about the mesa-dev mailing list