Reclaim idle upload memory under host pressure #386

Open
github-bot wants to merge 1 commit from github-bot/gh-386 into a-publier AGit
Owner

@⁠CauaHenriqueM on GitHub · 2026-11-26 23:25 UTC · original
CauaHenriqueM:fix/trim-idle-uploads → a-publier · +50 −51 · 3 files · 1 commits · open

Motivation

The default texture upload pool can hold empty staging blocks until another upload requests an allocation. Under host memory pressure, these blocks and unused command-list scratch can keep committed RAM after their work has finished.

Changes

  • Use the existing physical RAM and available commit thresholds during the submission sweep. The recovery thresholds prevent the policy from toggling when memory is near the pressure threshold.
  • Release spare upload scratch and sweep idle texture staging blocks periodically. Under pressure the sweep keeps at most one empty 64 MiB staging block. A block can be released once all pieces are free after the existing retirement interval.
  • Use VICTORY_RESIDENCY to control the optional speculative texture limits.

Validation

  • Clippy passed on Windows with all targets, all features, and warnings denied.
  • In the standard test profile, 445 GPU tests passed and 34 were ignored by the test suite.
  • The asset policy check passed for 271 tracked files.
  • The synthetic pool regression exercises releasing seven empty staging blocks (448 MiB) while preserving live and resting pieces.
  • In-game memory usage remains to be measured.
**@⁠CauaHenriqueM** on GitHub · 2026-11-26 23:25 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/386) `CauaHenriqueM:fix/trim-idle-uploads` → `a-publier` · +50 −51 · 3 files · 1 commits · open ## Motivation The default texture upload pool can hold empty staging blocks until another upload requests an allocation. Under host memory pressure, these blocks and unused command-list scratch can keep committed RAM after their work has finished. ## Changes - Use the existing physical RAM and available commit thresholds during the submission sweep. The recovery thresholds prevent the policy from toggling when memory is near the pressure threshold. - Release spare upload scratch and sweep idle texture staging blocks periodically. Under pressure the sweep keeps at most one empty 64 MiB staging block. A block can be released once all pieces are free after the existing retirement interval. - Use `VICTORY_RESIDENCY` to control the optional speculative texture limits. ## Validation - Clippy passed on Windows with all targets, all features, and warnings denied. - In the standard test profile, 445 GPU tests passed and 34 were ignored by the test suite. - The asset policy check passed for 271 tracked files. - The synthetic pool regression exercises releasing seven empty staging blocks (448 MiB) while preserving live and resting pieces. - In-game memory usage remains to be measured.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:58:55 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 01:23 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At 3f91df5: cargo test --release -p victory-gpu --lib, 4 runs: 3 passed whole (396 passed, 0 failed); one had host::refresh_tests::unchanged_ranges_are_known fail once. It did not come back in 10 runs alone or 3 more whole runs, and the base 4eb6cfd showed a flaky watch test in the same session. So I take it as a flake, not this PR.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 01:23 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/386#issuecomment-7207245766) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `3f91df5`: `cargo test --release -p victory-gpu --lib`, 4 runs: 3 passed whole (396 passed, 0 failed); one had `host::refresh_tests::unchanged_ranges_are_known` fail once. It did not come back in 10 runs alone or 3 more whole runs, and the base `4eb6cfd` showed a flaky `watch` test in the same session. So I take it as a flake, not this PR. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Gabriel-Ramaldes on GitHub · 2026-11-27 13:32 UTC · original

In-game test on AMD RDNA 4 with 32 GB, at 3f91df5 (a-publier 4eb6cfd + this PR), against 4eb6cfd as shipped.

Setup:

  • Windows 11 Pro 26300, RX 9070 XT 16 GB (driver 32.0.32029.2010), Ryzen 7 3700X, 32 GB DDR4, system-managed page file.
  • Diagnostics build; cargo test --locked -p victory-gpu --lib -- --test-threads=1: 396 passed, 0 failed, 34 ignored.
  • Every run uses scripts\play.ps1's settings (Series X).
  • The same manual save, restored before each run: a balcony after a mission, ~6,500 draws.
  • 300 s per run, shaders translated ahead, a warm-up run first, then runs in mirrored order.
  • Frame times are the log's per-second ms/frame over world lines, first quarter dropped.
  • Memory figures come from the log's last memory: line.
