[Mesa-dev] [PATCH] util/disk_cache: remove percentage based max cache limit
Timothy Arceri
tarceri at itsqueeze.com
Fri Apr 28 03:05:52 UTC 2017
The more I think about it the more this seems like a bad idea.
When we were deleting old cache dirs this wasn't so bad as it
was unlikely we would ever hit the actual limit before things
were cleaned up. Now that we only start cleaning up old cache
items once the limit is reached the a percentage based max
cache limit is more risky.
For the inital release of shader cache I think its better to
stick to a more conservative cache limit, at least until we
have some way of cleaning up the cache more aggressively.
Cc: "17.1" <mesa-stable at lists.freedesktop.org>
---
src/util/disk_cache.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 2764017..543f1c3 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -24,37 +24,35 @@
#ifdef ENABLE_SHADER_CACHE
#include <ctype.h>
#include <ftw.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/file.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/statvfs.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#include <pwd.h>
#include <errno.h>
#include <dirent.h>
#include "zlib.h"
#include "util/crc32.h"
#include "util/rand_xor.h"
#include "util/u_atomic.h"
#include "util/u_queue.h"
#include "util/mesa-sha1.h"
#include "util/ralloc.h"
#include "main/errors.h"
-#include "util/macros.h"
#include "disk_cache.h"
/* Number of bits to mask off from a cache key to get an index. */
#define CACHE_INDEX_KEY_BITS 16
/* 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. */
@@ -164,21 +162,20 @@ concatenate_and_mkdir(void *ctx, const char *path, const char *name)
struct disk_cache *
disk_cache_create(const char *gpu_name, const char *timestamp)
{
void *local;
struct disk_cache *cache = NULL;
char *path, *max_size_str;
uint64_t max_size;
int fd = -1;
struct stat sb;
- struct statvfs vfs = { 0 };
size_t size;
/* If running as a users other than the real user disable cache */
if (geteuid() != getuid())
return NULL;
/* A ralloc context for transient data during this invocation. */
local = ralloc_context(NULL);
if (local == NULL)
goto fail;
@@ -324,24 +321,23 @@ disk_cache_create(const char *gpu_name, const char *timestamp)
case '\0':
case 'G':
case 'g':
default:
max_size *= 1024*1024*1024;
break;
}
}
}
- /* Default to 1GB or 5% of filesystem for maximum cache size. */
+ /* Default to 1GB for maximum cache size. */
if (max_size == 0) {
- statvfs(path, &vfs);
- max_size = MAX2(1024*1024*1024, vfs.f_blocks * vfs.f_bsize / 20);
+ 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 at 2.70GHz
* (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.
*/
--
2.9.3
More information about the mesa-dev
mailing list