GPU: add opt-in idle shader cache trimming #1584
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1584
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@srijann07 on GitHub · 2026-11-24 19:28 UTC · original
srijann07:memory/trim-idle-shaders→main· +123 −7 · 2 files · 2 commits · openMotivation
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.
@Marvisak on GitHub · 2026-11-25 01:31 UTC · original · edited 2026-11-25 06:21 UTC
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
@srijann07 on GitHub · 2026-11-25 06:09 UTC · original
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!
@fuzeofficlal on GitHub · 2026-11-26 01:03 UTC · original
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.