Pre-compiled shader cache cleaned by nvidia driver, causing stutter when launching vulkan apps

This is basically referring to an existing report: https://github.com/ValveSoftware/steam-for-linux/issues/11392

When launch steam games, game itself compiles shader cache at first launch and cache were stored. However, when launching the game again, the existing shader were deleted by nvidia driver due to exceeding driver’s openGL/vulkan shader cache size limit, back in driver 460 this was increased from 128 M to 1024 M, but modern games with dxvk or vkd3d tends to ahve bigger shader cache, leading to this problem.

In this forum article https://forums.developer.nvidia.com/t/opengl-shader-disk-cache-max-size-garbage-collection/60056/18, __GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 was mentioned, also __GL_SHADER_DISK_CACHE_SIZE= mentioned in the github issue above, these 2 environment variables should able to change driver’s shader cleanup behavior, but they didn’t work.

Here are my test steps:

  1. Start the game for the first time. Game compiles shader.
  2. Close the game and start it. The shader compiled before was deleted then being compiled again.
  3. Repeat step 2, same beahvior.

This result happens with conditions below, or in other words, these condition leads to the same result above:

  1. launch the game with no env;
  2. launch the game with __GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1;
  3. launch the game with __GL_SHADER_DISK_CACHE_SIZE=10737418240;
  4. launch the game with __GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 __GL_SHADER_DISK_CACHE_SIZE=10737418240

From the github issue above, this was tracked by nvidia internal bug 4932793 and 4934720.

Here is my nvidia bug report log:
nvidia-bug-report.log.gz (506.2 KB)

I hope this could help you resolve the problem why shader cleanup beahvior cannot be changed.

Update:

When env __GL_SHADER_DISK_CACHE_SKIP_CLEANUP=1 is being set system-wide (for example, /etc/environment), it do make nvidia driver not to chean shader cache. (I forget to note above in my post that, I set these env in steam’s game launch command)

Is this behavior expected?