fix(gpu): apply slot eviction backoff on VICTORY_SLOT_EVICT_ASIDE path #4466

Closed
github-bot wants to merge 1 commit from github-bot/gh-4465 into main AGit
Owner

@⁠YounesAH15 on GitHub · 2026-11-30 20:40 UTC · original
YounesAH15:fix/8gb-vram-eviction → main · +45 −9 · 1 files · 1 commits · closed without merging

Problem

When VICTORY_SLOT_EVICT_ASIDE is enabled (the default), slot_evict returns early immediately after calling slot_look_aside(job), bypassing the NEXT_SLOT_MS backoff update (#2549) that only ran on the synchronous path:

  • NEXT_SLOT_MS stayed 0 forever on the async path, so whenever an 8 GB GPU was over the eviction threshold and slot_choose returned 0 victims (e.g. bindless/indexed textures without VICTORY_SAMPLED_EVICT=1), slot_look_aside spawned a fresh victory-slot-look OS thread on every sweep (each taking ~45-90 ms and contending on TEXTURES / SHADER_HEAPS locks) instead of backing off for 15 s.
  • slot_look_aside also did not check SLOT_HAS_READY, allowing a subsequent sweep before slot_evict_ready to spawn a redundant look thread and overwrite SLOT_READY.

Changes (crates/victory-gpu/src/resource.rs)

  • Hoisted NEXT_SLOT_MS to module scope with slot_evict_next_ms / slot_evict_schedule_next helpers.
  • Carried over_budget: bool on SlotJob.
  • Guarded slot_look_aside with SLOT_HAS_READY.load(Acquire) so pending victims aren't overwritten by a redundant scan.
  • Scheduled the #2549 backoff both when an async look finds 0 victims (15 s) and when slot_evict_ready finishes applying victims (2 s over budget / 5 s under budget / 15 s if 0 evicted).
  • Added unit test slot_evict_next_ms_schedules_backoff_for_sync_and_aside.

Verification

  • Unit tests: cargo test -p victory-gpu slot eviction tests — 9 passed, 0 failed (including slot_evict_next_ms_schedules_backoff_for_sync_and_aside, slot_evict_backoff_slows_empty_passes, a_texture_freed_since_the_look_aside_is_left_alone, a_rewritten_texture_descriptor_survives_a_stale_eviction).
  • In-game (RTX 3050 8 GB, Series S, release build): Verified slot eviction aside log timestamps across ~4 minutes of play (16 looks, 0 victims, 45.0 ms avg / 89.9 ms max) spaced cleanly at the 15 s backoff:
    • Look #1: 19:00:17.21
    • Look #2: 19:00:32.95 (+15.7 s)
    • Look #4: 19:01:04.29 (+15.6 s/look)
    • Look #8: 19:02:05.15 (+15.2 s/look)
    • Look #16: 19:04:06.71 (+15.2 s/look)
**@⁠YounesAH15** on GitHub · 2026-11-30 20:40 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4465) `YounesAH15:fix/8gb-vram-eviction` → `main` · +45 −9 · 1 files · 1 commits · closed without merging ### Problem When `VICTORY_SLOT_EVICT_ASIDE` is enabled (the default), `slot_evict` returns early immediately after calling `slot_look_aside(job)`, bypassing the `NEXT_SLOT_MS` backoff update (#2549) that only ran on the synchronous path: - `NEXT_SLOT_MS` stayed `0` forever on the async path, so whenever an 8 GB GPU was over the eviction threshold and `slot_choose` returned 0 victims (e.g. bindless/indexed textures without `VICTORY_SAMPLED_EVICT=1`), `slot_look_aside` spawned a fresh `victory-slot-look` OS thread on every sweep (each taking ~45-90 ms and contending on `TEXTURES` / `SHADER_HEAPS` locks) instead of backing off for 15 s. - `slot_look_aside` also did not check `SLOT_HAS_READY`, allowing a subsequent sweep before `slot_evict_ready` to spawn a redundant look thread and overwrite `SLOT_READY`. ### Changes (`crates/victory-gpu/src/resource.rs`) - Hoisted `NEXT_SLOT_MS` to module scope with `slot_evict_next_ms` / `slot_evict_schedule_next` helpers. - Carried `over_budget: bool` on `SlotJob`. - Guarded `slot_look_aside` with `SLOT_HAS_READY.load(Acquire)` so pending victims aren't overwritten by a redundant scan. - Scheduled the #2549 backoff both when an async look finds 0 victims (15 s) and when `slot_evict_ready` finishes applying victims (2 s over budget / 5 s under budget / 15 s if 0 evicted). - Added unit test `slot_evict_next_ms_schedules_backoff_for_sync_and_aside`. ### Verification - **Unit tests:** `cargo test -p victory-gpu` slot eviction tests — **9 passed, 0 failed** (including `slot_evict_next_ms_schedules_backoff_for_sync_and_aside`, `slot_evict_backoff_slows_empty_passes`, `a_texture_freed_since_the_look_aside_is_left_alone`, `a_rewritten_texture_descriptor_survives_a_stale_eviction`). - **In-game (RTX 3050 8 GB, Series S, release build):** Verified `slot eviction aside` log timestamps across ~4 minutes of play (16 looks, 0 victims, 45.0 ms avg / 89.9 ms max) spaced cleanly at the 15 s backoff: - Look #1: `19:00:17.21` - Look #2: `19:00:32.95` (+15.7 s) - Look #4: `19:01:04.29` (+15.6 s/look) - Look #8: `19:02:05.15` (+15.2 s/look) - Look #16: `19:04:06.71` (+15.2 s/look)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 20:41:27 +00:00
Author
Owner

