[Mesa-dev] [PATCH 4/4] util/disk_cache: use a thread queue to write to shader cache

Timothy Arceri tarceri at itsqueeze.com
Mon Mar 13 03:01:40 UTC 2017



On 13/03/17 12:01, Timothy Arceri wrote:
> This should help reduce any overhead added by the shader cache
> when programs are not found in the cache.
>
> To avoid creating any special function just for the sake of the
> tests we add a one second delay whenever we call dick_cache_put()
> to give it time to finish.
> ---
>  src/compiler/glsl/tests/cache_test.c | 49 +++++++++++++++++++++++++++++++-----
>  src/util/disk_cache.c                | 41 ++++++++++++++++++++----------
>  2 files changed, 71 insertions(+), 19 deletions(-)
>
> diff --git a/src/compiler/glsl/tests/cache_test.c b/src/compiler/glsl/tests/cache_test.c
> index 6451e65..f8259e0 100644
> --- a/src/compiler/glsl/tests/cache_test.c
> +++ b/src/compiler/glsl/tests/cache_test.c
> @@ -25,20 +25,21 @@
>
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <stdbool.h>
>  #include <string.h>
>  #include <ftw.h>
>  #include <errno.h>
>  #include <stdarg.h>
>  #include <inttypes.h>
>  #include <limits.h>
> +#include <time.h>
>  #include <unistd.h>
>
>  #include "util/mesa-sha1.h"
>  #include "util/disk_cache.h"
>
>  bool error = false;
>
>  #ifdef ENABLE_SHADER_CACHE
>
>  static void
> @@ -224,20 +225,27 @@ does_cache_contain(struct disk_cache *cache, cache_key key)
>
>     if (result) {
>        free(result);
>        return true;
>     }
>
>     return false;
>  }
>
>  static void
> +wait_one_second()
> +{
> +    unsigned wait_time = time(0) + 1;
> +    while (time(0) < wait_time);
> +}
> +
> +static void
>  test_put_and_get(void)
>  {
>     struct disk_cache *cache;
>     /* If the text of this blob is changed, then blob_key_byte_zero
>      * also needs to be updated.
>      */
>     char blob[] = "This is a blob of thirty-seven bytes";
>     uint8_t blob_key[20];
>     uint8_t blob_key_byte_zero = 0xca;
>     char string[] = "While this string has thirty-four";
> @@ -253,35 +261,49 @@ test_put_and_get(void)
>     _mesa_sha1_compute(blob, sizeof(blob), blob_key);
>
>     /* Ensure that disk_cache_get returns nothing before anything is added. */
>     result = disk_cache_get(cache, blob_key, &size);
>     expect_null(result, "disk_cache_get with non-existent item (pointer)");
>     expect_equal(size, 0, "disk_cache_get with non-existent item (size)");
>
>     /* Simple test of put and get. */
>     disk_cache_put(cache, blob_key, blob, sizeof(blob), NULL);
>
> +   /* disk_cache_put() hands things off to a thread give it some time to
> +    * finsih.

I've fixed these typos in finish locally.


More information about the mesa-dev mailing list