Build the boot library prebuild on two threads by default instead of half the CPUs

Sixteen builders on a 32-thread CPU spent about eight cores spinning on NVIDIA's driver lock and never finished the list
in a session; the ini text also said a quarter of the CPUs while the code took half.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HtayeqEG2x5woYzWuEQBGV
This commit is contained in:
Tyler
2026-11-08 17:22:29 -05:00
committed by chrg6
parent e5ce29aa97
commit 032f59bb44
2 changed files with 8 additions and 1 deletions

View File

@@ -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

View File

@@ -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();