---
 src/util/disk_cache.c | 15 ++++++++++++++-
 src/util/disk_cache.h |  2 ++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index facdcec..426cc55 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -53,20 +53,23 @@
 /* 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 +373,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 *
diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
index 3659b6d..f707ee4 100644
--- a/src/util/disk_cache.h
+++ b/src/util/disk_cache.h
@@ -25,20 +25,22 @@
 #define DISK_CACHE_H
 
 #ifdef ENABLE_SHADER_CACHE
 #include <dlfcn.h>
 #endif
 #include <assert.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <sys/stat.h>
 
+#include "util/u_queue.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /* Size of cache keys in bytes. */
 #define CACHE_KEY_SIZE 20
 
 typedef uint8_t cache_key[CACHE_KEY_SIZE];
 
 struct disk_cache;
-- 
2.9.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to