Variant race: a 150 ms pause between timed windows so the job loop gets the card (the mutex is not fair; a queued job waited the whole race, 36 s, in the first serve check)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
igneum-labs 2026-10-04 19:18:04 +00:00
parent fe3a3ab701
commit 123ee1a2ee
2 changed files with 6 additions and 1 deletions

View file

@ -687,6 +687,9 @@ static void racePair(Ctx& c, Pair* p, const PfPack& pk, const std::string& bound
if (i > 0 && round == 0 && wallMs() > deadline) { e.ok = false; e.note = "not timed: the race budget ran out"; continue; } if (i > 0 && round == 0 && wallMs() > deadline) { e.ok = false; e.note = "not timed: the race budget ran out"; continue; }
if (pinnedOnly && i == 0) continue; if (pinnedOnly && i == 0) continue;
if (!raceTime(c, p, pk, e, dOut, batch, pinnedOnly ? 0 : benchMs, s, round == 0)) e.ok = false; if (!raceTime(c, p, pk, e, dOut, batch, pinnedOnly ? 0 : benchMs, s, round == 0)) e.ok = false;
// the mutex is not fair: give the job loop the card between windows (measured on the Mac, 4 October
// 2026: without this a queued job waited the whole race, 36 s)
std::this_thread::sleep_for(std::chrono::milliseconds(150));
} }
} }
if (dOut) c.drv.memFree(dOut); if (dOut) c.drv.memFree(dOut);

View file

@ -2899,7 +2899,9 @@ func raceProgram(_ gpu: GPU, _ program: ServeProgram, dataset: MTLBuffer, datase
if pinnedOnly && i == 0 { continue } if pinnedOnly && i == 0 { continue }
if round == 0 && i > 0 && nowNs() > deadline { entries[i].note = "not timed: the race budget ran out"; continue } if round == 0 && i > 0 && nowNs() > deadline { entries[i].note = "not timed: the race budget ran out"; continue }
gpuLock.lock() gpuLock.lock()
defer { gpuLock.unlock() } // NSLock is not fair: after the window the job loop gets the card (measured 4 October 2026: without the
// pause a queued job waited the whole race, 36 s)
defer { gpuLock.unlock(); Thread.sleep(forTimeInterval: 0.15) }
if round == 0 && i > 0 { if round == 0 && i > 0 {
if !run(k, base: 0x1000_0000, count: checkN, into: outBuf) { entries[i].note = "did not run"; continue } if !run(k, base: 0x1000_0000, count: checkN, into: outBuf) { entries[i].note = "did not run"; continue }
var bad = -1 var bad = -1