util/disk_cache: Move blob_put_cb to the async queue

Move deflate and put to the queue for the blob cache case.  This moves
the overhead out of the app thread when storing new shaders.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22248>
This commit is contained in:
Rob Clark 2023-04-01 07:38:40 -07:00 committed by Marge Bot
parent dab1bd5a77
commit 66d4dbd960

View file

@ -426,6 +426,10 @@ destroy_put_job_nocopy(void *job, void *gdata, int thread_index)
destroy_put_job(job, gdata, thread_index);
}
static void
blob_put_compressed(struct disk_cache *cache, const cache_key key,
const void *data, size_t size);
static void
cache_put(void *job, void *gdata, int thread_index)
{
@ -435,7 +439,9 @@ cache_put(void *job, void *gdata, int thread_index)
char *filename = NULL;
struct disk_cache_put_job *dc_job = (struct disk_cache_put_job *) job;
if (dc_job->cache->type == DISK_CACHE_SINGLE_FILE) {
if (dc_job->cache->blob_put_cb) {
blob_put_compressed(dc_job->cache, dc_job->key, dc_job->data, dc_job->size);
} else if (dc_job->cache->type == DISK_CACHE_SINGLE_FILE) {
disk_cache_write_item_to_disk_foz(dc_job);
} else if (dc_job->cache->type == DISK_CACHE_DATABASE) {
disk_cache_db_write_item_to_disk(dc_job);
@ -546,11 +552,6 @@ disk_cache_put(struct disk_cache *cache, const cache_key key,
const void *data, size_t size,
struct cache_item_metadata *cache_item_metadata)
{
if (cache->blob_put_cb) {
blob_put_compressed(cache, key, data, size);
return;
}
if (!util_queue_is_initialized(&cache->cache_queue))
return;
@ -569,12 +570,6 @@ disk_cache_put_nocopy(struct disk_cache *cache, const cache_key key,
void *data, size_t size,
struct cache_item_metadata *cache_item_metadata)
{
if (cache->blob_put_cb) {
blob_put_compressed(cache, key, data, size);
free(data);
return;
}
if (!util_queue_is_initialized(&cache->cache_queue)) {
free(data);
return;
@ -691,6 +686,7 @@ disk_cache_set_callbacks(struct disk_cache *cache, disk_cache_put_cb put,
{
cache->blob_put_cb = put;
cache->blob_get_cb = get;
disk_cache_init_queue(cache);
}
#endif /* ENABLE_SHADER_CACHE */