GPU: add opt-in idle shader cache trimming #1583
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1584"
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?
Imported from Marvisak/VIctory. Originally posted by srijann07 on 2026-11-24T19:28:25Z.
Motivation
Related to #471. The shader cache retains every unique shader container for the lifetime of the process, even after all pipelines using it have been released.
Changes
VICTORY_TRIM_IDLE_SHADERS=1.Verification
Limitations
Experimental and disabled by default. Not a hard memory cap or VRAM optimization. Cache sweeps run under a mutex and only on new entries. Evicted shaders may require additional translation. Synthetic payload savings are not measured process RAM savings. No in-game measurements or game assets used.
AI-assisted development.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:31:31Z.
Automated triage for the maintainers.
Merge candidate. Adds an opt-in
VICTORY_TRIM_IDLE_SHADERS=1that turns theSHADERSmap incrates/victory-gpu/src/pipeline.rsinto aShaderCachewhich, every 256 new containers, drops entries whoseArcis held only by the cache. I checked that every other holder of anArc<Shader>(pipelines,pipeline/make.rspending jobs,pipeline/host.rs) keeps its own strong reference, so live shaders keep their identity and their translation; an evicted container is simply rebuilt (and retranslated or read from the disk cache) on next use. The default path is unchanged and the three tests exercise the cache directly. Note that no memory saving in the title has been measured yet; the README section says so.Thanks for the rebase: it now merges cleanly with
main(940d32f), so this is a full review of the new head.CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by srijann07 on 2026-11-25T06:09:16Z.
Rebased onto upstream main (
940d32f). All conflicts have been resolved, and fresh Windows CI, both Clippy configurations and tests passed.CI: https://github.com/srijann07/VIctory/actions/runs/45557268421
Ready for review. Thanks!
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:03:00Z.
Code review (concurrency/refcount audit) and RTX 5090 + WARP verification at head
1ba845ee1287merged cleanly ontomain(63bcca43c6a0):crates/victory-gpu/src/pipeline.rs:953-964):VICTORY_TRIM_IDLE_SHADERS == "1"cached inOnceLock<bool>), completely silent by default.trim_idle()(Arc::strong_count(shader) > 1): becauseShaderCacheis exclusively guarded bySHADERS: Mutex<Option<ShaderCache>>and new clones can only originate from a lookup holdingSHADERSor from an existing externalArc, observingstrong_count == 1under the lock guarantees no live external reference exists, preventing premature eviction with no nested lock acquisition. Amortized every 256 cache misses withshrink_to_fit()only on large shrink.VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:191 files ok;cargo clippy --locked -p victory-gpu --tests -- -D warnings(default +--features diagnostics): 0 warningsshader_cache pipeline::: 30/30 passed default on RTX 5090; 33/33 passed (--features diagnostics) on both RTX 5090 and WARP (including all 3 new idle-trim tests).LGTM.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.