gpu: fix STAGING pool cap leak and tighten idle snapshot/send pool caps on <=20GB RAM hosts
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
This commit is contained in:
1 parent
e4dbd89cd3
commit
604908e486
4 files changed
+17
-4
No files matched your search
@@ -122,7 +122,9 @@ static SPARE: Mutex<Vec<Memory>> = Mutex::new(Vec::new());
|
|||||||
/// On hosts with <= 32 GiB RAM, cap the idle upload pool at 256 MiB (instead
|
/// 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.
|
/// of 768 MiB) so streaming bursts have more commit headroom.
|
||||||
fn kept() -> u64 {
|
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
|
256 << 20
|
||||||
} else {
|
} else {
|
||||||
768 << 20
|
768 << 20
|
||||||
|
|||||||
@@ -52,12 +52,15 @@ pub(crate) fn room(memory: Option<[u64; 4]>) {
|
|||||||
pool.reclaim(tick, limit, true);
|
pool.reclaim(tick, limit, true);
|
||||||
}
|
}
|
||||||
if let Ok(mut pool) = STAGING.try_lock() {
|
if let Ok(mut pool) = STAGING.try_lock() {
|
||||||
|
let tight = crate::residency::tight_host_ram();
|
||||||
let staging_limit = if crate::residency::critical_commit() {
|
let staging_limit = if crate::residency::critical_commit() {
|
||||||
0
|
0
|
||||||
} else if pressure {
|
} else if pressure {
|
||||||
1
|
1
|
||||||
|
} else if tight {
|
||||||
|
2
|
||||||
} else {
|
} else {
|
||||||
limit
|
limit.min(STAGING_KEPT)
|
||||||
};
|
};
|
||||||
pool.reclaim(tick, staging_limit, true);
|
pool.reclaim(tick, staging_limit, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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))
|
*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<bool> = 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 {
|
fn next_pressure(was: bool, physical: u64, commit: u64) -> bool {
|
||||||
if was {
|
if was {
|
||||||
physical < 5 * GIB || commit < 6 * GIB
|
physical < 5 * GIB || commit < 6 * GIB
|
||||||
|
|||||||
@@ -1381,14 +1381,14 @@ fn snapshots_kept() -> usize {
|
|||||||
/// the largest, and of those the largest one and the next ones up to `KEPT`
|
/// the largest, and of those the largest one and the next ones up to `KEPT`
|
||||||
/// bytes in all.
|
/// bytes in all.
|
||||||
fn give_back(v: Vec<u8>) {
|
fn give_back(v: Vec<u8>) {
|
||||||
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());
|
let mut pool = POOL.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
pool.push(v);
|
pool.push(v);
|
||||||
pool.sort_by_key(|v| std::cmp::Reverse(v.capacity()));
|
pool.sort_by_key(|v| std::cmp::Reverse(v.capacity()));
|
||||||
let (mut kept, mut total) = (0, 0usize);
|
let (mut kept, mut total) = (0, 0usize);
|
||||||
for v in pool.iter().take(snapshots_kept()) {
|
for v in pool.iter().take(snapshots_kept()) {
|
||||||
total = total.saturating_add(v.capacity());
|
total = total.saturating_add(v.capacity());
|
||||||
if kept > 0 && total > KEPT {
|
if kept > 0 && total > cap {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
kept += 1;
|
kept += 1;
|
||||||
|
|||||||
Reference in new issue
Block a user