diff options
author | Timothy Arceri <[email protected]> | 2017-03-09 10:51:01 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-03-15 11:15:10 +1100 |
commit | e2c4435b078a1471b044219552873a54b1817bac (patch) | |
tree | 8b980f727cd1888090e30baf255489ad26b6637e | |
parent | 7372e3cf5f2df9dd2ec0423a4425baad098bf326 (diff) |
util/disk_cache: add thread queue to disk cache
Reviewed-by: Marek Olšák <[email protected]>
Reviewed-by: Grazvydas Ignotas <[email protected]>
-rw-r--r-- | src/util/disk_cache.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c index facdcecf7ca..19b593b76d4 100644 --- a/src/util/disk_cache.c +++ b/src/util/disk_cache.c @@ -41,6 +41,7 @@ #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" @@ -60,6 +61,9 @@ 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; @@ -377,6 +381,14 @@ disk_cache_create(const char *gpu_name, const char *timestamp) 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 [email protected] + * (a fairly modest desktop CPU). 1 thread was chosen 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; @@ -394,8 +406,10 @@ disk_cache_create(const char *gpu_name, const char *timestamp) 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); } |