build median frame mean worst 1-s line private at the end free RAM at the end left to commit host textures
4eb6cfd 128.2 / 152.8 ms 134.8 / 180.0 273 / 411 32.1 / 31.7 GB 0.8 / 3.4 GB 0.8 / 8.2 GB 6.9 / 6.9 GB
this PR 122.3 / 116.2 ms 124.4 / 125.7 159 / 187 33.3 / 31.8 GB 2.6 / 3.3 GB 6.7 / 8.1 GB 8.0 / 7.0 GB
  • The new sweep does engage on this PC: "host memory pressure: reclaiming idle upload storage" once per run, at 1.8-3.0 GB of RAM free and 12.5-13.3 GB of commit available. Pressure stays on for the rest of the run.
  • It has little to take here:
    • when it turns on, texture staging is 84-141 MB and spare scratch 0-86 MB;
    • private bytes at the end are the same as the base within run-to-run noise (31.7-33.3 GB in both);
    • the base ran with 0.8 GB left to commit once.
  • Frame time: no regression seen. The PR's runs were not slower; the base's two runs were noisier, with 273 / 411 ms worst lines.
  • Crash at start, not caused by this PR: one of three starts of this PR died at t+33 s with #143's signature (victory-image-…dll+0x2215c35, write 0x0, before the world). The same happened to #512's build the same day.

AI-assisted (Claude Code); no game files.

**@⁠Gabriel-Ramaldes** on GitHub · 2026-11-27 13:32 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/386#issuecomment-7219618994) In-game test on AMD RDNA 4 with 32 GB, at `3f91df5` (`a-publier` `4eb6cfd` + this PR), against `4eb6cfd` as shipped. **Setup:** - Windows 11 Pro 26300, RX 9070 XT 16 GB (driver 32.0.32029.2010), Ryzen 7 3700X, 32 GB DDR4, system-managed page file. - Diagnostics build; `cargo test --locked -p victory-gpu --lib -- --test-threads=1`: 396 passed, 0 failed, 34 ignored. - Every run uses `scripts\play.ps1`'s settings (Series X). - The same manual save, restored before each run: a balcony after a mission, ~6,500 draws. - 300 s per run, shaders translated ahead, a warm-up run first, then runs in mirrored order. - Frame times are the log's per-second `ms/frame` over world lines, first quarter dropped. - Memory figures come from the log's last `memory:` line. | build | median frame | mean | worst 1-s line | private at the end | free RAM at the end | left to commit | host textures | |---|---|---|---|---|---|---|---| | `4eb6cfd` | 128.2 / 152.8 ms | 134.8 / 180.0 | 273 / 411 | 32.1 / 31.7 GB | 0.8 / 3.4 GB | 0.8 / 8.2 GB | 6.9 / 6.9 GB | | this PR | 122.3 / 116.2 ms | 124.4 / 125.7 | 159 / 187 | 33.3 / 31.8 GB | 2.6 / 3.3 GB | 6.7 / 8.1 GB | 8.0 / 7.0 GB | - **The new sweep does engage on this PC:** "host memory pressure: reclaiming idle upload storage" once per run, at 1.8-3.0 GB of RAM free and 12.5-13.3 GB of commit available. Pressure stays on for the rest of the run. - **It has little to take here:** - when it turns on, texture staging is 84-141 MB and spare scratch 0-86 MB; - private bytes at the end are the same as the base within run-to-run noise (31.7-33.3 GB in both); - the base ran with 0.8 GB left to commit once. - **Frame time:** no regression seen. The PR's runs were not slower; the base's two runs were noisier, with 273 / 411 ms worst lines. - **Crash at start, not caused by this PR:** one of three starts of this PR died at t+33 s with #143's signature (`victory-image-…dll+0x2215c35`, write 0x0, before the world). The same happened to #512's build the same day. AI-assisted (Claude Code); no game files.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 14:14 UTC · original

