mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 00:10:10 +01:00
util/disk_cache: Add marker on cache usage.
To be able to delete it later if it isn't used. Checking the mtime on e.g. the index doesn't work if we always hit the cache so add something that writes unconditionally. Only once per day to avoid excessive writes. (See https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22339) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27173>
This commit is contained in:
parent
5fbb00dbc7
commit
3f119a1fd8
3 changed files with 30 additions and 0 deletions
|
|
@ -146,6 +146,9 @@ disk_cache_type_create(const char *gpu_name,
|
|||
goto path_fail;
|
||||
}
|
||||
|
||||
if (!getenv("MESA_SHADER_CACHE_DIR") && !getenv("MESA_GLSL_CACHE_DIR"))
|
||||
disk_cache_touch_cache_user_marker(cache->path);
|
||||
|
||||
cache->type = cache_type;
|
||||
|
||||
cache->stats.enabled = debug_get_bool_option("MESA_SHADER_CACHE_SHOW_STATS",
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ disk_cache_get_function_identifier(void *ptr, struct mesa_sha1 *ctx)
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "utime.h"
|
||||
|
||||
#include "util/blob.h"
|
||||
#include "util/crc32.h"
|
||||
|
|
@ -1044,6 +1045,29 @@ disk_cache_load_cache_index_foz(void *mem_ctx, struct disk_cache *cache)
|
|||
return foz_prepare(&cache->foz_db, cache->path);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
disk_cache_touch_cache_user_marker(char *path)
|
||||
{
|
||||
char *marker_path = NULL;
|
||||
asprintf(&marker_path, "%s/marker", path);
|
||||
if (!marker_path)
|
||||
return;
|
||||
|
||||
time_t now = time(NULL);
|
||||
|
||||
struct stat attr;
|
||||
if (stat(marker_path, &attr) == -1) {
|
||||
int fd = open(marker_path, O_WRONLY | O_CREAT | O_CLOEXEC, 0644);
|
||||
if (fd != -1) {
|
||||
close(fd);
|
||||
}
|
||||
} else if (now - attr.st_mtime < 60 * 60 * 24 /* One day */) {
|
||||
(void)utime(marker_path, NULL);
|
||||
}
|
||||
free(marker_path);
|
||||
}
|
||||
|
||||
bool
|
||||
disk_cache_mmap_cache_index(void *mem_ctx, struct disk_cache *cache,
|
||||
char *path)
|
||||
|
|
|
|||
|
|
@ -161,6 +161,9 @@ disk_cache_enabled(void);
|
|||
bool
|
||||
disk_cache_load_cache_index_foz(void *mem_ctx, struct disk_cache *cache);
|
||||
|
||||
void
|
||||
disk_cache_touch_cache_user_marker(char *path);
|
||||
|
||||
bool
|
||||
disk_cache_mmap_cache_index(void *mem_ctx, struct disk_cache *cache,
|
||||
char *path);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue