diff --git a/nx2navi.ini.example b/nx2navi.ini.example index a0cdd692..4bd4d65b 100644 --- a/nx2navi.ini.example +++ b/nx2navi.ini.example @@ -72,6 +72,8 @@ # oneshot_wait_ms = 30000 # Build shader stage libraries in the background ahead of time, and the threads for it (1 to 16; default: a quarter of # the CPU threads). +# Build shader stage libraries in the background ahead of time, and the threads for it (1 to 16; default 2). More +# threads mostly wait on the graphics driver's lock: 16 on NVIDIA spent about 8 cores spinning in the driver. # lib_prebuild = 1 # lib_prebuild_threads = 4 # 1: very large compute shaders that no cache holds are built on one background thread after the start. 0: each is diff --git a/runtime/vk_pipeline.c b/runtime/vk_pipeline.c index be7974f0..76f9ed8a 100644 --- a/runtime/vk_pipeline.c +++ b/runtime/vk_pipeline.c @@ -4214,7 +4214,12 @@ static void lb_start(const uint32_t pr_hist[16], const uint32_t fs_hist[4]) { lb_state(pr_hist, fs_hist); LB.idle = 1; int cpus = (int)plat_cpu_usable(); - int t = te && *te ? atoi(te) : cpus / 2; // idle priority; a cold driver takes ~2 s per large compute shader + // Two threads by default, not half the CPUs. On a 32-thread CPU with NVIDIA's driver, 16 builders kept the driver's + // lock busy: 77% of the process's running time was a spin loop in nvoglv64.dll (about 8 cores), the prebuild had not + // finished after 34,000 frames, and lib_prebuild = 0 took it to 5% and the game to its frame limit (RTX 4080 SUPER, + // driver 617.14, 2026-11-08). With the driver's disk cache warm (--prepare-shaders, --warm-shaders) a build takes + // well under a millisecond, so two threads still finish the list quickly. + int t = te && *te ? atoi(te) : (cpus < 4 ? 1 : 2); // idle priority; a cold driver takes ~2 s per large compute shader t = t < 1 ? 1 : t > LB_MAX_THREADS ? LB_MAX_THREADS : t; if ((size_t)t > n) t = (int)n; LB.t0 = now_ms();