diff --git a/crates/victory-gpu/src/host/send.rs b/crates/victory-gpu/src/host/send.rs index aa2ee1c..9355caa 100644 --- a/crates/victory-gpu/src/host/send.rs +++ b/crates/victory-gpu/src/host/send.rs @@ -122,7 +122,9 @@ static SPARE: Mutex> = Mutex::new(Vec::new()); /// On hosts with <= 32 GiB RAM, cap the idle upload pool at 256 MiB (instead /// of 768 MiB) so streaming bursts have more commit headroom. fn kept() -> u64 { - if on_card() || crate::residency::limited_host_ram() { + if crate::residency::tight_host_ram() { + 128 << 20 + } else if on_card() || crate::residency::limited_host_ram() { 256 << 20 } else { 768 << 20 diff --git a/crates/victory-gpu/src/pool.rs b/crates/victory-gpu/src/pool.rs index f94df04..8bd19c7 100644 --- a/crates/victory-gpu/src/pool.rs +++ b/crates/victory-gpu/src/pool.rs @@ -52,12 +52,15 @@ pub(crate) fn room(memory: Option<[u64; 4]>) { pool.reclaim(tick, limit, true); } if let Ok(mut pool) = STAGING.try_lock() { + let tight = crate::residency::tight_host_ram(); let staging_limit = if crate::residency::critical_commit() { 0 } else if pressure { 1 + } else if tight { + 2 } else { - limit + limit.min(STAGING_KEPT) }; pool.reclaim(tick, staging_limit, true); } diff --git a/crates/victory-gpu/src/residency.rs b/crates/victory-gpu/src/residency.rs index 0e701e5..cb7b3bf 100644 --- a/crates/victory-gpu/src/residency.rs +++ b/crates/victory-gpu/src/residency.rs @@ -95,6 +95,14 @@ pub(crate) fn limited_host_ram() -> bool { *LIMITED.get_or_init(|| memory_status().is_some_and(|s| s.ullTotalPhys <= 32 * GIB)) } +/// True on hosts with <= 20 GiB physical RAM (e.g. 16 GB laptops), where idle +/// pools (staging blocks, snapshot buffers, upload scratch, command allocators) +/// should stay lean to leave physical RAM free for Windows and avoid paging. +pub(crate) fn tight_host_ram() -> bool { + static TIGHT: OnceLock = OnceLock::new(); + *TIGHT.get_or_init(|| memory_status().is_some_and(|s| s.ullTotalPhys <= 20 * GIB)) +} + fn next_pressure(was: bool, physical: u64, commit: u64) -> bool { if was { physical < 5 * GIB || commit < 6 * GIB diff --git a/crates/victory-gpu/src/shadow.rs b/crates/victory-gpu/src/shadow.rs index 7763dd0..5684d16 100644 --- a/crates/victory-gpu/src/shadow.rs +++ b/crates/victory-gpu/src/shadow.rs @@ -1381,14 +1381,14 @@ fn snapshots_kept() -> usize { /// the largest, and of those the largest one and the next ones up to `KEPT` /// bytes in all. fn give_back(v: Vec) { - const KEPT: usize = 512 << 20; + let cap: usize = if crate::residency::tight_host_ram() { 128 << 20 } else { 512 << 20 }; let mut pool = POOL.lock().unwrap_or_else(|e| e.into_inner()); pool.push(v); pool.sort_by_key(|v| std::cmp::Reverse(v.capacity())); let (mut kept, mut total) = (0, 0usize); for v in pool.iter().take(snapshots_kept()) { total = total.saturating_add(v.capacity()); - if kept > 0 && total > KEPT { + if kept > 0 && total > cap { break; } kept += 1;