perf(gpu): offload bury() COM drops off relay thread and batch dynamic slot releases #1358
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1358"
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 qlfu on 2026-11-28T17:57:42Z.
Summary
Reduces relay-thread landing stalls and descriptor-heap lock contention by:
bury()COM object drops to a dedicatedvictory-buryworker thread (crates/victory-gpu/src/host.rs):relay_land()callsbury(last)right before clearingline.settlingand notifyingLINE_MOVED/LINE_LANDED, synchronously dropping ~20,000 retiredID3D12ResourceCOM references and freed D3D12 objects per frame (~3.75–8.75 ms/frame on the relay thread).bury()now drains the ready prefix fromRETIREDand hands theVecto a lazily spawnedvictory-burythread with bounded backpressure (MAX_PENDING_BATCHES = 64; falls back to inline drop if full or if thread spawn fails).crates/victory-gpu/src/descriptor.rs,crates/victory-gpu/src/descriptor/host.rs,crates/victory-gpu/src/draw.rs):release_dynamic()calls (~12,500 calls/frame fromState::tables_done()andDrop for State) withrelease_dynamic_many()+HostHeap::release_many().SHADER_HEAPS.read()once per command list and groups consecutive ranges sharing(heap, id)under a singleHostHeap::nextlock, updatingfreeandtoo_longonce per batch.Verification
cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- --test-threads=1 --quiet: 456 passed, 0 failed, 36 ignored (including new testshost::bury_tests::bury_drops_retired_objects_asynchronouslyanddescriptor::host::tests::dynamic_release_many_frees_disjoint_ranges_and_ignores_wrong_id).cargo +1.98.1-x86_64-pc-windows-msvc clippy -p victory-gpu --lib --tests --locked(default and--all-features): 0 warnings in modified files.cargo +1.98.1-x86_64-pc-windows-msvc build --release --locked -p victory: exit0.Clean Idle-PC A/B Benchmark (Ryzen 7 5700X + RTX 4070 Ti 12 GB, 1440p Series X, DLSS Quality,
-FrameGen, 90s steady gameplay)main(9ce3cf9,BASE_9ce3cf9_fg_clean)PR7_bury_fg_clean)the rest(bury) median / mean / max3.75 / 4.10 / 8.75 ms0.73 / 0.72 / 1.10 msread-backs and listsmedian / mean3.04 / 3.04 ms2.46 / 2.66 mslanding in allmedian / mean24.75 / 23.70 ms19.90 / 18.67 msVICTORY_THINtranslation median257.5 ms242.4 ms18.6/71.0%18.8/76%0 / 00 / 0Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-29T10:14:27Z.
Rebased onto current \main\ (\
829188e9): dropped theelease_dynamic_batch\ hunks that already landed upstream, leaving a focused 1-file change (+72 lines in \host.rs) that offloads \ury()\ COM drops off the relay landing thread (preserving inline timing when \VICTORY_RELAY_TIMING=1). Verified in a clean 90s gameplay run on \
829188e9: \land_rest\ dropped from 6.19 ms/frame to 1.48 ms/frame (-4.71 ms/frame on the relay thread), \ury_drops_retired_objects_asynchronously\ passes.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by elsi06 on 2026-11-29T18:49:52Z.
We tested the same
bury()change independently in the Belobug fork, using one binary with a runtime toggle (Ryzen 7 5800X, RTX 4070 SUPER, 32 GiB RAM, FSR 3.1.5 Performance at 1080p, frame generation off). Our release worker allows one batch pending and one in progress, with inline fallback when full. These measurements apply to that implementation.Across two walking segments, eight readback waits of at least 2 ms began with the render fence already signaled in the inline run (226.98 ms total). With the worker there was one such wait (12.28 ms). In one inline case, releasing an older submission overlapped 83.44 ms of an 87.25 ms wait for a 384-byte upload. With the worker, eight native Presents completed during a single 411.06 ms release. The queue was full for about 2.7% of batches.
The second walk had comparable draw counts (3,003 vs 2,967 per frame). Moving releases to the worker reduced frames ≥100 ms from 6 to 1 and native P99 from 70.61 to 67.13 ms. Mean FPS fell from 24.50 to 23.87. Peak sampled working set across the walks rose by 355 MiB and private bytes by 647 MiB. The first walk differed substantially in draw count, so we excluded it from the frame-rate comparison.
The clearest gain on this machine was allowing Presents and readbacks to continue during long releases. Tracking waits that start with the fence already signaled, alongside queue-full fallbacks and peak memory, may help evaluate the queue bound on this PR.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by upipibi on 2026-11-29T23:31:45Z.
Test note for #1358 (head
1b4b50c9), merged onto main41adb551, on RTX 30. Synthetic tests only: no title run, no game files.Setup: RTX 3070 8 GB, driver 621.40, Windows 11 (10.0.26100), rustc 1.98.1.
The new test passes, and it also passes with the change taken out.
host::bury_tests::bury_drops_retired_objects_asynchronouslyis a CPU-only test (it makes no device). As a negative control I changed one line ofburyso that a batch is never handed to thevictory-burythread (if false && timing.is_none() && let Some(pool) = bury_pool()), which leaves the old inline drop:bury_drops_retired_objects_asynchronouslyThe test waits until the object's
Drophas run, and an inline drop satisfies that at once. So it shows thatburystill drops what is retired, but not that the drop left the calling thread. If theDropin the test recorded the name of the thread it ran on, the test could assert it isvictory-buryand would then fail on the inline path.cargo test -p victory-gpu --lib --lockedon the card, PR tree, two runs: 922 passed, 1 failed, 60 ignored both times. The one failure isshader_cache::tests::every_switch_of_the_translator_is_in_the_key(VICTORY_SCALAR_SPLITS is not read by the translator any more), which fails the same way on main41adb551without this PR.Not tested: the frame-time effect, which needs a title run.
Tested with the help of Claude Code (Claude Fable 5.2).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-11-30T07:58:28Z.
We ran a test of this PR on current main (
41adb551with this PR merged), on a CPU-bound machine.We compare only the seconds where the idle camera shows the same lighter views (about 7,500 draws a frame). Its heavier view (about 15,000 draws, half the frame rate) takes 10 to 60 s of each 150 s run, and it moved whole-run means by several ms.
No difference we can measure. The five main runs of the session agreed within 1.3 ms on these seconds. But we also ran main again, built in another folder, eight times: it ranged from 57.5 to 65.5 ms. Its first four runs were 2.4 ms slower than main on average, and the last four 4.2 ms faster. All nine PRs we tested in this session came out 0.4 to 3.9 ms slower than main, and fps moved with it. So we read the difference as a newly built executable, not as this PR.
The relay thread was landing 32.5 and 35.6 ms a frame, against 30.9 to 38.0 on main. That is the lowest of the PRs we tested, but inside main's own spread.
Picture: 0 defects in 160 frames.
Setup:
41adb551(only its own commits on top), against41adb551itself;Picture check: a burst of 10 captures a second at the end of each run (80 frames), looked at frame by frame.
AI Assisted
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by remijn on 2026-11-30T12:38:41Z.
Tested on an RTX 3080 / Ryzen 9 7900X3D (32 GB), Series S profile, DLSS Quality, FSR 3 frame generation, ray tracing off, the same save every run, diagnostics build. The PR's commit was cherry-picked onto a tree based on
41adb551. For an A/B in one binary I added a local switch that makesbury_pool()returnNone, which drops inline as before. Three pairs, 30 s each, run order alternated:victory-burythread (this PR)The relay thread's landing time ("was … ms landing in all" in the relay line) went down by about 4.5 ms a frame in every pair. fps rose in two of the three pairs and was unchanged in the third, about +4.7 % on average, and p99 improved in every pair. No problems seen in these runs.
Merges cleanly here. A switch for the inline path would make A/B tests like this easier for others.