victory-gpu: throttle pipeline workers and pause prewarming under commit pressure #1173

Open
belalhama wants to merge 1 commit from upstream-pr/1173 into main
belalhama commented 2026-11-28 14:52:33 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by belalhama on 2026-11-28T14:52:33Z.


Summary

On 32 GiB RAM hosts (especially with small default Windows pagefiles), parallel background compilation of speculative EARLY and slow pipelines can exhaust Windows commit headroom during loading screens and scene transitions (E_OUTOFMEMORY / Windows Event 2004, as noted in docs/windows-memory.md).

This PR makes the pipeline worker pool commit-aware and pauses speculative prewarming when host memory or commit headroom drops:

  • 32 ms physical & commit sampling (crates/victory-gpu/src/residency.rs):
    • sample_memory() now samples both ullAvailPhys and ullAvailPageFile every 32 ms and updates HEADROOM and PRESSURED, keeping memory pressure state accurate even during multi-second loading frames between submissions.
    • Added pipeline_policy() and pipeline_limits():
      • On <= 32 GiB hosts with moderate headroom (commit <= 6 GiB or physical <= 4 GiB), caps active general pipeline workers at half the pool ((workers / 2).max(2)).
      • Under host memory pressure (commit <= 4 GiB or physical <= 3 GiB), caps active general workers at 2 and pauses speculative EARLY / slow prewarming.
      • Under critical commit (< 1,536 MiB) or recent E_OUTOFMEMORY refusal, caps active general workers at 1 (for explicitly requested draws only) and pauses speculative prewarming.
    • Calls pipeline::wake_workers() whenever memory pressure clears.
  • Dynamic worker & prewarm gating (crates/victory-gpu/src/pipeline/make.rs, crates/victory-gpu/src/pipeline.rs):
    • Tracks ctive_now for general workers in Queue::pop_with().
    • Dedicated SCREEN_WORKERS (first-scene lighting and bake passes) remain unthrottled, and any EARLY pipeline promoted to REQUESTED by an active draw runs immediately even while speculative prewarming is paused.

Testing

  • Added unit tests
    esidency::tests::pipeline_policy_throttles_workers_and_pauses_prewarm_under_pressure and pipeline::make::tests::pressure_pauses_prewarming_and_caps_active_general_workers.
  • Verified cargo test -p victory-gpu --lib residency (4/4 passed) and cargo test -p victory-gpu --lib pipeline::make::tests (9/9 passed).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5541353566 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1173). Originally posted by [belalhama](https://github.com/belalhama) on 2026-11-28T14:52:33Z. --- ### Summary On 32 GiB RAM hosts (especially with small default Windows pagefiles), parallel background compilation of speculative EARLY and slow pipelines can exhaust Windows commit headroom during loading screens and scene transitions (E_OUTOFMEMORY / Windows Event 2004, as noted in docs/windows-memory.md). This PR makes the pipeline worker pool commit-aware and pauses speculative prewarming when host memory or commit headroom drops: - **32 ms physical & commit sampling (crates/victory-gpu/src/residency.rs)**: - sample_memory() now samples both ullAvailPhys and ullAvailPageFile every 32 ms and updates HEADROOM and PRESSURED, keeping memory pressure state accurate even during multi-second loading frames between submissions. - Added pipeline_policy() and pipeline_limits(): - On <= 32 GiB hosts with moderate headroom (commit <= 6 GiB or physical <= 4 GiB), caps active general pipeline workers at half the pool ((workers / 2).max(2)). - Under host memory pressure (commit <= 4 GiB or physical <= 3 GiB), caps active general workers at 2 and pauses speculative EARLY / slow prewarming. - Under critical commit (< 1,536 MiB) or recent E_OUTOFMEMORY refusal, caps active general workers at 1 (for explicitly requested draws only) and pauses speculative prewarming. - Calls pipeline::wake_workers() whenever memory pressure clears. - **Dynamic worker & prewarm gating (crates/victory-gpu/src/pipeline/make.rs, crates/victory-gpu/src/pipeline.rs)**: - Tracks ctive_now for general workers in Queue::pop_with(). - Dedicated SCREEN_WORKERS (first-scene lighting and bake passes) remain unthrottled, and any EARLY pipeline promoted to REQUESTED by an active draw runs immediately even while speculative prewarming is paused. ### Testing - Added unit tests esidency::tests::pipeline_policy_throttles_workers_and_pauses_prewarm_under_pressure and pipeline::make::tests::pressure_pauses_prewarming_and_caps_active_general_workers. - Verified cargo test -p victory-gpu --lib residency (4/4 passed) and cargo test -p victory-gpu --lib pipeline::make::tests (9/9 passed).
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/1173:upstream-pr/1173'
git switch 'upstream-pr/1173'

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/1173'
git switch 'upstream-pr/1173'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1173'
git switch 'upstream-pr/1173'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1173'
git switch 'main'
git merge --squash 'upstream-pr/1173'
git switch 'main'
git merge --ff-only 'upstream-pr/1173'
git switch 'main'
git merge 'upstream-pr/1173'
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
trustno1-coder/VIctory-NVIDIA!1173
No description provided.