In-game numbers at 3f91df5 against a-publier 4eb6cfd, on an RX 7900 XT (RDNA 3, 20 GB), driver 32.0.32029.2010, Ryzen 7 5800X, 32 GB RAM, system-managed page file, Windows 11 26300. The RX 9070 XT report above found private memory at the end unchanged within its noise; this adds, on another card and route, what the sweep takes by the block counters and what it costs.

What I ran:

  • Unattended passes of the opening sequence: diag with diagnostics, Series S, the settings of scripts\play.ps1, frame capture on, DRED light.
  • 3 passes per build, inside one queue of 12 warm passes (PR at positions 1, 7, 12; base at 2, 8, 10; the rest were other builds), 65 minutes, nothing else running.
  • Window: 60-235 s after the first frame of 500 draws or more. Values are PR passes against base passes, medians of the 5 s memory lines unless said. Every ± is a Welch 95 % interval of the difference of means, 3 passes against 3.

The sweep was on for the whole window:

  • Each PR pass logs "host memory pressure: reclaiming idle upload storage" once and never "host memory pressure cleared".
  • Two logged it at frame 19 / 18, with 15,341 / 16,276 MiB of RAM free and 1,094 / 1,049 MiB of commit available. The third logged it at frame 1,259, half a second before the first frame of 500 draws, with 4,366 and 3,641 MiB.
  • So the commit line set it each time. Windows grows the page file as the process grows. In three of the six passes it was 21.0 GB allocated before and 46.9-47.0 GB five seconds after the close (commit limit 53.7 to 79.6-79.7 GB). Two others began with it still grown, and one was sampled after it had shrunk.
  • "Left to commit" stays at 0.1-1.9 GB from that first frame on, whatever the process holds. The RAM line would hold the pressure on too: 0.3-2.4 GB of RAM was free on every memory line of the window, in all six passes.
  • The WARN's texture_staging_mib is the live staging buffers (about 51 MB on both builds), not the blocks. What the sweep can take is on the memory in blocks and memory, what holds it lines.

What it did:

  • Staging blocks: 448 / 448 / 384 MB against 768 / 768 / 704 (-320 ± 84). On base they are constant in the window. With the PR they move between 256 and 1,024 MB.
  • List scratch: 192 / 203 / 202 MB against 381 / 364 / 396 (-181 ± 35). Of it spare: 24 / 32 / 36 against 236 / 200 / 222 (-189 ± 41).

Did memory come down:

  • Plain private: 27,632 / 27,215 / 28,148 MB against 28,147 / 28,489 / 28,356 (-666 ± 1,018). Its maximum: 31,178 / 30,587 / 30,841 against 31,166 / 31,280 / 31,346 (-395 ± 665). Neither interval excludes zero.
  • Private minus the card's memory in use on the same lines: 16,160 / 16,008 / 16,170 MB against 16,593 / 16,584 / 16,578 (-472 ± 223). I chose this figure after seeing the data, because private grows with the route and the passes do not progress alike.
  • Lowest "left to commit": 370 / 146 / 296 MB against 272 / 385 / 339.

So the sweep does what it says. The two counters fall by about 0.5 GB together, and the adjusted figure agrees. On plain private, its peak and "left to commit" I cannot show a change with three passes.

What it cost:

  • made so far: N upload buffers on the line nearest 235 s: 22,634 / 21,414 / 18,946 (14.4-17.0 GB) against 521 / 523 / 529 (2.0-2.2 GB). In the window that is 82-98 a second against 0.3-0.4. trim_spare_chunks drops every kept chunk at each sweep, once a second, and the lists make them again.
  • Each new buffer is waited for. "new memory waited for", last line of each pass (it is written every 1,000 waits): 54,000 / 52,000 / 52,000 times and 32.8 / 31.7 / 31.8 s, against 30,000 each and 15.4 / 15.8 / 16.4 s (+16.2 ± 1.3 s per pass). I did not trace which threads wait.
  • Relay line, "landing in all", mean of the one-second lines: 28.4 / 28.9 / 29.2 ms against 26.6 / 25.8 / 26.7 (+2.5 ± 1.0). The frame line's "copying back", median: 20.9 / 22.1 / 22.1 ms against 20.8 / 22.8 / 22.1 (-0.2 ± 2.1). I did not trace why the first moves and the second does not.
  • Submit thread, median of the one-second lines: 58.9 / 62.4 / 63.3 ms against 63.2 / 61.9 / 62.1 (-0.9 ± 5.2).
  • Frames in the window, from the saved-frame numbers: 2,184 / 2,179 / 2,510 against 2,248 / 2,606 / 2,527 (-6.9 ± 17.4 %).
  • Stall time above 20 ms, present to the title's first list call: 15.4 / 18.0 / 1.7 s against 9.1 / 2.3 / 3.5 (+6.7 ± 18.6).
  • The copying-back, submit, frame and stall intervals include zero. The frame interval also includes a cost of 24 %.
  • No ERROR line, no "no upload buffer" warning and no device loss in any pass.

