Build the boot's first recorded pipeline alone before its builder threads start.

The boot's prewarm and the shared list's preparation started a builder on every core at once, so the driver began
that many graphics pipelines at the same moment, its first ones of the run among them. NVIDIA's 621.14 was reported to
fault in a sizable share of starts that way; a driver's first graphics pipeline sets up its compiler. warm_builder
now takes a one-job mode, and both callers build one queued pipeline on the starting thread before they start the
others.

Checked on an RTX GPU with --probe-prewarm in a copy of a dev folder (its prewarm skip marker removed), twice each with
the baseline and this build, alternating: no fault in four runs. With the 20 s budget the first pass built 2,203 of
3,226 recorded pipelines before and 2,135 after; the second pass built all 3,226 in both. A fault rate of a few
percent cannot be shown in four runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-11 17:42:21 -05:00
parent 4b23c4da09
commit 8c353cdf21

View File

@@ -4431,8 +4431,11 @@ static int id_cmp(const void *x, const void *y) { return memcmp(x, y, 32); }
// bookkeeping). Jobs left queued at K.until stay for the pool. So do those the memory gate refuses (gate_enter): a
// builder it refuses ends, which leaves fewer builders compiling side by side while the others' reservations stand,
// and none when the machine has no room; the pool builds what is left during play, when the gate lets it.
// arg non-NULL: one job at most. The builders start with one pipeline built alone on the starting thread:
// a driver's first graphics pipeline sets up its compiler, and NVIDIA's 621.14 was reported to fault in a sizable
// share of starts when every builder began its first pipeline at the same moment.
static void warm_builder(void *arg) {
(void)arg;
int one = arg != NULL;
plat_mutex_lock(&P.lock);
while (A.low && !(K.until && now_ms() >= K.until)) {
double held;
@@ -4470,6 +4473,7 @@ static void warm_builder(void *arg) {
plat_cond_broadcast(&done_cv);
free(j);
gate_leave(held);
if (one) break;
}
plat_mutex_unlock(&P.lock);
return;
@@ -4612,6 +4616,7 @@ static void prewarm_run(void) {
K.until = P.gpl && !(full && !strcmp(full, "1")) ? now_ms() + PREWARM_PIPE_MS : 0; // before the builders start
PlatThread *t[64];
int nt = 0;
if (queued) warm_builder((void *)1); // the first alone (warm_builder)
for (int i = 0; i < cpus && i < 64 && queued; i++)
if ((t[nt] = plat_thread_new(warm_builder, NULL, "pipe prewarm"))) nt++;
if (!nt) warm_builder(NULL);
@@ -6435,6 +6440,7 @@ static int seed_pipelines(const char *dir) {
free(ids), free(sh), free(r);
PlatThread *th[64];
int nt = 0;
if (queued) warm_builder((void *)1); // the first alone (warm_builder)
for (int i = 0; i < cpus && i < 64 && queued; i++)
if ((th[nt] = plat_thread_new(warm_builder, NULL, "pipe list"))) nt++;
if (!nt && queued) warm_builder(NULL);