GPU: retire regenerable memory under pressure #3848
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3848"
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 kotekompotek on 2026-11-29T15:45:07Z.
Summary
Leak mechanisms addressed
Before this change:
Arcs in a static map and were never freed;Validation
cargo check -p victory-gpu— pass (MSVC 1.98.1).cargo check -p victory-gpu --features diagnostics— pass.cargo clippy -p victory-gpu --all-targets --locked -- -D warnings— pass.cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings— pass.cargo test -p victory-gpu --lib— 226 passed, 5 failed, 1 ignored. A clean upstream-main baseline run on the same machine produced exactly the same 226/5/1 result. The five pre-existing environment-dependent failures aredynamic_slots_are_held_until_released,a_texture_written_in_one_format_reads_in_another_through_a_placed_view,compute_view_marks_rebind_after_depth_twin_conversion,lists_share_a_table_and_copies_keep_their_views, anddepth_bounds_control_a_title_drawon the GTX 1050 test system. The updated eviction unit test passes.Stress-boot evidence from the investigation build of these changes:
frame=8192 draws=65536 drawn=8192was reached and presentation continued through the end of the window;That boot exercised the texture-eviction and loose-LRU paths heavily. It did not report title-memory remap callbacks, so the new remap-invalidation paths are included by design and compile/clippy validated but were not separately runtime-proven by this particular log.
Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-29T16:40:26Z.
Tested on a Radeon 780M (RDNA3 iGPU, shared system memory, Ryzen 7 8845HS), merged onto main
63bcca4,cargo test --profile diag -p victory-gpu --features diagnostics --lib, run twice. main passes all 246 both times; with this PR, three existing tests fail, a different set each run:bindless::tests::heap_views_are_currentbindless::tests::heap_views_follow_writes_through_another_mapping,shadow::tests::partial_refresh_under_marked_range_updates_saved_bytes#3831 and #3832 on the same machine and base pass every test both runs, so this looks specific to this change. Since the failures move between runs, my guess is the new eviction: on an iGPU the system commit pressure check may trip during the test run and retire loose shadow copies (or poison placed resources) that a test still reads. A dGPU with its own VRAM might never hit it. Happy to rerun with a log or a patch.
AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by AurumCarlos on 2026-11-29T20:54:22Z.
Review: COMMENTED
Three points, the first two concrete:
1. The
descriptor.rshunk is #3512's change.sync_heapsnow clampslastathost.count(), which is what #3512 (neonbyte1, open) does in the same lines. #3512 also clampsfirstand stopssync_slotsearly, and it has measurements. The two will conflict. Suggested: drop that hunk here and leave it to #3512.2. Eviction now depends on the whole machine's commit charge, during tests too.
evict_unusedruns at everyHost::execute(host.rs:1168), tests included. With this PR it also evicts whenK32GetPerformanceInfo'sCommitTotal(every process on the system) is above 85 % ofCommitLimit(resource.rs:1599,COMMIT_HIGH). So whether a test's textures are given up mid-test depends on what else the machine is doing. That fits kilolimaVI's report: three different tests failing in two runs on the same machine, whilemainpasses all 246 both times. I haven't reproduced those failures, so take this as the likeliest lead rather than a proven cause.Suggested fix: keep the pressure sources out of unit tests, so tests that want eviction call
evict(frame, now, over)with theoverthey mean:The same applies to
local(the card's budget), which on an iGPU is shared memory too.3. Splitting would make the failures bisectable. This PR has five independent changes: texture evictability, commit pressure, the loose-copy lifecycle, remap invalidation of placed textures, and the heap-sync clamp. With all five in one commit, the flaky failures can't be traced to one of them. The loose-copy lifecycle also overlaps #3078 and #3457, which retire loose windows and shadow copies too. One PR per change, starting with the eviction rules, would let each be tested and measured on its own.
Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-30T23:12:31Z.
I reproduced both bindless failures reported above on
856f65355761be639acf46004fdbf90ad135bc8eon an RTX 4090 Laptop GPU and Microsoft WARP. I varied the inputs to the production eviction decision while running each existing test in its own process. The high values below are injected inputs, not observations from the Radeon 780M.heap_views_are_currentandheap_views_follow_writes_through_another_mapping, both adapters combinedBefore the failing dispatch, slot 2 held the shader texture and its title texel was 64. Eviction selected that texture (65,536 bytes), wrote a null view to the same slot, and no remake occurred before dispatch. All 64 output words were
1000+iinstead of1064+i. Keeping just this texture alive restored all three rounds while the pressure calculation still requested the same reclamation.The separate shadow partial-refresh test passed 24/24 in isolation and never polled eviction pressure. If the 780M failure recurs, the most useful details would be which test failed, the first mismatched word/byte, system commit and adjusted local usage at that submission, and whether it also fails when run alone.
A candidate for the two bindless failures is now open against your branch, commit
3397c6f356654ee89f043ac7418fb13357d2e48b. Both adapters passed the same 24 high-pressure runs with actual eviction and no pin. The targeted matrix passed 84/84, including the 48 live/low/boundary bindless runs and 12 placed-resource controls. The fix repairs evicted descriptor generations in heaps referenced by the submitted lists. In a separate two-slot control, a previously materialized but unsampled texture on the same heap was rebuilt and uploaded on the first pressured submission. It had no additional upload on the second. Active-heap memory savings have not been quantified.I also reran the stock partial-refresh shadow test in 30 new test processes on the original SHA, including four full-library runs (serial and default scheduling on both adapters). The named test passed in all 30. Direct byte readback in the earlier instrumented probe was
aa 66 00 11 bb 77. If it recurs on 780M, could you share the exact assertion line and actual bytes, plus whether the same test fails with--test-threads=1or in isolation? That would let us distinguish partial copy length from incorrect saved bytes.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.