GPU: under memory pressure the sweep lets idle scratch chunks and pooled lists go (RAM band, commit-aware) #476

Open
simbaui4life wants to merge 2 commits from upstream-pr/476 into main
simbaui4life commented 2026-11-27 16:30:35 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by simbaui4life on 2026-11-27T16:30:35Z.


Builds on #473 (the memory bench): its commit is included, and only the last commit is new. It is independent of #474; both touch host.rs, in different functions.

Cause: two caches ignore memory pressure in the default setup.

  • Idle scratch chunks: up to SPARE_KEPT (1 GiB) with VICTORY_KEEP_FREED. They were let go only with VICTORY_RESIDENCY=1, which is off by default.
  • Host lists idle in the pool: up to 512 lists, each with its allocators. They were never let go.

Only windows react to low free RAM (ram_idle_ms). The commit limit, where the reported crashes happen (#146, #189, #267, #465), was not looked at for either cache.

What this does

  • The once-a-second sweep() now takes the RAM band (ram_band), with its hysteresis. The band looks at free RAM, commit headroom, this process's private bytes and its working set. Until now only the opt-in window budget used it.
    • Calm: as before.
    • Watch: idle chunks down to SPARE_MOST (128 MiB), and lists idle in the pool for 10 s go.
    • High: all idle chunks go, and lists idle for 2 s go.
    • The times are those used for windows.
  • Lists: only those that waited longest go (list::let_go_idle). fresh_list takes the one given last, so a busy frame keeps its lists; the 21 ms a frame of making lists anew (list.rs) is not brought back.
  • Switch: on by default; VICTORY_PRESSURE_TRIM=0 restores the old behaviour.
  • Related: #271 (retention by process size) goes at the same problem from the other side.

Tested (RTX 4070 Ti, driver 621.01, debug build, VICTORY_RELAY=2)

  • Memory bench pressure test: a spike, then idle "told 1 GiB free". The test now asserts that spare bytes and pooled lists come down.

    under pressure trim off trim on
    lists idle in the pool 68 → 68 68 → 8
    spare scratch 297.2 → 297.2 MB 297.0 → 34.0 MB
    private bytes −19 MB −98 MB

    Private bytes fell less than the chunks let go (263 MB); the driver may keep freed upload memory for a while. I did not establish why.

  • With room: nothing changes, and the steady state stays flat (1057.6 → 1058.0 MB).

  • cargo test -p victory-gpu: 394 passed, 0 failed (37 ignored). One run of three failed watch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_view (one page guarded); it passed alone 3 of 3 and in the next full run. watch.rs is not touched; it looks like an existing order-dependent test.

  • Clippy: adds nothing (main's existing failures are listed in #473).

Not tested:

  • In the game (no game data here), in particular whether Watch on a 32 GB PC (working set ≥ ¼ of RAM) makes lists or chunks be made anew too often. The 10 s idle time should keep the lists a frame needs.
  • Other GPUs.

No game data in the commits.

🤖 Generated with Claude Code

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:5529943880 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/476). Originally posted by [simbaui4life](https://github.com/simbaui4life) on 2026-11-27T16:30:35Z. --- **Builds on #473** (the memory bench): its commit is included, and only the last commit is new. It is independent of #474; both touch `host.rs`, in different functions. **Cause:** two caches ignore memory pressure in the default setup. - **Idle scratch chunks:** up to `SPARE_KEPT` (1 GiB) with `VICTORY_KEEP_FREED`. They were let go only with `VICTORY_RESIDENCY=1`, which is off by default. - **Host lists idle in the pool:** up to 512 lists, each with its allocators. They were never let go. Only windows react to low free RAM (`ram_idle_ms`). The commit limit, where the reported crashes happen (#146, #189, #267, #465), was not looked at for either cache. **What this does** - The once-a-second `sweep()` now takes the RAM band (`ram_band`), with its hysteresis. The band looks at free RAM, commit headroom, this process's private bytes and its working set. Until now only the opt-in window budget used it. - **Calm:** as before. - **Watch:** idle chunks down to `SPARE_MOST` (128 MiB), and lists idle in the pool for 10 s go. - **High:** all idle chunks go, and lists idle for 2 s go. - The times are those used for windows. - **Lists:** only those that waited longest go (`list::let_go_idle`). `fresh_list` takes the one given last, so a busy frame keeps its lists; the 21 ms a frame of making lists anew (`list.rs`) is not brought back. - **Switch:** on by default; `VICTORY_PRESSURE_TRIM=0` restores the old behaviour. - **Related:** #271 (retention by process size) goes at the same problem from the other side. **Tested** (RTX 4070 Ti, driver 621.01, debug build, `VICTORY_RELAY=2`) - **Memory bench pressure test:** a spike, then idle "told 1 GiB free". The test now asserts that spare bytes and pooled lists come down. | under pressure | trim off | trim on | |---|---|---| | lists idle in the pool | 68 → 68 | 68 → 8 | | spare scratch | 297.2 → 297.2 MB | 297.0 → 34.0 MB | | private bytes | −19 MB | −98 MB | Private bytes fell less than the chunks let go (263 MB); the driver may keep freed upload memory for a while. I did not establish why. - **With room:** nothing changes, and the steady state stays flat (1057.6 → 1058.0 MB). - **`cargo test -p victory-gpu`:** 394 passed, 0 failed (37 ignored). One run of three failed `watch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_view` (one page guarded); it passed alone 3 of 3 and in the next full run. `watch.rs` is not touched; it looks like an existing order-dependent test. - **Clippy:** adds nothing (main's existing failures are listed in #473). **Not tested:** - In the game (no game data here), in particular whether Watch on a 32 GB PC (working set ≥ ¼ of RAM) makes lists or chunks be made anew too often. The 10 s idle time should keep the lists a frame needs. - Other GPUs. No game data in the commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/476:upstream-pr/476'
git switch 'upstream-pr/476'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/476'
git switch 'upstream-pr/476'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/476'
git switch 'upstream-pr/476'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/476'
git switch 'main'
git merge --squash 'upstream-pr/476'
git switch 'main'
git merge --ff-only 'upstream-pr/476'
git switch 'main'
git merge 'upstream-pr/476'
git push origin 'main'
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
avatarmanz/VIctory-7900XTX!476
No description provided.