Lazy commit for XMemVirtualAlloc and <=16 GiB host RAM tuning #3738

Closed
rdj415 wants to merge 5 commits from upstream-pr/3738 into main
rdj415 commented 2026-11-30 05:45:19 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by rdj415 on 2026-11-30T05:45:19Z.


What it changes

Reduces host RAM pressure and private commit usage on <= 16 GiB RAM systems by ~6.4–7.0 GB without affecting default residency behavior on higher-RAM machines.

  • Lazy commit for XMemVirtualAlloc (crates/victory-hle/src/modules/xmem.rs, crates/victory-gpu/src/watch.rs, crates/victory-gpu/src/lib.rs)
    • Reserves virtual address ranges upfront and commits backing pages on demand instead of committing full allocations immediately, cutting private commit pressure.
  • Tight host RAM tier (<= 16 GiB) (crates/victory-gpu/src/residency.rs)
    • Adds tight_host_ram() (s.ullTotalPhys <= 16 * GIB) to gate <= 16 GiB host memory tuning.
  • Host/shadow residency tuning under tight_host_ram() (crates/victory-gpu/src/host.rs, crates/victory-gpu/src/shadow.rs, crates/victory-gpu/src/resource.rs)
    • Caps ram_idle_ms at 4_000 ms and defaults allocator_trim to 5s, while preserving bury_lag = 16 on limited_host_ram().
    • Enables the 1024 KiB (1 MiB) shadow window grid and tails() by default, and sets exact_pool_limit to 16 << 20 (16 MiB).
    • Lowers the default slot_evict_settings() high threshold to room.saturating_sub(4).clamp(50, 78).

How it was tested

  • GPU and profile: NVIDIA GeForce RTX 5060 Ti (16 GiB VRAM), 16 GiB system RAM, Series S, 1080to1440 (720p), DLSS Quality, FG 2X, RT Off.
  • Memory comparison (~90s into world load on v2026.11.29.05 base):
Metric Before After Delta
Private 24,057 MB 17,033–17,623 MB -6,434 to -7,024 MB (-27% to -29%)
Committed 36,480 MB 29,742–30,041 MB -6,439 to -6,738 MB (~-18%)
  • Before: 5,054 MB host copies of title memory, 6,207 MB shared, 0 MB slot evicted (without 1 MiB shadow window grid/tails() and lowered slot_evict).
  • After: run with lazy_commit, 1 MiB shadow window grid/tails(), and lowered slot_evict.
  • Shader wave sizes tested (32 and/or 64 lanes): N/A (no shader translator changes).
  • cargo test results:
    • cargo test -p victory-hle --lib -- --test-threads=1: 424 passed, 0 failed, 5 ignored.
    • cargo test -p victory-gpu --lib -- --test-threads=1: 921 passed, 1 failed, 60 ignored (pre-existing failure: shader_cache::tests::every_switch_of_the_translator_is_in_the_key / VICTORY_SCALAR_SPLITS).

Checked for overlap

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5559758155 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3738). Originally posted by [rdj415](https://github.com/rdj415) on 2026-11-30T05:45:19Z. --- ## What it changes Reduces host RAM pressure and private commit usage on `<= 16 GiB` RAM systems by ~6.4–7.0 GB without affecting default residency behavior on higher-RAM machines. - **Lazy commit for `XMemVirtualAlloc`** (`crates/victory-hle/src/modules/xmem.rs`, `crates/victory-gpu/src/watch.rs`, `crates/victory-gpu/src/lib.rs`) - Reserves virtual address ranges upfront and commits backing pages on demand instead of committing full allocations immediately, cutting private commit pressure. - **Tight host RAM tier (`<= 16 GiB`)** (`crates/victory-gpu/src/residency.rs`) - Adds `tight_host_ram()` (`s.ullTotalPhys <= 16 * GIB`) to gate `<= 16 GiB` host memory tuning. - **Host/shadow residency tuning under `tight_host_ram()`** (`crates/victory-gpu/src/host.rs`, `crates/victory-gpu/src/shadow.rs`, `crates/victory-gpu/src/resource.rs`) - Caps `ram_idle_ms` at `4_000` ms and defaults `allocator_trim` to `5s`, while preserving `bury_lag = 16` on `limited_host_ram()`. - Enables the `1024 KiB` (1 MiB) shadow window grid and `tails()` by default, and sets `exact_pool_limit` to `16 << 20` (16 MiB). - Lowers the default `slot_evict_settings()` `high` threshold to `room.saturating_sub(4).clamp(50, 78)`. ## How it was tested - **GPU and profile:** NVIDIA GeForce RTX 5060 Ti (16 GiB VRAM), 16 GiB system RAM, Series S, 1080to1440 (720p), DLSS Quality, FG 2X, RT Off. - **Memory comparison** (~90s into world load on `v2026.11.29.05` base): | Metric | Before | After | Delta | | :--- | :--- | :--- | :--- | | **Private** | `24,057 MB` | `17,033–17,623 MB` | **-6,434 to -7,024 MB (-27% to -29%)** | | **Committed** | `36,480 MB` | `29,742–30,041 MB` | **-6,439 to -6,738 MB (~-18%)** | - *Before:* `5,054 MB` host copies of title memory, `6,207 MB` shared, `0 MB` slot evicted (without 1 MiB shadow window grid/`tails()` and lowered `slot_evict`). - *After:* run with `lazy_commit`, 1 MiB shadow window grid/`tails()`, and lowered `slot_evict`. - **Shader wave sizes tested (32 and/or 64 lanes):** N/A (no shader translator changes). - **`cargo test` results:** - `cargo test -p victory-hle --lib -- --test-threads=1`: **424 passed**, 0 failed, 5 ignored. - `cargo test -p victory-gpu --lib -- --test-threads=1`: **921 passed**, 1 failed, 60 ignored *(pre-existing failure: `shader_cache::tests::every_switch_of_the_translator_is_in_the_key` / `VICTORY_SCALAR_SPLITS`)*. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: • #3503 • #3723 • #3584 • #3126, #2133, #2390
trustno1-coder commented 2026-12-01 18:49:18 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:49:18Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321611821 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3738#issuecomment-7321611821). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:49:18Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!3738
No description provided.