What this cannot show:

  • A PC where pressure comes and goes. Here the sweep ran every second, the worst case for churn.
  • That giving scratch back every second is safe. The note on kept memory puts both device losses of 2026-11-25 on reads in memory given back seconds before, a list's scratch among them. Three passes of 4 minutes without a loss do not settle that.
  • One card, one driver, one route, not time-locked. Frames ranged from 2,014 to 2,606 across the 12 passes. With 3 against 3, a complete ordering comes up by chance one time in ten.
  • diag build, a PNG saved every 8th frame, and the process peaking at 30.6-31.3 GB private on a 32 GB PC.
  • The first PR pass started 1 s after another GPU job of mine ended.
**@⁠adrianmjim** on GitHub · 2026-11-27 14:14 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/386#issuecomment-7220530194) In-game numbers at 3f91df5 against a-publier 4eb6cfd, on an RX 7900 XT (RDNA 3, 20 GB), driver 32.0.32029.2010, Ryzen 7 5800X, 32 GB RAM, system-managed page file, Windows 11 26300. The RX 9070 XT report above found private memory at the end unchanged within its noise; this adds, on another card and route, what the sweep takes by the block counters and what it costs. What I ran: - Unattended passes of the opening sequence: `diag` with diagnostics, Series S, the settings of `scripts\play.ps1`, frame capture on, DRED light. - 3 passes per build, inside one queue of 12 warm passes (PR at positions 1, 7, 12; base at 2, 8, 10; the rest were other builds), 65 minutes, nothing else running. - Window: 60-235 s after the first frame of 500 draws or more. Values are PR passes against base passes, medians of the 5 s memory lines unless said. Every ± is a Welch 95 % interval of the difference of means, 3 passes against 3. The sweep was on for the whole window: - Each PR pass logs "host memory pressure: reclaiming idle upload storage" once and never "host memory pressure cleared". - Two logged it at frame 19 / 18, with 15,341 / 16,276 MiB of RAM free and 1,094 / 1,049 MiB of commit available. The third logged it at frame 1,259, half a second before the first frame of 500 draws, with 4,366 and 3,641 MiB. - So [the commit line](https://github.com/Belobug/VIctory-Belobug-AMD/blob/3f91df5/crates/victory-gpu/src/residency.rs#L125-L131) set it each time. Windows grows the page file as the process grows. In three of the six passes it was 21.0 GB allocated before and 46.9-47.0 GB five seconds after the close (commit limit 53.7 to 79.6-79.7 GB). Two others began with it still grown, and one was sampled after it had shrunk. - "Left to commit" stays at 0.1-1.9 GB from that first frame on, whatever the process holds. The RAM line would hold the pressure on too: 0.3-2.4 GB of RAM was free on every memory line of the window, in all six passes. - The WARN's `texture_staging_mib` is [the live staging buffers](https://github.com/Belobug/VIctory-Belobug-AMD/blob/3f91df5/crates/victory-gpu/src/texture.rs#L468-L471) (about 51 MB on both builds), not the blocks. What the sweep can take is on the `memory in blocks` and `memory, what holds it` lines. What it did: - Staging blocks: 448 / 448 / 384 MB against 768 / 768 / 704 (-320 ± 84). On base they are constant in the window. With the PR they move between 256 and 1,024 MB. - List scratch: 192 / 203 / 202 MB against 381 / 364 / 396 (-181 ± 35). Of it spare: 24 / 32 / 36 against 236 / 200 / 222 (-189 ± 41). Did memory come down: - Plain private: 27,632 / 27,215 / 28,148 MB against 28,147 / 28,489 / 28,356 (-666 ± 1,018). Its maximum: 31,178 / 30,587 / 30,841 against 31,166 / 31,280 / 31,346 (-395 ± 665). Neither interval excludes zero. - Private minus the card's memory in use on the same lines: 16,160 / 16,008 / 16,170 MB against 16,593 / 16,584 / 16,578 (-472 ± 223). I chose this figure after seeing the data, because private grows with the route and the passes do not progress alike. - Lowest "left to commit": 370 / 146 / 296 MB against 272 / 385 / 339. So the sweep does what it says. The two counters fall by about 0.5 GB together, and the adjusted figure agrees. On plain private, its peak and "left to commit" I cannot show a change with three passes. What it cost: - `made so far: N upload buffers` on the line nearest 235 s: 22,634 / 21,414 / 18,946 (14.4-17.0 GB) against 521 / 523 / 529 (2.0-2.2 GB). In the window that is 82-98 a second against 0.3-0.4. [`trim_spare_chunks`](https://github.com/Belobug/VIctory-Belobug-AMD/blob/3f91df5/crates/victory-gpu/src/host.rs#L2134-L2150) drops every kept chunk at each sweep, once a second, and the lists make them again. - Each new buffer is [waited for](https://github.com/Belobug/VIctory-Belobug-AMD/blob/3f91df5/crates/victory-gpu/src/host.rs#L9172-L9175). "new memory waited for", last line of each pass (it is written every 1,000 waits): 54,000 / 52,000 / 52,000 times and 32.8 / 31.7 / 31.8 s, against 30,000 each and 15.4 / 15.8 / 16.4 s (+16.2 ± 1.3 s per pass). I did not trace which threads wait. - Relay line, "landing in all", mean of the one-second lines: 28.4 / 28.9 / 29.2 ms against 26.6 / 25.8 / 26.7 (+2.5 ± 1.0). The frame line's "copying back", median: 20.9 / 22.1 / 22.1 ms against 20.8 / 22.8 / 22.1 (-0.2 ± 2.1). I did not trace why the first moves and the second does not. - Submit thread, median of the one-second lines: 58.9 / 62.4 / 63.3 ms against 63.2 / 61.9 / 62.1 (-0.9 ± 5.2). - Frames in the window, from the saved-frame numbers: 2,184 / 2,179 / 2,510 against 2,248 / 2,606 / 2,527 (-6.9 ± 17.4 %). - Stall time above 20 ms, present to the title's first list call: 15.4 / 18.0 / 1.7 s against 9.1 / 2.3 / 3.5 (+6.7 ± 18.6). - The copying-back, submit, frame and stall intervals include zero. The frame interval also includes a cost of 24 %. - No ERROR line, no "no upload buffer" warning and no device loss in any pass. What this cannot show: - A PC where pressure comes and goes. Here the sweep ran every second, the worst case for churn. - That giving scratch back every second is safe. [The note on kept memory](https://github.com/Belobug/VIctory-Belobug-AMD/blob/3f91df5/crates/victory-gpu/src/host.rs#L369-L380) puts both device losses of 2026-11-25 on reads in memory given back seconds before, a list's scratch among them. Three passes of 4 minutes without a loss do not settle that. - One card, one driver, one route, not time-locked. Frames ranged from 2,014 to 2,606 across the 12 passes. With 3 against 3, a complete ordering comes up by chance one time in ten. - `diag` build, a PNG saved every 8th frame, and the process peaking at 30.6-31.3 GB private on a 32 GB PC. - The first PR pass started 1 s after another GPU job of mine ended.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/386/head:github-bot/gh-386'
git switch 'github-bot/gh-386'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-386'
git switch 'github-bot/gh-386'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-386'
git switch 'github-bot/gh-386'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-386'
git switch 'a-publier'
git merge --squash 'github-bot/gh-386'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-386'
git switch 'a-publier'
git merge 'github-bot/gh-386'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.