resource: check unmapped_only instead of host_idle.is_some() in let_go_idle #3272

Merged
Maverick0351a merged 1 commit from upstream-pr/3272 into main 2026-11-30 16:28:30 +00:00
Maverick0351a commented 2026-11-29 21:12:50 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Maverick0351a on 2026-11-29T21:12:50Z.


Problem

\idle_sweep_policy(host_idle, card_rule)\ returns \unmapped_only = false\ whenever the card itself is pressured (\card_most != u64::MAX || card_idle < 60_000), even when \host_idle.is_some()\ is also true (which is permanently true on a 32 GB RAM PC once < 8 GiB\ of physical RAM is free), so that mapped idle textures continue to be evicted from VRAM to keep the card under budget.

However, inside \let_go_idle()\ (\crates/victory-gpu/src/resource.rs:3119\ and \3131), the inner loop checked \if host_idle.is_some()\ instead of \if unmapped_only. As a result, whenever both \host_idle.is_some()\ and \card_pressured\ were true:

  1. \let_go_idle()\ entered the full \most != u64::MAX\ VRAM sweep, sorting all \60,000+\ idle textures into \y_age.
  2. For every texture in \y_age, it entered \if host_idle.is_some()\ at line 3131, called \crate::texture::wholly_unmapped\ (\VirtualQuery), saw the texture was still mapped, and executed \continue\ without evicting the texture or resetting
    .host.used.store(0, Relaxed).
  3. Every sweep therefore walked and called \VirtualQuery\ across all \60,000+\ mapped idle textures from scratch, freeing 0 bytes of mapped textures and taking 41.97–44.27 ms per sweep (up to 166.8 ms) on the submitting thread after ~11 minutes of gameplay on a 32 GB RAM / 16 GB RTX 5080 system.

Fix

Check \if unmapped_only\ instead of \if host_idle.is_some()\ at lines 3119 and 3131 of \crates/victory-gpu/src/resource.rs, matching line 3103 and line 3176 and honoring \idle_sweep_policy's returned \unmapped_only\ decision.

Verification

