gpu: fix STAGING pool cap leak and tighten idle snapshot/send pool caps on <=20GB RAM hosts
CI / check (push) Canceled after 0s

This commit is contained in:
theme613 committed 2026-11-28 20:28:10 +08:00
1 parent e4dbd89cd3
commit 604908e486
4 files changed
+17 -4

No files matched your search

+2 -2
View File
@@ -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<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());
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;