@⁠tikD1337 on GitHub · 2026-11-30 20:51 UTC · original

Tested headlessly on origin/main (e1251c31, Windows 11, no game run):

  • Merge check: clean against origin/main.
  • cargo test -p victory-gpu --lib -- slot_evict: 7 passed, 0 failed (1193 filtered).

Note: this overlaps in crates/victory-gpu/src/resource.rs with #4433 (both hoist NEXT_SLOT_MS, add over_budget to SlotJob, guard slot_look_aside with SLOT_HAS_READY, and schedule backoff on empty victims / after slot_apply). Merging both would conflict in resource.rs. (#4466 uses Relaxed on NEXT_SLOT_MS and tests the pure helper without mutating global statics; #4433 uses Acquire/Release and also updates sampled.rs sweep_cadence.)

(AI-assisted build/unit-test check and diff review; game runtime not launched.)

**@⁠tikD1337** on GitHub · 2026-11-30 20:51 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4465#issuecomment-7291562009) Tested headlessly on `origin/main` (`e1251c31`, Windows 11, no game run): - Merge check: clean against `origin/main`. - `cargo test -p victory-gpu --lib -- slot_evict`: **7 passed, 0 failed** (1193 filtered). Note: this overlaps in `crates/victory-gpu/src/resource.rs` with #4433 (both hoist `NEXT_SLOT_MS`, add `over_budget` to `SlotJob`, guard `slot_look_aside` with `SLOT_HAS_READY`, and schedule backoff on empty `victims` / after `slot_apply`). Merging both would conflict in `resource.rs`. (#4466 uses `Relaxed` on `NEXT_SLOT_MS` and tests the pure helper without mutating global statics; #4433 uses `Acquire`/`Release` and also updates `sampled.rs` `sweep_cadence`.) *(AI-assisted build/unit-test check and diff review; game runtime not launched.)*
Author
Owner

@⁠YounesAH15 on GitHub · 2026-12-01 01:41 UTC · original

Before/After Comparison on RTX 3050 (8 GB, Series S, release build)

Tested the exact same machine on main (without this PR) vs this branch:

Build slot eviction aside looks Avg / Max scan time Notes
main (without PR #4466) 896 looks (~12 min session) 53.1 ms / 136.5 ms ~47.6 s spent spawning scan threads & contending on TEXTURES / SHADER_HEAPS locks
This PR (fix/8gb-vram-eviction) 16 looks (~4 min session) 45.0 ms / 89.9 ms Clean ~15.2-15.7 s backoff between empty scans (#2549)
**@⁠YounesAH15** on GitHub · 2026-12-01 01:41 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4465#issuecomment-7297791456) ### Before/After Comparison on RTX 3050 (8 GB, Series S, release build) Tested the exact same machine on `main` (without this PR) vs this branch: | Build | `slot eviction aside` looks | Avg / Max scan time | Notes | | --- | --- | --- | --- | | `main` (without PR #4466) | **896 looks** (~12 min session) | 53.1 ms / 136.5 ms | ~47.6 s spent spawning scan threads & contending on `TEXTURES` / `SHADER_HEAPS` locks | | This PR (`fix/8gb-vram-eviction`) | **16 looks** (~4 min session) | 45.0 ms / 89.9 ms | Clean ~15.2-15.7 s backoff between empty scans (#2549) |
github-bot force-pushed github-bot/gh-4465 from 0dc8c44959 to aeb0af47b9 2026-12-01 07:48:07 +00:00 Compare
github-bot closed this pull request 2026-12-01 18:43:31 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:41 UTC · original

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.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:41 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4465#issuecomment-7321340417) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4466
No description provided.