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

Open
github-bot wants to merge 2 commits from github-bot/gh-476 into main AGit
Owner

@⁠simbaui4life on GitHub · 2026-11-27 16:30 UTC · original
simbaui4life:fix/pressure-trims → main · +922 −14 · 5 files · 2 commits · open

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

**@⁠simbaui4life** on GitHub · 2026-11-27 16:30 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/476) `simbaui4life:fix/pressure-trims` → `main` · +922 −14 · 5 files · 2 commits · open **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)
Ignored tests memory_bench_steady_state and memory_bench_pressure_lets_idle_go: lists, copies,
submissions, fences and windows through the title-facing methods, with title memory from a
write-watched VirtualAlloc allocator; per-class bytes from the existing counters and private
bytes, flat over 240 frames; idle memory let go when little RAM is said to be free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Idle scratch chunks (up to 1 GiB with VICTORY_KEEP_FREED) were let go only with
VICTORY_RESIDENCY=1, and host lists idle in the pool (up to 512) never. Free RAM alone
reached only windows.

The once-a-second sweep now takes the RAM band (ram_band: free RAM, commit headroom, this
process's private bytes and working set, with its hysteresis; until now used only by the
opt-in window budget). Watch: idle chunks down to SPARE_MOST (128 MiB), lists idle in the
pool for 10 s go. High: all idle chunks, lists idle for 2 s. Calm: as before. The times are
those of the windows. On by default; VICTORY_PRESSURE_TRIM=0: as before.

Memory bench (RTX 4070 Ti, VICTORY_RELAY=2), pressure test, after a spike, told 1 GiB free:
- trim off: pooled lists 68 -> 68, spare chunks 297.2 -> 297.2 MB, private -19 MB
- trim on:  pooled lists 68 -> 8,  spare chunks 297.0 -> 34.0 MB,  private -98 MB
With room nothing changes; the steady state stays flat. The pressure test now asserts that
spare bytes and pooled lists come down.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 16:36:53 +00:00
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/476/head:github-bot/gh-476'
git switch 'github-bot/gh-476'

Merge

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