Sweep: release trimmed spares off the submitting thread (once-a-second hitch) #3951
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Colej1921 on 2026-11-30T12:47:20Z.
What
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
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T13:10:33Z.
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
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-30T14:53:45Z.
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.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:47:37Z.
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