Mesa (master): glsl/shader_cache: restore evicted shader keys

Timothy Arceri tarceri at kemper.freedesktop.org
Sun Mar 26 22:14:57 UTC 2017


Module: Mesa
Branch: master
Commit: f2d4d116113c8eddf7e8f372d466510c31d3dba4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2d4d116113c8eddf7e8f372d466510c31d3dba4

Author: Grazvydas Ignotas <notasas at gmail.com>
Date:   Sun Mar 26 19:28:38 2017 +0300

glsl/shader_cache: restore evicted shader keys

Even though the programs themselves stay in cache and are loaded, the
shader keys can be evicted separately. If that happens, unnecessary
compiles are caused that waste time, and no matter how many times the
program is re-run, performance never recovers to the levels of first
hot cache run. To deal with this, we need to refresh the shader keys
of shaders that were recompiled.

An easy way to currently observe this is running Deux Ex, then piglit
and Deux Ex again, or deleting just the cache index. The later is
causing over a minute of lost time on all later Deux Ex runs, with this
patch it returns to normal after 1 run.

Signed-off-by: Grazvydas Ignotas <notasas at gmail.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/compiler/glsl/shader_cache.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index dd8c6c0b40..274bb8c91e 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1409,6 +1409,23 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
    /* This is used to flag a shader retrieved from cache */
    prog->data->LinkStatus = linking_skipped;
 
+   /* Since the program load was successful, CompileStatus of all shaders at
+    * this point should normally be compile_skipped. However because of how
+    * the eviction works, it may happen that some of the individual shader keys
+    * have been evicted, resulting in unnecessary recompiles on this load, so
+    * mark them again to skip such recompiles next time.
+    */
+   char sha1_buf[41];
+   for (unsigned i = 0; i < prog->NumShaders; i++) {
+      if (prog->Shaders[i]->CompileStatus == compile_success) {
+         disk_cache_put_key(cache, prog->Shaders[i]->sha1);
+         if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
+            _mesa_sha1_format(sha1_buf, prog->Shaders[i]->sha1);
+            fprintf(stderr, "re-marking shader: %s\n", sha1_buf);
+         }
+      }
+   }
+
    free (buffer);
 
    return true;




More information about the mesa-commit mailing list