From fdd2c4aff37fef76780ac58616fe271ef6ce8532 Mon Sep 17 00:00:00 2001 From: shawn Date: Fri, 27 Nov 2026 12:40:36 -0500 Subject: [PATCH 1/3] Sweeps behind flights every 15 s while memory is not pressed (VICTORY_SWEEP_EVERY_MS) Each sweep made behind flights settles everything in the air first; those frames took 36-82 ms instead of ~31 on an RTX 5070 Ti, at every 1.5 s: the 0.7 frames a second over 50 ms that made the prison stutter. With no sweeps the cell had none (p99 60 -> 39 ms, worst 99 -> 48 ms). They stay at 1.5 s while the PC's memory is pressed (residency thresholds) or the card's use is over 97% of its budget. Co-Authored-By: Claude Opus 5.5 --- crates/victory-gpu/src/host.rs | 36 +++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index 7fa2fe72a..273617a43 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -5757,7 +5757,7 @@ impl Host { } sweep(); SWEPT.store(now_ms(), Ordering::Relaxed); - } else if late_free_present() && now_ms() > SWEPT.load(Ordering::Relaxed) + 1500 { + } else if late_free_present() && now_ms() > SWEPT.load(Ordering::Relaxed) + self.sweep_every_ms() { // With the present sent ahead nothing else brings a moment // with nothing in the air: one is made for the sweep. self.settle(&mut submitted, WHY_SYNC); @@ -10213,6 +10213,40 @@ impl Host { /// bytes: the budget and the use of the card's own memory, then of the /// PC's memory shared with the card (where the system moves what does /// not fit on the card). + /// How long between sweeps made behind flights ([`late_free_present`]). + /// Each settles everything in the air first, and that frame took 36 to + /// 82 ms instead of ~31 on an RTX 5070 Ti: at every 1.5 s, the 0.7 + /// frames a second over 50 ms that made the prison stutter; without + /// sweeps, none. So while memory is not pressed they come every + /// `VICTORY_SWEEP_EVERY_MS` (15,000 by default; 1,500 as before), and + /// every 1.5 s while it is: the PC's memory under the residency + /// thresholds ([`crate::residency::pressured`]) or the card's use over + /// 97% of its budget (the texture pool fills it to about nine tenths by + /// design: 10.2 of 11.0 GB in the cell). Looked at twice a second. + fn sweep_every_ms(&self) -> u64 { + const PRESSED_MS: u64 = 1500; + static EVERY: OnceLock = OnceLock::new(); + let every = *EVERY.get_or_init(|| { + std::env::var("VICTORY_SWEEP_EVERY_MS").ok().and_then(|v| v.trim().parse().ok()).unwrap_or(15_000) + }); + if every <= PRESSED_MS { + return every; + } + static LOOKED: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); + static PRESSED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(true); + let now = now_ms(); + if now >= LOOKED.load(Ordering::Relaxed) + 500 { + LOOKED.store(now, Ordering::Relaxed); + crate::residency::refresh(); + let card = self.video_memory().is_none_or(|[budget, used, ..]| used > budget / 100 * 97); + let pressed = crate::residency::pressured() || card; + if PRESSED.swap(pressed, Ordering::Relaxed) != pressed { + tracing::info!(pressed, every_ms = if pressed { PRESSED_MS } else { every }, "sweeps behind flights"); + } + } + if PRESSED.load(Ordering::Relaxed) { PRESSED_MS } else { every } + } + pub(crate) fn video_memory(&self) -> Option<[u64; 4]> { let adapter = self.adapter.as_ref()?; let mut own = DXGI_QUERY_VIDEO_MEMORY_INFO::default(); From dbefb1f3978e78f371d6a6819ee2e2b46259cba3 Mon Sep 17 00:00:00 2001 From: shawn Date: Fri, 27 Nov 2026 14:38:08 -0500 Subject: [PATCH 2/3] Sweeps: the card counts as pressed at the texture room line, not at 97% of its budget Textures are held back for room from that line on, and it is the sweep that lets idle ones go; between the line and 97% the sweep would have come every 15 s only. Co-Authored-By: Claude Opus 5.5 --- crates/victory-gpu/src/host.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index 273617a43..df3909fc9 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -10220,9 +10220,12 @@ impl Host { /// sweeps, none. So while memory is not pressed they come every /// `VICTORY_SWEEP_EVERY_MS` (15,000 by default; 1,500 as before), and /// every 1.5 s while it is: the PC's memory under the residency - /// thresholds ([`crate::residency::pressured`]) or the card's use over - /// 97% of its budget (the texture pool fills it to about nine tenths by - /// design: 10.2 of 11.0 GB in the cell). Looked at twice a second. + /// thresholds ([`crate::residency::pressured`]) or the card's use (less + /// the texture pool's free part) at the line textures are made up to + /// ([`crate::resource::room_line`]): textures are held back for room + /// then, and the sweep is what lets idle ones go (at 97% of the budget + /// instead, ~150,000 slots were held back a 5 s line for a minute of the + /// cutscene). Looked at twice a second. fn sweep_every_ms(&self) -> u64 { const PRESSED_MS: u64 = 1500; static EVERY: OnceLock = OnceLock::new(); @@ -10238,7 +10241,11 @@ impl Host { if now >= LOOKED.load(Ordering::Relaxed) + 500 { LOOKED.store(now, Ordering::Relaxed); crate::residency::refresh(); - let card = self.video_memory().is_none_or(|[budget, used, ..]| used > budget / 100 * 97); + // The card past the line textures are made up to: textures are + // held back for room, and it is the sweep that lets idle ones go. + let card = self + .video_memory() + .is_none_or(|[budget, used, ..]| used.saturating_sub(crate::pool::texture_room()) >= crate::resource::room_line(budget)); let pressed = crate::residency::pressured() || card; if PRESSED.swap(pressed, Ordering::Relaxed) != pressed { tracing::info!(pressed, every_ms = if pressed { PRESSED_MS } else { every }, "sweeps behind flights"); From d8dd7d8114243b6bfb1c776d76eda25c7c0d1db4 Mon Sep 17 00:00:00 2001 From: shawn Date: Sat, 28 Nov 2026 08:13:12 -0500 Subject: [PATCH 3/3] Sweeps: the card counts as pressed when the texture pass finds no room (VICTORY_SWEEP_PRESS_BY_ROOM) The pressed test compared the card's use with the texture line but left out what the pass keeps for render targets and buffer copies, so it said "not pressed" for seconds at a time while every pass held new textures back: in a cutscene thousands of slots a second were held, served up to 32 s after their write, with sweeps every 15 s meanwhile. Now it asks resource::room, as the pass does. VICTORY_SWEEP_PRESS_BY_ROOM=0: by the use alone, as before. Co-Authored-By: Claude Opus 5.5 --- crates/victory-gpu/src/host.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index df3909fc9..bb6976e62 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -10243,9 +10243,23 @@ impl Host { crate::residency::refresh(); // The card past the line textures are made up to: textures are // held back for room, and it is the sweep that lets idle ones go. - let card = self - .video_memory() - .is_none_or(|[budget, used, ..]| used.saturating_sub(crate::pool::texture_room()) >= crate::resource::room_line(budget)); + // Asked as the texture pass asks it (`crate::resource::room`, + // with what is kept for render targets and buffer copies): by + // the card's use alone it said "not pressed" for seconds at a + // time while every pass held new textures back (a cutscene: + // thousands of slots a second held, served up to 32 s after + // their write, sweeps every 15 s meanwhile). + // `VICTORY_SWEEP_PRESS_BY_ROOM=0`: by the use alone, as before. + static BY_ROOM: OnceLock = OnceLock::new(); + let by_room = *BY_ROOM.get_or_init(|| std::env::var_os("VICTORY_SWEEP_PRESS_BY_ROOM").is_none_or(|v| v != "0")); + let memory = self.video_memory(); + let card = if by_room { + !crate::resource::room(memory) + } else { + memory.is_none_or(|[budget, used, ..]| { + used.saturating_sub(crate::pool::texture_room()) >= crate::resource::room_line(budget) + }) + }; let pressed = crate::residency::pressured() || card; if PRESSED.swap(pressed, Ordering::Relaxed) != pressed { tracing::info!(pressed, every_ms = if pressed { PRESSED_MS } else { every }, "sweeps behind flights");