Skip to content

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

Open
fever308 wants to merge 3 commits into
fxceless:mainfrom
fever308:feat/auto-ram-pool-limits
Open

fever308 wants to merge 3 commits into
fxceless:mainfrom
fever308:feat/auto-ram-pool-limits

Conversation

@fever308

@fever308 fever308 commented Nov 24, 2026 •

Copy link
Copy Markdown

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.

@im-a-cat

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown
Author

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
fever308 force-pushed the feat/auto-ram-pool-limits branch from bfff043 to 23ac4d4 Compare November 25, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants