From ab4971fda7cc5fccbe7c2b446db1087ed51627ad Mon Sep 17 00:00:00 2001 From: adanaport <361659188+adanaport@users.noreply.github.com> Date: Fri, 27 Nov 2026 07:36:00 +0000 Subject: [PATCH 1/5] VICTORY_LAND_NOT: host copies only shaders use stay on the card; play.ps1 lists four of this title's (22.7 -> 25.4 fps) The timeline (n-tl-w1) put landing on the frame's chain: the card's copy queue ~5 ms and the landing threads ~9 ms a frame, while the title waits for what the card wrote. Of the ~63 MB fetched a frame, 21 MB came from the upscaler chain's 0x1412200-byte buffer and 14 MB from three buffers shaders fill (0x2d00000, 0x5265c0, 0x1cc000), none of them sent up after the load. A copy of a listed length is not fetched, except in the 64 KiB pieces the title sent bytes up into within the last 300 frames: the title writes all of each at the load, and the 45 MB one gets a piece or two now and then. Keyed by length: the addresses differ between runs. In-run A/B (n-ab-land, the pieces left out by a temporary switch): 45.3 ms a frame with everything fetched, 42.2 without the chain's buffer, 42.6 without the other three, 39.7 without all four, the same draws a frame, the pictures alike. With the switch (n-ln2): 25.4 fps against 22.7 (n-ln1, where all pieces had kept landing since the load), merging what was fetched 13.2 -> 6.2 ms, copying back 24 -> 16 ms a frame. Six landing threads instead of three were slower (n-ln6, 22.0 fps). Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 692cebe6e72a3de0eca8061e64926ca270a914b2) --- crates/victory-gpu/src/host.rs | 4 +++ crates/victory-gpu/src/land.rs | 63 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index d1088cc6..b78291d8 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -4330,6 +4330,7 @@ impl Host { let bytes: u64 = ranges.iter().map(|&(a, b)| (b - a) as u64).sum(); crate::shadow::CARD_STATS[0].fetch_add(bytes, Ordering::Relaxed); crate::shadow::CARD_STATS[1].fetch_add(ranges.len() as u64, Ordering::Relaxed); + crate::land::title_sent(shadow.span(), ranges); #[cfg(feature = "diagnostics")] traffic::moved(traffic::UP, shadow.span(), ranges.iter().copied()); if own.is_none() && before.is_some() && !ranges.is_empty() { @@ -4641,6 +4642,9 @@ impl Host { continue; } let (lo, hi) = r.shadow.card_piece(&r.span, p); + if land::left_on_card(r.shadow.span(), lo) { + continue; + } if lo < hi && !seen.contains(&(copy, lo, hi)) { let key = (r.shadow.id(), r.shadow.span().0 as usize + lo, hi - lo); if fetch.as_ref().is_some_and(|f| f.had.holds(behind, key)) { diff --git a/crates/victory-gpu/src/land.rs b/crates/victory-gpu/src/land.rs index 2bde5853..428171b2 100644 --- a/crates/victory-gpu/src/land.rs +++ b/crates/victory-gpu/src/land.rs @@ -69,6 +69,69 @@ pub(crate) fn skip_on() -> bool { *ON.get_or_init(|| std::env::var_os("VICTORY_LAND_SKIP").is_some_and(|v| v == "1")) } +/// Copies left on the card (`VICTORY_LAND_NOT=`, hex, comma +/// separated; unset: none): what shaders write in a host copy of one of these +/// lengths is not fetched into title memory, except in the 64 KiB pieces the +/// title has sent bytes up into within the last [`SENT_FRAMES`] frames +/// ([`title_sent`]), which land as before. For memory only shaders use, +/// which the title's code neither reads nor writes after it set it up (the +/// title writes all of each at the load): the card's side is the one that +/// counts, and the title's lists find it there. In this title the upscaler +/// chain's 0x1412200 bytes (21 MB fetched a frame) and three buffers shaders +/// fill (0x2d00000, 0x5265c0, 0x1cc000: 14 MB a frame; the first of them +/// has a piece or two sent up now and then, which keep landing): n-ab-land, +/// -3.0 and -2.6 ms a frame, -5.6 together, the same draws a frame. +pub(crate) fn left_on_card(span: (u64, u64), offset: usize) -> bool { + listed(span.1) + && sent() + .lock() + .unwrap_or_else(|e| e.into_inner()) + .get(&(span.0, (offset >> 16) as u32)) + .is_none_or(|&at| crate::frame::current().saturating_sub(at) > SENT_FRAMES) +} + +/// How long a piece of [`left_on_card`]'s copies the title sent up keeps +/// landing: about ten seconds. +const SENT_FRAMES: u64 = 300; + +/// Offsets `ranges` of the copy of `span` were sent up: their pieces land +/// for a while ([`left_on_card`]). +pub(crate) fn title_sent(span: (u64, u64), ranges: &[(usize, usize)]) { + if !listed(span.1) { + return; + } + let now = crate::frame::current(); + let mut sent = sent().lock().unwrap_or_else(|e| e.into_inner()); + for &(from, to) in ranges.iter().filter(|r| r.0 < r.1) { + for p in (from >> 16) as u32..=((to - 1) >> 16) as u32 { + sent.insert((span.0, p), now); + } + } +} + +fn listed(len: u64) -> bool { + static LIST: OnceLock> = OnceLock::new(); + let list = LIST.get_or_init(|| { + let list: Vec = std::env::var("VICTORY_LAND_NOT") + .unwrap_or_default() + .split(',') + .filter_map(|v| u64::from_str_radix(v.trim().trim_start_matches("0x"), 16).ok()) + .collect(); + if !list.is_empty() { + tracing::info!(?list, "host copies of these lengths stay on the card, but for pieces the title sends up (VICTORY_LAND_NOT)"); + } + list + }); + !list.is_empty() && list.contains(&len) +} + +/// Of [`left_on_card`]'s copies, the pieces the title sent up: (title +/// address, piece) → the frame it last did. +fn sent() -> &'static Mutex> { + static SENT: OnceLock>> = OnceLock::new(); + SENT.get_or_init(Default::default) +} + /// Since the last frame-rate line; microseconds first. pub(crate) mod stat { /// Which pieces to fetch; their list recorded and sent. From 23ab672011df0224603d552ff1d36cd6b6bf2532 Mon Sep 17 00:00:00 2001 From: adanaport <361659188+adanaport@users.noreply.github.com> Date: Fri, 27 Nov 2026 07:36:00 +0000 Subject: [PATCH 2/5] play.ps1: three more host copies only shaders read stay on the card (26.1 fps) 0x3200000 (the title and the shaders write pieces of it apart), 0xc00000 and 0x2a3000: 11 MB a frame fetched for nothing. In-run A/B (n-ab-landc, a temporary switch for the three): 39.0 -> 37.5 ms a frame, the same draws a frame, the pictures alike. With all seven listed (n-ln3): 26.1 fps, 17.7 MB fetched a frame (was ~63). Copies both write pieces of (the 174 MB ring, 0x1900000, 0x564000) are left as they are. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 26d310d9fe0c5482cae2f4e943133aee6df0999a) --- crates/victory-gpu/src/land.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/victory-gpu/src/land.rs b/crates/victory-gpu/src/land.rs index 428171b2..fa03f545 100644 --- a/crates/victory-gpu/src/land.rs +++ b/crates/victory-gpu/src/land.rs @@ -80,7 +80,10 @@ pub(crate) fn skip_on() -> bool { /// chain's 0x1412200 bytes (21 MB fetched a frame) and three buffers shaders /// fill (0x2d00000, 0x5265c0, 0x1cc000: 14 MB a frame; the first of them /// has a piece or two sent up now and then, which keep landing): n-ab-land, -/// -3.0 and -2.6 ms a frame, -5.6 together, the same draws a frame. +/// -3.0 and -2.6 ms a frame, -5.6 together, the same draws a frame. Then +/// 0x3200000 (the title and the shaders write pieces apart), 0xc00000 and +/// 0x2a3000, 11 MB a frame: n-ab-landc, 39.0 -> 37.5 ms. Copies both write +/// pieces of (the 174 MB ring, 0x1900000, 0x564000) are left as they are. pub(crate) fn left_on_card(span: (u64, u64), offset: usize) -> bool { listed(span.1) && sent() From 9251411beb01996ae1bc5187aa106a14762bad52 Mon Sep 17 00:00:00 2001 From: adanaport <361659188+adanaport@users.noreply.github.com> Date: Fri, 27 Nov 2026 07:36:01 +0000 Subject: [PATCH 3/5] VICTORY_LAND_NOT: the log names each copy a listed length catches A length is no name: in a walk through the cell (n-walk1) 0xc00000 caught four copies, 0x1cc000 and 0x2a3000 two each. The pictures of that walk match one with the list switched off (n-walk0), no device lost; fps in the cell 30.0 (the title's own cap) against 24-27.5 without the list. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 50a0b550cc2cf6c54912229d4c3689071085c85b) --- crates/victory-gpu/src/land.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/victory-gpu/src/land.rs b/crates/victory-gpu/src/land.rs index fa03f545..edd15f7e 100644 --- a/crates/victory-gpu/src/land.rs +++ b/crates/victory-gpu/src/land.rs @@ -86,6 +86,7 @@ pub(crate) fn skip_on() -> bool { /// pieces of (the 174 MB ring, 0x1900000, 0x564000) are left as they are. pub(crate) fn left_on_card(span: (u64, u64), offset: usize) -> bool { listed(span.1) + && caught(span) && sent() .lock() .unwrap_or_else(|e| e.into_inner()) @@ -97,6 +98,23 @@ pub(crate) fn left_on_card(span: (u64, u64), offset: usize) -> bool { /// landing: about ten seconds. const SENT_FRAMES: u64 = 300; +/// Says in the log each copy a listed length catches, the first time: a +/// length is no name, and another buffer of the same size would be left on +/// the card too. Always true. +fn caught(span: (u64, u64)) -> bool { + static SEEN: OnceLock>> = OnceLock::new(); + let mut seen = SEEN.get_or_init(Default::default).lock().unwrap_or_else(|e| e.into_inner()); + if seen.insert(span) { + let of_length = seen.iter().filter(|s| s.1 == span.1).count(); + tracing::info!( + "a host copy of a listed length stays on the card (VICTORY_LAND_NOT): {:#x}+{:#x}, {of_length} of that length so far", + span.0, + span.1 + ); + } + true +} + /// Offsets `ranges` of the copy of `span` were sent up: their pieces land /// for a while ([`left_on_card`]). pub(crate) fn title_sent(span: (u64, u64), ranges: &[(usize, usize)]) { From a1bcfb342d9bb0a9c5c3740697a5541948803f93 Mon Sep 17 00:00:00 2001 From: adanaport <361659188+adanaport@users.noreply.github.com> Date: Fri, 27 Nov 2026 07:36:00 +0000 Subject: [PATCH 4/5] The threads that translate lists run below normal priority (VICTORY_LIST_LOW=0: normal) With landing off the chain, the timeline (n-tl-w2) has the title's own code, the submitting thread and ~3 ms a frame of "woken, not running yet" on it; translation moves the frame weakly (the busy-work test). In-run A/B (n-ab-prio, 250 s): 37.2 -> 36.3 ms a frame, every phase lower. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit e47bfa03f42ebeaf3c8279a7c05e0dc194580dbc) --- crates/victory-gpu/src/list/thin.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/victory-gpu/src/list/thin.rs b/crates/victory-gpu/src/list/thin.rs index fe9277dd..6b2d51b9 100644 --- a/crates/victory-gpu/src/list/thin.rs +++ b/crates/victory-gpu/src/list/thin.rs @@ -305,6 +305,15 @@ fn start() { let worker = move || { crate::cores::keep_many_on_fast_cores("victory-list"); crate::queue::no_drain_here(); + // Below the title's threads and the submitting one, which the + // frame waits for more than for a list's translation + // (`VICTORY_LIST_LOW=0`: normal): n-ab-prio, 37.2 -> 36.3 ms a + // frame, the chain's "woken, not running yet" being ~3 ms. + if std::env::var_os("VICTORY_LIST_LOW").is_none_or(|v| v != "0") { + use windows_sys::Win32::System::Threading::{GetCurrentThread, SetThreadPriority, THREAD_PRIORITY_BELOW_NORMAL}; + // SAFETY: this thread's own priority. + unsafe { SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL) }; + } loop { let recording = { let mut ready = held(&READY); From 564966b7759c4a8010651d40fbb4f70b3c3a96f1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 10:12:23 +0000 Subject: [PATCH 5/5] VICTORY_LIST_LOW off by default (=1 lowers THIN translator threads) Change written by DeepSeek; cherry-picked e47bfa0 had it on by default. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FLuVRjyhfFuq98XrffwyiL --- crates/victory-gpu/src/list/thin.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/victory-gpu/src/list/thin.rs b/crates/victory-gpu/src/list/thin.rs index 6b2d51b9..32042900 100644 --- a/crates/victory-gpu/src/list/thin.rs +++ b/crates/victory-gpu/src/list/thin.rs @@ -307,9 +307,9 @@ fn start() { crate::queue::no_drain_here(); // Below the title's threads and the submitting one, which the // frame waits for more than for a list's translation - // (`VICTORY_LIST_LOW=0`: normal): n-ab-prio, 37.2 -> 36.3 ms a + // (`VICTORY_LIST_LOW=1`; off by default): n-ab-prio, 37.2 -> 36.3 ms a // frame, the chain's "woken, not running yet" being ~3 ms. - if std::env::var_os("VICTORY_LIST_LOW").is_none_or(|v| v != "0") { + if std::env::var_os("VICTORY_LIST_LOW").is_some_and(|v| v == "1") { use windows_sys::Win32::System::Threading::{GetCurrentThread, SetThreadPriority, THREAD_PRIORITY_BELOW_NORMAL}; // SAFETY: this thread's own priority. unsafe { SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL) };