Name NVIDIA's Shader Cache Size limit when the library warm finds the driver's cache cold.

The driver keeps the prepared shaders' libraries in its shader cache, and under Windows that cache has a size limit
set in NVIDIA's settings. A limit smaller than the set drops the oldest libraries as new ones come in (a 2048 MB cache
could not hold them on the reporter's RTX 5070 Ti), so every start builds them again in the background and play
stutters until that is done. The cold lines of the library warm now say so on NVIDIA under Windows, most plainly when
the cache is cold right after a warm that finished on the same driver; the build kit's notes and the example file say
it too. tests/warm_hint_check.py checks which hint each case gets.

From pull request #403 by tarballz; two conflicts resolved (an include and the build kit's notes).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 09:13:35 -05:00
parent 25e31815fd
commit a1fcbb0b07
7 changed files with 179 additions and 3 deletions

View File

@@ -49,6 +49,7 @@
#include "platform/platform.h"
#include "tex.h"
#include "vk_gpa.h"
#include "vk_warm_hint.h"
#define LOG_ONCE(...) do { static volatile int32_t once_; if (!plat_xchg32(&once_, 1)) rt_log(__VA_ARGS__); } while (0)
@@ -5115,6 +5116,7 @@ static struct {
volatile int32_t running, stop, started;
PlatThread *th[LW_MAX_THREADS + 1];
int threads, strikes;
uint32_t vendor; // the GPU's vendor id, for what a cold cache's log line adds (vk_warm_hint.h)
double t0;
char stamp[PLAT_PATH_MAX * 2 + 32], id[64];
} LW;
@@ -5208,7 +5210,8 @@ static void lw_main(void *arg) {
if (!resume && same && strikes >= 2 && strcmp(mode, "force")) {
rt_log("vk_pipeline: library warm: the prepared libraries are cold again (a sample's median %.0f ms) after two "
"finished warms on this driver: it does not keep them, so pipelines compile when a draw first needs "
"them (NX2NAVI_LIB_WARM=force warms anyway)", median);
"them (NX2NAVI_LIB_WARM=force warms anyway).%s", median,
lw_cold_hint(LW.vendor, LW_COLD_GAVE_UP, LW_ON_WINDOWS));
return;
}
LW.strikes = resume ? strikes : same && !strcmp(was, "done") ? strikes + 1 : 0;
@@ -5218,11 +5221,15 @@ static void lw_main(void *arg) {
if (resume)
rt_log("vk_pipeline: library warm: going on with the warm an earlier run began: %zu prepared variants on %d "
"idle threads", LW.n, t);
else
else // cold right after a finished warm on this driver says more than a first cold (vk_warm_hint.h)
rt_log("vk_pipeline: library warm: the driver's cache does not have the prepared libraries (a sample's median "
"%.0f ms; a driver update or a change of what they are built with): building %zu prepared variants "
"into it on %d idle threads while the game runs. Until it is done, a pipeline a draw first needs may "
"compile, which skips that draw for some frames or makes it wait", median, LW.n, t);
"compile, which skips that draw for some frames or makes it wait.%s", median, LW.n, t,
lw_cold_hint(LW.vendor,
median <= LW_COLD_MS ? LW_WARM_FORCED // warm, but lib_warm = force
: same && !strcmp(was, "done") ? LW_COLD_AFTER_WARM : LW_COLD_FIRST,
LW_ON_WINDOWS));
LW.t0 = now_ms();
LW.running = t;
int started = 0;
@@ -5252,6 +5259,7 @@ static void lw_start(void) {
VkPhysicalDeviceProperties pp;
vkGetPhysicalDeviceProperties(vk_ctx()->phys, &pp);
snprintf(LW.id, sizeof LW.id, "%04x:%04x:%08x", pp.vendorID, pp.deviceID, pp.driverVersion);
LW.vendor = pp.vendorID;
LW.th[0] = plat_thread_new(lw_main, NULL, "lib warm check");
}