Reviewed-by: Marek Olšák <marek.ol...@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@2.70GHz + * (a fairly modist desktop CPU). 1 thread was choosen because we don't + * really care about getting things to disk quickly just that it's not + * blocking other tasks. + */ + util_queue_init(&cache->cache_queue, "disk_cache", 32, 1); + ralloc_free(local); return cache; fail: if (fd != -1) close(fd); if (cache) ralloc_free(cache); ralloc_free(local); return NULL; } void disk_cache_destroy(struct disk_cache *cache) { - if (cache) + if (cache) { + util_queue_destroy(&cache->cache_queue); munmap(cache->index_mmap, cache->index_mmap_size); + } ralloc_free(cache); } /* Return a filename within the cache's directory corresponding to 'key'. The * returned filename is ralloced with 'cache' as the parent context. * * Returns NULL if out of memory. */ static char * -- 2.9.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev