Pipelines known to take long are made beside the others, by a quarter of the workers (VICTORY_PIPELINE_SLOW=0: in the order created)

Run shaders-1, the first with a changed translator (fresh shader and
pipeline caches): 3,020 pipelines started at creation, all 16 workers in
programs of seconds to tens of seconds each while the title loaded (97 made in 20 s),
then the quick ones at 100-190 a second, too late: 0.5-1.6 s a frame and up
to 2,900 draws a frame dropped from 60 to 150 s. A pipeline that took a
second is now noted (slow-pipelines.txt; `victory warm` notes them too) and
waits in a list of its own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-25 14:35:11 -06:00
1 parent 2f22f6e2c2
commit bd7be01b3b
3 files changed
+147 -17

No files matched your search

@@ -633,7 +633,9 @@ pub(crate) fn save(now: bool) {
)
});
}
let slow: Vec<String> = slow_ones().iter().flatten().map(|(key, ms)| format!("{key} {ms}")).collect();
let written = library_written
.and_then(|()| write_atomically(&dir.join(SLOW_FILE), slow.join("\n").as_bytes()))
.and_then(|()| write_atomically(&dir.join(EARLY_FILE), used.join("\n").as_bytes()));
match written {
Ok(()) => tracing::info!(
@@ -696,6 +698,48 @@ fn write_atomically(path: &std::path::Path, bytes: &[u8]) -> std::io::Result<()>
res
}
/// How long each title pipeline that took long to make took, in ms (beside
/// the early list; a key may be there more than once).
const SLOW_FILE: &str = "slow-pipelines.txt";
/// A pipeline that takes this long is one ([`slow`]).
pub(crate) const SLOW_MS: u64 = 1000;
static SLOW: Mutex<Option<std::collections::HashMap<String, u64>>> = Mutex::new(None);
fn slow_ones() -> std::sync::MutexGuard<'static, Option<std::collections::HashMap<String, u64>>> {
let mut slow = SLOW.lock().unwrap_or_else(|e| e.into_inner());
if slow.is_none() {
let listed = DIR.get().and_then(|d| std::fs::read_to_string(d.join(SLOW_FILE)).ok()).unwrap_or_default();
*slow = Some(
listed
.lines()
.filter_map(|l| l.split_once(' '))
.filter_map(|(key, ms)| Some((key.to_owned(), ms.parse().ok()?)))
.collect(),
);
}
slow
}
/// Whether making the title pipeline with `key` took [`SLOW_MS`] in this or
/// an earlier run.
pub(crate) fn slow(key: &str) -> bool {
slow_ones().as_ref().is_some_and(|s| s.contains_key(key))
}
/// The title pipeline with `key` took `ms` to make.
pub(crate) fn note_time(key: &str, ms: u64) {
if ms < SLOW_MS {
return;
}
let mut slow = slow_ones();
let known = slow.get_or_insert_default().entry(key.to_owned()).or_insert(0);
if ms > *known {
*known = ms;
// With the next save of the early list.
USED_CHANGED.store(true, Ordering::Relaxed);
}
}
/// Title pipeline keys requested by draws or dispatches (this run and the last).
static USED: Mutex<Option<HashSet<String>>> = Mutex::new(None);
static USED_CHANGED: AtomicBool = AtomicBool::new(false);