Lines Matching defs:cache
86 /* TODO: implement disk cache support on windows */
124 fprintf(stderr, "Cannot use %s for shader cache (not a directory)"
134 fprintf(stderr, "Failed to create %s for shader cache (%s)---disabling.\n",
218 * out to only be around 0.04% of total cache items.
381 /* Create the directory that will be needed for the cache file for \key.
387 make_cache_file_directory(struct disk_cache *cache, const cache_key key)
393 if (asprintf(&dir, "%s/%c%c", cache->path, buf[0], buf[1]) == -1)
430 /* Evict least recently used cache item */
432 disk_cache_evict_lru_item(struct disk_cache *cache)
436 /* With a reasonably-sized, full cache, (and with keys generated
439 * Provides pseudo-LRU eviction to reduce checking all cache files.
441 uint64_t rand64 = rand_xorshift128plus(cache->seed_xorshift128plus);
442 if (asprintf(&dir_path, "%s/%02" PRIx64 , cache->path, rand64 & 0xff) < 0)
450 p_atomic_add(cache->size, - (uint64_t)size);
459 * tests to work, (which use an artificially-small cache to be able
463 choose_lru_file_matching(cache->path, is_two_character_sub_directory);
477 p_atomic_add(cache->size, - (uint64_t)size);
481 disk_cache_evict_item(struct disk_cache *cache, char *filename)
493 p_atomic_add(cache->size, - (uint64_t)sb.st_blocks * 512);
497 parse_and_validate_cache_item(struct disk_cache *cache, void *cache_item,
505 size_t header_size = cache->driver_keys_blob_size;
511 if (memcmp(cache->driver_keys_blob, keys_blob, header_size) != 0) {
512 assert(!"Mesa cache keys mismatch!");
525 /* The cache item metadata is currently just used for distributing
551 /* Uncompress the cache data */
570 disk_cache_load_item(struct disk_cache *cache, char *filename, size_t *size)
592 parse_and_validate_cache_item(cache, data, sb.st_size, size);
613 /* Return a filename within the cache's directory corresponding to 'key'.
618 disk_cache_get_cache_filename(struct disk_cache *cache, const cache_key key)
623 if (cache->path_init_failed)
627 if (asprintf(&filename, "%s/%c%c/%s", cache->path, buf[0],
639 /* Compress the cache item data */
655 if (!blob_write_bytes(cache_blob, dc_job->cache->driver_keys_blob,
656 dc_job->cache->driver_keys_blob_size))
659 /* Write the cache item metadata. This data can be used to deal with
661 * tools reading the cache files.
678 * cache and use it to check for corruption.
687 /* Finally copy the compressed cache blob */
717 /* Make the two-character subdirectory within the cache as needed. */
722 make_cache_file_directory(dc_job->cache, dc_job->key);
752 * (to ensure the size accounting of the cache doesn't get off).
761 * not in the cache, and is also not being written out to the cache
771 * perform an atomic increment of the total cache size.
792 p_atomic_add(dc_job->cache->size, sb.st_blocks * 512);
806 /* Determine path for cache based on the first defined name as follows:
810 * <pwd.pw_dir>/.cache/mesa_shader_cache
878 path = concatenate_and_mkdir(mem_ctx, pwd.pw_dir, ".cache");
903 /* If running as a users other than the real user disable cache */
907 /* At user request, disable shader cache entirely. */
929 disk_cache_load_item_foz(struct disk_cache *cache, const cache_key key,
933 void *cache_item = foz_read_entry(&cache->foz_db, key, &cache_tem_size);
938 parse_and_validate_cache_item(cache, cache_item, cache_tem_size, size);
953 bool r = foz_write_entry(&dc_job->cache->foz_db, dc_job->key,
961 disk_cache_load_cache_index(void *mem_ctx, struct disk_cache *cache)
963 /* Load cache index into a hash map (from fossilise files) */
964 return foz_prepare(&cache->foz_db, cache->path);
968 disk_cache_mmap_cache_index(void *mem_ctx, struct disk_cache *cache,
974 path = ralloc_asprintf(mem_ctx, "%s/index", cache->path);
987 size_t size = sizeof(*cache->size) + CACHE_INDEX_MAX_KEYS * CACHE_KEY_SIZE;
997 * processes don't scramble the cache size recorded in the
1006 * unlikely to ever match a real cache key).
1008 cache->index_mmap = mmap(NULL, size, PROT_READ | PROT_WRITE,
1010 if (cache->index_mmap == MAP_FAILED)
1012 cache->index_mmap_size = size;
1014 cache->size = (uint64_t *) cache->index_mmap;
1015 cache->stored_keys = cache->index_mmap + sizeof(uint64_t);
1026 disk_cache_destroy_mmap(struct disk_cache *cache)
1028 munmap(cache->index_mmap, cache->index_mmap_size);