perf(victory): evict LRU staging upload buffers across size classes and trim idle pool RAM #289
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!289
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-289"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@mauroalvare on GitHub · 2026-11-26 01:23 UTC · original
mauroalvare:perf/victory-stage-pool-lru→main· +424 −47 · 1 files · 1 commits · merged 2026-11-26 14:21 UTC## Change
In
third_party/victory/crates/victory-gpu/src/texture.rs,STAGE_POOL(VICTORY_STAGE_POOL_MB, 256 MiB by default) caches freed D3D12 texture staging upload buffers by power-of-two size class, but had three streaming/RAM issues:Staging::droponly cached a returned buffer whenpool.bytes + size <= most. Once an earlier streaming phase filled the pool cap with one size class (e.g., 4 MiB textures), subsequent streaming of another size class (e.g., 1 MiB textures) could never enter the pool — hitting 0% pool reuse and issuingCreateCommittedResource+Releasefor every single texture upload.texture::let_go_idle()dropped idleStagingentries under RAM pressure, whoseDroppushed their upload buffers directly intoSTAGE_POOL, where they remained pinned permanently without ever being trimmed.stage_buffer()zeroed the full power-of-two class capacitysize(up to 2×bytes) instead of the actualGetCopyableFootprintsextentbytes([0..bytes)), writing unnecessary zeros over write-combined upload memory past the last subresource footprint.This change:
StagePoolsize class to aVecDequewith monotonic return sequence numbers andmomenttimestamps, evicting the globally least-recently-used cached buffer(s) across all size classes when returning a buffer that fits within the cap (size <= most), and dropping evictedID3D12Resources outside the pool mutex.STAGE_POOLintexture::let_go_idle()using the sameram_idle_ms/IDLE_FRAMESthresholds asSTAGING.[0..bytes)on pool reuse (preventing stale texture data while avoiding redundant writes to the unused power-of-two tail[bytes..size)).stage_pool_most()untouched to avoid conflicts with PR #256.Verification
Base SHA:
c4c93bdc413191a9dc909998d2d53080a3f0c880GPU:
NVIDIA GeForce RTX 5070 Ti(15995 MiB VRAM, driver32.0.16.2140),--releasebuild, same machine and driver.Synthetic multi-phase streaming benchmark (
texture::stage_pool_tests::stage_pool_evicts_lru_across_size_classes_and_trims_idle: 32 MiB pool filled by 8 × 4 MiB Phase-1 buffers, then 200 sequential 600 KiB / 1 MiB-class Phase-2 uploads, plus 1.1 MiB reuse of a 2 MiB buffer with 512×512 RGBA8 GPU upload + readback verification, plus idle trim):c4c93bd)47b02cb)0 / 200(0%)199 / 200(99.5%)CreateCommittedResourceupload allocs2001(-99.5%)--release, RTX 5070 Ti)85.37 ms5.82–7.34 ms(~11.6–14.7× faster)[bytes..size)on 1.1 MiB in 2 MiB buffer946,176 Bextra WC writes)[0..bytes)still zeroed; 512×512 RGBA8 GPU readback matches)32 MiBpinned indefinitely0 MiB(28 MiBtrimmed first for stale Phase-1, then1 MiBPhase-2)Commands run from
third_party/victory(Rust1.98.1):Note: Python tests (
pytest/ruff) were not modified because this PR only touchesthird_party/victory.Oracle and test data
texture::stage_pool_tests::stage_pool_evicts_lru_across_size_classes_and_trims_idleon the local RTX 5070 Ti.c4c93bdwithVICTORY_STAGE_POOL_MB=32): fails withhits=0 made=200 elapsed_ms=85.37andtail_untouched=false.Checklist
E_NOTIMPL), never a fake success.Made with AI assistance (Antigravity / Gemini).