gpu: scale snapshot, scratch, and command-list pools from system RAM #47

Open
github-bot wants to merge 3 commits from github-bot/gh-47 into main AGit
Owner

@⁠fever308 on GitHub · 2026-11-24 20:54 UTC · original
fever308:feat/auto-ram-pool-limits → main · +168 −13 · 4 files · 3 commits · open

Summary

crates/victory-gpu/src/
├── lib.rs     # #[cfg(windows)] total_system_ram_bytes() via GlobalMemoryStatusEx (OnceLock)
├── host.rs    # spare_most:        64 / 128 / 256 MiB  (<= 16 GiB / middle / >= 30 GiB)
├── list.rs    # idle_most:         clamp(cores * 16, 64, 256) lists; 128 / 256 / 512 MiB
└── shadow.rs  # snapshot_pool_cap: clamp(ram / 32, 128 MiB, 1024 MiB)

Using >= 30 GiB for the 32 GB tier accounts for firmware/hardware reservations where Windows ullTotalPhys reports ~31.7–31.9 GiB.

Evidence

  • Before: Fixed host RAM pool caps (128 MiB spare scratch, 128 lists / 256 MiB idle list memory, 512 MiB snapshot pool) across all host RAM capacities.
    After:
    • cargo test -p victory-gpu scales_with_ram: 3 passed (spare_most_scales_with_ram, idle_most_scales_with_ram_and_cores, snapshot_pool_cap_scales_with_ram), 0 failed.
    • cargo clippy -p victory-gpu --all-targets -- -D warnings (default and --all-features): clean.

Merge Danger

Door: two-way

Only changes retention ceilings for reusable pools; VICTORY_SCRATCH_POOL=0 and VICTORY_LIST_POOL=0 remain unchanged.

Blast Radius: Pools

Changes peak retained host RAM for scratch chunks, idle host command lists, and shadow snapshot buffers.

**@⁠fever308** on GitHub · 2026-11-24 20:54 UTC · [original](https://github.com/fxceless/victory-fork/pull/47) `fever308:feat/auto-ram-pool-limits` → `main` · +168 −13 · 4 files · 3 commits · open ## Summary ```text crates/victory-gpu/src/ ├── lib.rs # #[cfg(windows)] total_system_ram_bytes() via GlobalMemoryStatusEx (OnceLock) ├── host.rs # spare_most: 64 / 128 / 256 MiB (<= 16 GiB / middle / >= 30 GiB) ├── list.rs # idle_most: clamp(cores * 16, 64, 256) lists; 128 / 256 / 512 MiB └── shadow.rs # snapshot_pool_cap: clamp(ram / 32, 128 MiB, 1024 MiB) ``` Using `>= 30 GiB` for the 32 GB tier accounts for firmware/hardware reservations where Windows `ullTotalPhys` reports ~31.7–31.9 GiB. ## Evidence - **Before:** Fixed host RAM pool caps (`128 MiB` spare scratch, `128` lists / `256 MiB` idle list memory, `512 MiB` snapshot pool) across all host RAM capacities. **After:** - `cargo test -p victory-gpu scales_with_ram`: 3 passed (`spare_most_scales_with_ram`, `idle_most_scales_with_ram_and_cores`, `snapshot_pool_cap_scales_with_ram`), 0 failed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`): clean. ## Merge Danger **Door:** two-way Only changes retention ceilings for reusable pools; `VICTORY_SCRATCH_POOL=0` and `VICTORY_LIST_POOL=0` remain unchanged. **Blast Radius:** Pools Changes peak retained host RAM for scratch chunks, idle host command lists, and shadow snapshot buffers.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:35:12 +00:00
Author
Owner

@⁠im-a-cat on GitHub · 2026-11-25 07:21 UTC · original

Tested cleanly against current fxceless/main (a26859f) on Windows 11 (Ryzen 5 5600, 32 GB RAM, RTX 4060 Ti 16 GB):

  • Merges cleanly onto a26859f (4 files, +111/-11).
  • Passes workspace unit tests (cargo test --workspace --locked) when stacked with #461, #190, #500, and #592 (including spare_most_scales_with_ram and snapshot_pool_cap_scales_with_ram).

One note from our 32 GB std::alloc::rust_oom report in #771: for ullTotalPhys >= 30 GiB, scaling spare_most up (128 -> 256 MiB) and snapshot_pool_cap up (512 -> 1024 MiB) is keyed off total installed RAM rather than remaining Windows commit charge (ullAvailPageFile), so 32 GB hosts with tight pagefile headroom can hold more pooled memory across transitions. Scaling pools down on <= 16 GiB systems looks solid.

**@⁠im-a-cat** on GitHub · 2026-11-25 07:21 UTC · [original](https://github.com/fxceless/victory-fork/pull/47#issuecomment-7155768519) Tested cleanly against current `fxceless/main` (`a26859f`) on Windows 11 (Ryzen 5 5600, 32 GB RAM, RTX 4060 Ti 16 GB): - Merges cleanly onto `a26859f` (4 files, +111/-11). - Passes workspace unit tests (`cargo test --workspace --locked`) when stacked with #461, #190, #500, and #592 (including `spare_most_scales_with_ram` and `snapshot_pool_cap_scales_with_ram`). One note from our 32 GB `std::alloc::rust_oom` report in #771: for `ullTotalPhys >= 30 GiB`, scaling `spare_most` up (128 -> 256 MiB) and `snapshot_pool_cap` up (512 -> 1024 MiB) is keyed off total installed RAM rather than remaining Windows commit charge (`ullAvailPageFile`), so 32 GB hosts with tight pagefile headroom can hold more pooled memory across transitions. Scaling pools down on `<= 16 GiB` systems looks solid.
Author
Owner

@⁠fever308 on GitHub · 2026-11-25 07:27 UTC · original

Thank you for testing this on Windows 11 and for flagging the 32 GB std::alloc::rust_oom / tight pagefile headroom issue (#771), @im-a-cat — that's a great catch!

Pushed bfff043 to clamp all three RAM-scaled pool caps dynamically against remaining Windows commit charge (MEMORYSTATUSEX.ullAvailPageFile) via available_commit_bytes():

  • ullAvailPageFile >= 8 GiB (or unknown): full RAM-scaled tier (spare_most up to 256 MiB, idle_most up to 512 MiB, snapshot_pool_cap up to 1024 MiB on >= 30 GiB hosts).
  • 4 GiB <= ullAvailPageFile < 8 GiB: clamped to the baseline caps (128 MiB / 256 MiB / 512 MiB), so 32 GB hosts with tight pagefile headroom do not grow pooled memory past baseline during transitions.
  • ullAvailPageFile < 4 GiB: clamped down to the low-memory floor (64 MiB / 128 MiB / 128 MiB).
  • Systems with <= 16 GiB RAM still never scale above their lower RAM tier even with a large pagefile (by_ram.min(by_commit)).

Verified locally with cargo clippy -p victory-gpu --all-targets (default and --all-features, -D warnings), unit tests covering all commit-headroom clamping tiers (spare_most_scales_with_ram, idle_most_scales_with_ram_and_cores, snapshot_pool_cap_scales_with_ram), and a clean merge check against fxceless/main (a26859f).

**@⁠fever308** on GitHub · 2026-11-25 07:27 UTC · [original](https://github.com/fxceless/victory-fork/pull/47#issuecomment-7155879843) Thank you for testing this on Windows 11 and for flagging the 32 GB `std::alloc::rust_oom` / tight pagefile headroom issue (`#771`), `@im-a-cat` — that's a great catch! Pushed `bfff043` to clamp all three RAM-scaled pool caps dynamically against remaining Windows commit charge (`MEMORYSTATUSEX.ullAvailPageFile`) via `available_commit_bytes()`: - `ullAvailPageFile >= 8 GiB` (or unknown): full RAM-scaled tier (`spare_most` up to 256 MiB, `idle_most` up to 512 MiB, `snapshot_pool_cap` up to 1024 MiB on `>= 30 GiB` hosts). - `4 GiB <= ullAvailPageFile < 8 GiB`: clamped to the baseline caps (`128 MiB` / `256 MiB` / `512 MiB`), so 32 GB hosts with tight pagefile headroom do not grow pooled memory past baseline during transitions. - `ullAvailPageFile < 4 GiB`: clamped down to the low-memory floor (`64 MiB` / `128 MiB` / `128 MiB`). - Systems with `<= 16 GiB` RAM still never scale above their lower RAM tier even with a large pagefile (`by_ram.min(by_commit)`). Verified locally with `cargo clippy -p victory-gpu --all-targets` (default and `--all-features`, `-D warnings`), unit tests covering all commit-headroom clamping tiers (`spare_most_scales_with_ram`, `idle_most_scales_with_ram_and_cores`, `snapshot_pool_cap_scales_with_ram`), and a clean merge check against `fxceless/main` (`a26859f`).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/47/head:github-bot/gh-47'
git switch 'github-bot/gh-47'

Merge

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