gpu: add 6GB VRAM mip dropping, 16GB RAM pool caps/OOM recovery, and clear_air +inf clamp
This commit is contained in:
1 parent
63b902fe17
commit
c9067a7d3f
8 files changed
+366
-51
No files matched your search
@@ -119,8 +119,14 @@ unsafe impl Send for Memory {}
|
||||
static SPARE: Mutex<Vec<Memory>> = Mutex::new(Vec::new());
|
||||
|
||||
/// At most this much is kept (of the card's memory, with [`on_card`]).
|
||||
/// 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() { 256 << 20 } else { 768 << 20 }
|
||||
if on_card() || crate::residency::limited_host_ram() {
|
||||
256 << 20
|
||||
} else {
|
||||
768 << 20
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the memory lies in the card's memory, written by the CPU through
|
||||
@@ -164,9 +170,35 @@ pub(super) fn give_back(memory: Memory) {
|
||||
let mut spare = SPARE.lock().unwrap_or_else(|e| e.into_inner());
|
||||
spare.push(memory);
|
||||
spare.sort_by_key(|m| std::cmp::Reverse(m.size));
|
||||
let mut freed = Vec::new();
|
||||
while spare.iter().map(|m| m.size).sum::<u64>() > kept() {
|
||||
spare.remove(0);
|
||||
freed.push(spare.remove(0));
|
||||
}
|
||||
drop(spare);
|
||||
drop(freed);
|
||||
}
|
||||
|
||||
/// Drops excess idle submission upload buffers during critical host commit
|
||||
/// pressure, keeping up to two small buffers (<= 32 MiB).
|
||||
pub(super) fn trim_spare() {
|
||||
let freed: Vec<Memory> = {
|
||||
let mut spare = SPARE.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if spare.is_empty() {
|
||||
return;
|
||||
}
|
||||
spare.sort_by_key(|m| m.size);
|
||||
let mut kept_bytes = 0u64;
|
||||
let mut keep = 0usize;
|
||||
for m in spare.iter().take(2) {
|
||||
if kept_bytes + m.size > 32 << 20 {
|
||||
break;
|
||||
}
|
||||
kept_bytes += m.size;
|
||||
keep += 1;
|
||||
}
|
||||
spare.split_off(keep)
|
||||
};
|
||||
drop(freed);
|
||||
}
|
||||
|
||||
/// Since the last frame-rate line: bytes copied, runs copied, words stored,
|
||||
|
||||
Reference in new issue
Block a user