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

Open
fever308 wants to merge 3 commits from upstream-pr/47 into main
fever308 commented 2026-11-24 20:54:23 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by fever308 on 2026-11-24T20:54:23Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6591205353 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/47). Originally posted by [fever308](https://github.com/fever308) on 2026-11-24T20:54:23Z. --- ## 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.
im-a-cat commented 2026-11-25 08:08:59 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by im-a-cat on 2026-11-25T07:21:22Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7155768519 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/47#issuecomment-7155768519). Originally posted by [im-a-cat](https://github.com/im-a-cat) on 2026-11-25T07:21:22Z. --- 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.
fever308 commented 2026-11-25 08:08:59 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by fever308 on 2026-11-25T07:27:24Z.


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).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7155879843 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/47#issuecomment-7155879843). Originally posted by [fever308](https://github.com/fever308) on 2026-11-25T07:27:24Z. --- 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 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/47:upstream-pr/47'
git switch 'upstream-pr/47'

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/47'
git switch 'upstream-pr/47'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/47'
git switch 'upstream-pr/47'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/47'
git switch 'main'
git merge --squash 'upstream-pr/47'
git switch 'main'
git merge --ff-only 'upstream-pr/47'
git switch 'main'
git merge 'upstream-pr/47'
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
fxceless/victory-fork!47
No description provided.