Sweep: release trimmed spares off the submitting thread (once-a-second hitch) #3951
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3951
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3951"
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?
@Colej1921 on GitHub · 2026-11-30 12:47 UTC · original
Colej1921:fix/sweep-release-off-thread→main· +69 −7 · 2 files · 2 commits · closed without mergingWhat
Fixes a frame hitch that happened about once a second. Under memory pressure, the once-a-second sweep (
host.rssweep()) now releases the spares it trims on a background thread (victory-release). Before, it released them on the submitting thread.Why
The sweep runs on the submitting thread, before a submission starts. While the PC is under host memory pressure, which can happen even on a 32 GB PC (1–2 GB free while the title runs), the sweep trims three kinds of spare:
Releasing those D3D12 buffers took 22–45 ms every second:
trim_spare_chunks)send::trim)As a result, one frame came in late in nearly every second, even at a steady 30 fps. I found this with per-step timing of the sweep (not included in this PR).
No list names what a trim lets go of: a list holds what it records until it is reset. So only the release itself is left, and D3D12 objects are free-threaded. The release thread holds none of our locks.
Measured
Rig: Ryzen 7 7700X, RTX 4070 SUPER, 32 GB, Series S profile, DLSS frame generation 2x, 30 fps cap. Two 90-second walks with the game focused, on the same build, with only
VICTORY_RELEASE_APARTdifferent:VICTORY_RELEASE_APARTon (default)=0(as before)A standing-still pair at the same spot, uncapped: seconds whose longest frame was more than 40 ms above that second's median went from 21/60 to 1/60.
Notes
VICTORY_RELEASE_APART=0restores the old behaviour.trim_spare_uploads,trim_spare_chunksandsend::trim. Other drops are unchanged.cargo test -p victory-gpu --libgives 920 passed, 2 failed. Both failures predate this PR:shader_cache::tests::every_switch_of_the_translator_is_in_the_keyfails onmainwithout this change.card_steps::places_written_after_sending_are_learnedis flaky and passes when run alone.cargo clippy -p victory-gpu --all-targets -- -D warningsreports the same 4 errors asmain, none of them new.🤖 Generated with Claude Code
https://claude.ai/code/session_01TqPhfCMSaeRyntpNrQy31k
@tyr0nsur on GitHub · 2026-11-30 13:10 UTC · original
I checked the release queue at
202d3f13. The fix already keeps xmem/F7 scratch release synchronous. The sweep queue itself is still unbounded. A blocked driver release can leave old batches alive while the pools replenish, even though their counters no longer include those batches.The follow-up budgets logical bytes across queued and currently releasing batches. Each batch holds its charge through the last resource drop. Admission uses at most 256 MiB, or one eighth of sampled host headroom when lower. A batch that cannot fit, or one trimmed under critical commit pressure, releases on the caller. This can bring back the release hitch on an overloaded worker. It bounds deferred work and the existing immediate paths still release inline.
For a standalone RTX 4060 test I blocked a 32 MiB batch inside its destructor, queued a 16 MiB batch and tried another 16 MiB with a 48 MiB test cap. DXGI non-local usage went 92 → 76 MiB while the worker was still blocked and then 76 → 28 MiB after it ran again. The original unbounded enqueue also reproduced the pending overflow in an isolated blocked-destructor fixture. 17 diagnostics tests passed and the two queue tests passed on WARP. The test uses artificial delay and does not measure frame time.
Companion commit
@dyshay on GitHub · 2026-11-30 14:53 UTC · original
Merged for testing into our integration branch dyshay/VIctory-NVIDIA
janus-prs(adapted: release apart in the sweep andsend::trim;trim_spare_chunksstays synchronous). Builds and the targeted CPU tests pass; a run on an RTX 4090 (Series S, hardware RT) is queued and I'll post the result here.@trustno1-coder on GitHub · 2026-12-01 18:47 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed