[Mesa-dev] [PATCH 2/4] util/disk_cache: compress individual cache entries

Grazvydas Ignotas notasas at gmail.com
Wed Mar 1 13:04:37 UTC 2017


On Wed, Mar 1, 2017 at 7:25 AM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> ...
> diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
> index 2a0edca..03aae02 100644
> --- a/src/util/disk_cache.c
> +++ b/src/util/disk_cache.c
> @@ -30,20 +30,21 @@
>  #include <stdio.h>
>  #include <sys/file.h>
>  #include <sys/types.h>
>  #include <sys/stat.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/u_atomic.h"
>  #include "util/mesa-sha1.h"
>  #include "util/ralloc.h"
>  #include "main/errors.h"
>
>  #include "disk_cache.h"
>
>  /* Number of bits to mask off from a cache key to get an index. */
> @@ -638,30 +639,106 @@ disk_cache_remove(struct disk_cache *cache, cache_key key)
>        return;
>     }
>
>     unlink(filename);
>     free(filename);
>
>     if (sb.st_size)
>        p_atomic_add(cache->size, - sb.st_size);
>  }
>
> +/* From the zlib docs:
> + *    "If the memory is available, buffers sizes on the order of 128K or 256K
> + *    bytes should be used."
> + */
> +#define BUFSIZE 256 * 1024
> +
> +/**
> + * Compresses cache entry in memeory and writes it to disk. Returns the size

typo: memory


More information about the mesa-dev mailing list