atagen

monolith

public
Star0
Watch0

Commit 7e34874b2bd1

tarball

atagen <boss@atagen.co>2026-10-19 06:54 UTC

1 file changed+6-11
render-vk: stop rebuilding the staging pool every frame

trim_staging runs from every reap, so draining the pool into two fresh Vecs allocated on every frame and dispatch even when nothing expired.
Modified file: crates/render-vk/src/image.rs+6 additions−11 deletions
@@ -213,17 +213,12 @@ const POOL_IDLE: Duration = Duration::from_secs(2);
213213 /// Frees pooled staging buffers that have sat unused for [`POOL_IDLE`].
214214 pub(crate) fn trim_staging(shared: &Shared) {
215215 let now = Instant::now();
216- let expired: Vec<Pooled> = {
217- let mut pool = shared
218- .staging_pool
219- .lock()
220- .unwrap_or_else(|e| e.into_inner());
221- let (stale, kept) = std::mem::take(&mut *pool)
222- .into_iter()
223- .partition(|p| now - p.returned >= POOL_IDLE);
224- *pool = kept;
225- stale
226- };
216+ let expired: Vec<Pooled> = shared
217+ .staging_pool
218+ .lock()
219+ .unwrap_or_else(|e| e.into_inner())
220+ .extract_if(.., |p| now - p.returned >= POOL_IDLE)
221+ .collect();
227222 if expired.is_empty() {
228223 return;
229224 }