Verified across a 26-minute continuous gameplay run on an RTX 5080 Laptop GPU (16 GB VRAM, 32 GB RAM):

  • Before fix: \555 looks for textures to let go, 44.27 ms each, the longest 166.8, \84 MB of texture blocks free, VRAM climbed past the room line (\ first host texture was admitted just over the room line so_far=4000).
  • After fix: \414 looks for textures to let go, 7.29 ms each, the longest 18.1, \2283 MB of texture blocks free, \
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5555176248 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3272). Originally posted by [Maverick0351a](https://github.com/Maverick0351a) on 2026-11-29T21:12:50Z. --- ## Problem \idle_sweep_policy(host_idle, card_rule)\ returns \unmapped_only = false\ whenever the card itself is pressured (\card_most != u64::MAX || card_idle < 60_000\), even when \host_idle.is_some()\ is also true (which is permanently true on a 32 GB RAM PC once \< 8 GiB\ of physical RAM is free), so that mapped idle textures continue to be evicted from VRAM to keep the card under budget. However, inside \let_go_idle()\ (\crates/victory-gpu/src/resource.rs:3119\ and \3131\), the inner loop checked \if host_idle.is_some()\ instead of \if unmapped_only\. As a result, whenever both \host_idle.is_some()\ and \card_pressured\ were true: 1. \let_go_idle()\ entered the full \most != u64::MAX\ VRAM sweep, sorting all \60,000+\ idle textures into \y_age\. 2. For every texture in \y_age\, it entered \if host_idle.is_some()\ at line 3131, called \crate::texture::wholly_unmapped\ (\VirtualQuery\), saw the texture was still mapped, and executed \continue\ without evicting the texture or resetting \ .host.used.store(0, Relaxed)\. 3. Every sweep therefore walked and called \VirtualQuery\ across all \60,000+\ mapped idle textures from scratch, freeing 0 bytes of mapped textures and taking **41.97–44.27 ms per sweep (up to 166.8 ms)** on the submitting thread after ~11 minutes of gameplay on a 32 GB RAM / 16 GB RTX 5080 system. ## Fix Check \if unmapped_only\ instead of \if host_idle.is_some()\ at lines 3119 and 3131 of \crates/victory-gpu/src/resource.rs\, matching line 3103 and line 3176 and honoring \idle_sweep_policy\'s returned \unmapped_only\ decision. ## Verification Verified across a 26-minute continuous gameplay run on an RTX 5080 Laptop GPU (16 GB VRAM, 32 GB RAM): - Before fix: \555 looks for textures to let go, 44.27 ms each, the longest 166.8\, \84 MB of texture blocks free\, VRAM climbed past the room line (\ first host texture was admitted just over the room line so_far=4000\). - After fix: \414 looks for textures to let go, 7.29 ms each, the longest 18.1\, \2283 MB of texture blocks free\, \
barasalah2 commented 2026-11-30 00:55:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by barasalah2 on 2026-11-30T00:55:56Z.


Confirming this on an RTX 3060 Ti 8 GB (i7-12700, 32 GB, Windows 11, driver 621.40, Series S, frame generation off).

Without this PR, a 45-minute session went from 5.3 GB of card memory at the start to 8.8 GB of a 7.0 GB budget. Host texture copies grew from 2.8 to 5.6 GB, and fps fell from 13 to 5. Then the whole PC froze. Log attached.

The log shows slot eviction "Evicting: yes" all session, but 0 textures let go. PC memory free stayed under 8 GiB, so host_idle was Some throughout. With the card over its line, idle_sweep_policy returned unmapped_only = false, but line 3131 still checked host_idle.is_some() and skipped every mapped idle copy. This PR's change is the right fix.

This PR builds on 41adb551. cargo test -p victory-gpu gives 921 passed, 1 failed (every_switch_of_the_translator_is_in_the_key, which fails on main too and is unrelated).

The log analysis and code review were done with Claude (Claude Code); I ran the session. I'll post an after-run with this PR.Report from an affected 8 GB card. This line is what let the card's memory climb until my PC froze, and this pull request fixes the condition.

victory-nvidia-play-20261129-235149-15000.zip

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7265698696 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3272#issuecomment-7265698696). Originally posted by [barasalah2](https://github.com/barasalah2) on 2026-11-30T00:55:56Z. --- Confirming this on an RTX 3060 Ti 8 GB (i7-12700, 32 GB, Windows 11, driver 621.40, Series S, frame generation off). Without this PR, a 45-minute session went from 5.3 GB of card memory at the start to 8.8 GB of a 7.0 GB budget. Host texture copies grew from 2.8 to 5.6 GB, and fps fell from 13 to 5. Then the whole PC froze. Log attached. The log shows slot eviction "Evicting: yes" all session, but 0 textures let go. PC memory free stayed under 8 GiB, so `host_idle` was `Some` throughout. With the card over its line, `idle_sweep_policy` returned `unmapped_only = false`, but line 3131 still checked `host_idle.is_some()` and skipped every mapped idle copy. This PR's change is the right fix. This PR builds on 41adb551. `cargo test -p victory-gpu` gives 921 passed, 1 failed (`every_switch_of_the_translator_is_in_the_key`, which fails on main too and is unrelated). The log analysis and code review were done with Claude (Claude Code); I ran the session. I'll post an after-run with this PR.Report from an affected 8 GB card. This line is what let the card's memory climb until my PC froze, and this pull request fixes the condition. [victory-nvidia-play-20261129-235149-15000.zip](https://github.com/user-attachments/files/35587571/victory-nvidia-play-20261129-235149-15000.zip)
andrewpozdnakov7-jpg commented 2026-11-30 12:59:46 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-11-30T12:59:46Z.


I reproduced the mapped-idle case on WARP 1.0.22 against release main 41adb551. The only injected inputs were the host and card pressure rules. The fixture used two 64x64 RGBA8 textures backed by committed CPU memory, let them age four frames and over 1.5 seconds, and held an extra host reference to one. It then ran the normal let_go_idle() path.

Pressure rules Mapped idle copies retired on 41adb551 Mapped idle copies retired with a0f5fc3
Host only, card has room 0 0
Card only 1 1
Host and card 0 1

The held copy survived all cases. After a retirement, the next access created a new host copy and the synthetic CPU backing bytes were intact. The existing resource unit tests passed 44/44 with one ignored on each revision. This measures eviction and recreation on WARP with uncontended locks. The long-session FPS and VRAM figures come from the field reports.

For integration, #2591 contains these same two predicate changes and additional tile work. #3681 also changes the inner detach predicate and adds its own reload protection. Please carry the predicate fix once when landing the overlapping sweep work. This PR is the two-line version. GitHub shows only the label check for this head, so maintainer review and the normal Windows CI run remain pending.

Release follow-up

Both predicates are already present in v2026.11.30.01 (c71899d) through merged #2591. On that release, the same WARP 1.0.22 fixture retires 0 mapped copies with host pressure alone, 1 with card pressure alone, and 1 with both. The held copy survives and the synthetic CPU bytes are intact after recreation. The resource suite ran 61 tests successfully with 2 ignored. The only additional local change was the #4018 unit-test build fix.

Thanks @Lyrnc for the RTX 5080 sweep timings. The current release passes the two-predicate check. The sweep time on the current release and the FPS effect of the stacked changes remain field measurements.

Another matched field pair with the same room settings on an RTX 5070 Ti showed 5.65 GB versus 3.2 GB of texture copies at minute 30 after changing the inner sweep condition. The patched run was under budget in all 175 samples from minute 16. This was one pair on an older locally stacked tree. Our current-release fixture above verifies both conditions. RTX 5070 Ti measurements

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7279209033 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3272#issuecomment-7279209033). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-30T12:59:46Z. --- I reproduced the mapped-idle case on WARP 1.0.22 against release main `41adb551`. The only injected inputs were the host and card pressure rules. The fixture used two 64x64 RGBA8 textures backed by committed CPU memory, let them age four frames and over 1.5 seconds, and held an extra host reference to one. It then ran the normal `let_go_idle()` path. | Pressure rules | Mapped idle copies retired on `41adb551` | Mapped idle copies retired with `a0f5fc3` | | --- | ---: | ---: | | Host only, card has room | 0 | 0 | | Card only | 1 | 1 | | Host and card | 0 | 1 | The held copy survived all cases. After a retirement, the next access created a new host copy and the synthetic CPU backing bytes were intact. The existing resource unit tests passed 44/44 with one ignored on each revision. This measures eviction and recreation on WARP with uncontended locks. The long-session FPS and VRAM figures come from the field reports. For integration, [#2591](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2591) contains these same two predicate changes and additional tile work. [#3681](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3681) also changes the inner detach predicate and adds its own reload protection. Please carry the predicate fix once when landing the overlapping sweep work. This PR is the two-line version. GitHub shows only the label check for this head, so maintainer review and the normal Windows CI run remain pending. **Release follow-up** Both predicates are already present in `v2026.11.30.01` (`c71899d`) through merged [#2591](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2591). On that release, the same WARP 1.0.22 fixture retires 0 mapped copies with host pressure alone, 1 with card pressure alone, and 1 with both. The held copy survives and the synthetic CPU bytes are intact after recreation. The resource suite ran 61 tests successfully with 2 ignored. The only additional local change was the [#4018](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4018) unit-test build fix. Thanks @Lyrnc for the RTX 5080 sweep timings. The current release passes the two-predicate check. The sweep time on the current release and the FPS effect of the stacked changes remain field measurements. Another matched field pair with the same room settings on an RTX 5070 Ti showed 5.65 GB versus 3.2 GB of texture copies at minute 30 after changing the inner sweep condition. The patched run was under budget in all 175 samples from minute 16. This was one pair on an older locally stacked tree. Our current-release fixture above verifies both conditions. [RTX 5070 Ti measurements](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3272#issuecomment-7283231190)
Lyrnc commented 2026-11-30 13:59:37 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Lyrnc on 2026-11-30T13:59:37Z.


Tested on an RTX 5080 + 9800X3D with 32 GB, Series X native 1440p, DLSS off, a scripted walk route, 300 s windows. On a 32 GB PC free RAM is always under 8 GiB while the game runs, so let_go_idle took the host_idle.is_some() path: it walked every idle-looking texture each second and let none go.

  • Sweep step "looks for textures to let go": 22–36 ms each in every build without this commit (main 41adb551, palmlight's 29.11 sync, with or without VICTORY_SLOT_EVICT=0). With this commit: ~4 ms each (longest 16).
  • Stacked with a fix for the send-spare churn (#3381 / our perf/send-trim-floor) and #80-style sweep spreading in our team fork: 24.0 fps and 10.6 frames over 100 ms per 1,000, against 21.7 / 42.5 without them. Two runs.
  • Unit tests resource:: pass (44) with it on our fork's main. No picture regressions in walk and camera-spin captures.

We've carried it unchanged in our team fork, with your authorship.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7280671250 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3272#issuecomment-7280671250). Originally posted by [Lyrnc](https://github.com/Lyrnc) on 2026-11-30T13:59:37Z. --- Tested on an RTX 5080 + 9800X3D with **32 GB**, Series X native 1440p, DLSS off, a scripted walk route, 300 s windows. On a 32 GB PC free RAM is always under 8 GiB while the game runs, so `let_go_idle` took the `host_idle.is_some()` path: it walked every idle-looking texture each second and let none go. - Sweep step "looks for textures to let go": **22–36 ms each** in every build without this commit (main 41adb551, palmlight's 29.11 sync, with or without `VICTORY_SLOT_EVICT=0`). With this commit: **~4 ms each** (longest 16). - Stacked with a fix for the send-spare churn (#3381 / our `perf/send-trim-floor`) and #80-style sweep spreading in our team fork: 24.0 fps and 10.6 frames over 100 ms per 1,000, against 21.7 / 42.5 without them. Two runs. - Unit tests `resource::` pass (44) with it on our fork's main. No picture regressions in walk and camera-spin captures. We've carried it unchanged in our team fork, with your authorship. AI use: Claude Code (Claude Opus 5.5).
voidharbor commented 2026-11-30 15:34:57 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by voidharbor on 2026-11-30T15:34:57Z.


Numbers for the same gate from a 16 GB card with 64 GB of RAM, where the PC's line is 16 GiB free instead of 8.

Setup. Ryzen 7 9800X3D, RTX 5070 Ti 16 GB, 64 GB RAM, Windows 11. Series X at 2560x1440, DLSS Balanced, frame generation 2x, ray tracing on. Tree: main 41adb551 with a number of open pull requests merged locally, not this one. One scripted route, 31 minutes a run: 10 minutes of walking and camera turns, then standing, from the same save. VICTORY_SLOT_EVICT=1 in all three runs. The third run had the same gate change as this pull request, behind a switch of my own (VICTORY_CARD_SWEEP_FIRST=1: the gate reads unmapped_only, the try_lock line unchanged).

run of 31 minutes texture copies card in use against a budget of about 14.9 GB frame rate at 6,000 to 8,000 draws end
the launcher's default texture room 4.8 GB at minute 4, 6.5 GB at minute 28 over from minute 5, 16.5 GB at the end 20 device lost at 26 minutes
VICTORY_TEXTURE_ROOM_PERCENT=88, VICTORY_CARD_ROOM_FOR_TARGETS_MB=3072 3.3 GB at minute 8, 5.65 GB at minute 30 over from minute 16, 15.3 to 15.8 GB at the end 20 closed normally
the same plus the gate change 2.9 to 3.5 GB throughout (3.2 GB at minute 30) under by 0.5 to 0.85 GB throughout; over in 0 of 175 samples from minute 16 23 closed normally

Without it, the PC fell under 16 GiB free at minute 10 of the second run (minute 2 of the first), and idle copies that no list and no slot held went from 12 at minute 8 to 35,750 at minute 31; slot eviction let go of 0 textures, since no slot shows them. With it, by the end: 247,162 copies let go (25,574 MB), 92,066 made again, 4,035 of them within 2 s (4.4 %), away 156.8 s on average. At 6,000 to 8,000 draws the submitting thread took 35.6 ms a frame against 46.8 ms, the card 41.4 ms against 45.4.

One card, one route, one run per row, on a local tree rather than plain main. The cost to watch is copies made again soon after they go. The counting code (made again, within 2 s, time away) is on a branch if that line is wanted here.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7283231190 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3272#issuecomment-7283231190). Originally posted by [voidharbor](https://github.com/voidharbor) on 2026-11-30T15:34:57Z. --- Numbers for the same gate from a 16 GB card with 64 GB of RAM, where the PC's line is 16 GiB free instead of 8. **Setup.** Ryzen 7 9800X3D, RTX 5070 Ti 16 GB, 64 GB RAM, Windows 11. Series X at 2560x1440, DLSS Balanced, frame generation 2x, ray tracing on. Tree: main 41adb551 with a number of open pull requests merged locally, not this one. One scripted route, 31 minutes a run: 10 minutes of walking and camera turns, then standing, from the same save. `VICTORY_SLOT_EVICT=1` in all three runs. The third run had the same gate change as this pull request, behind a switch of my own (`VICTORY_CARD_SWEEP_FIRST=1`: the gate reads `unmapped_only`, the `try_lock` line unchanged). | run of 31 minutes | texture copies | card in use against a budget of about 14.9 GB | frame rate at 6,000 to 8,000 draws | end | |---|---|---|---|---| | the launcher's default texture room | 4.8 GB at minute 4, 6.5 GB at minute 28 | over from minute 5, 16.5 GB at the end | 20 | device lost at 26 minutes | | `VICTORY_TEXTURE_ROOM_PERCENT=88`, `VICTORY_CARD_ROOM_FOR_TARGETS_MB=3072` | 3.3 GB at minute 8, 5.65 GB at minute 30 | over from minute 16, 15.3 to 15.8 GB at the end | 20 | closed normally | | the same plus the gate change | 2.9 to 3.5 GB throughout (3.2 GB at minute 30) | under by 0.5 to 0.85 GB throughout; over in 0 of 175 samples from minute 16 | 23 | closed normally | Without it, the PC fell under 16 GiB free at minute 10 of the second run (minute 2 of the first), and idle copies that no list and no slot held went from 12 at minute 8 to 35,750 at minute 31; slot eviction let go of 0 textures, since no slot shows them. With it, by the end: 247,162 copies let go (25,574 MB), 92,066 made again, 4,035 of them within 2 s (4.4 %), away 156.8 s on average. At 6,000 to 8,000 draws the submitting thread took 35.6 ms a frame against 46.8 ms, the card 41.4 ms against 45.4. One card, one route, one run per row, on a local tree rather than plain main. The cost to watch is copies made again soon after they go. The counting code (made again, within 2 s, time away) is on a branch if that line is wanted here.
KruIN689 commented 2026-11-30 21:13:57 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by KruIN689 on 2026-11-30T21:13:57Z.


Part of a set measured on an RTX 5080 16 GB with HW RT, roaming, 3 rounds in one session: upstream main 21.0 fps / 275 frames over 50 ms per 1,000, against 26.7 / 63 with this PR's unmapped_only check plus a spread sweep, #3063/#3067, #4233 and SUBMIT_SPLIT. Not split per change; the table and the set are in #3858's latest comment. On this 47 GB PC memory pressure rarely holds, so this PR's own part is likely small here; Lyrnc measured it on a 32 GB PC: the texture look went from 22-36 ms to ~4 ms each. (Claude Code, for KruIN689.)

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7292103816 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3272#issuecomment-7292103816). Originally posted by [KruIN689](https://github.com/KruIN689) on 2026-11-30T21:13:57Z. --- Part of a set measured on an RTX 5080 16 GB with HW RT, roaming, 3 rounds in one session: upstream main 21.0 fps / 275 frames over 50 ms per 1,000, against 26.7 / 63 with this PR's unmapped_only check plus a spread sweep, #3063/#3067, #4233 and SUBMIT_SPLIT. Not split per change; the table and the set are in #3858's latest comment. On this 47 GB PC memory pressure rarely holds, so this PR's own part is likely small here; Lyrnc measured it on a 32 GB PC: the texture look went from 22-36 ms to ~4 ms each. (Claude Code, for KruIN689.)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!3272
No description provided.