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

Closed
YounesAH15 wants to merge 1 commit from upstream-pr/4465 into main
YounesAH15 commented 2026-11-30 20:40:01 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by YounesAH15 on 2026-11-30T20:40:01Z.


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)
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5573364197 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4465). Originally posted by [YounesAH15](https://github.com/YounesAH15) on 2026-11-30T20:40:01Z. --- ### 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)
tikD1337 commented 2026-11-30 20:51:14 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tikD1337 on 2026-11-30T20:51:14Z.


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 #4432 (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. (#4465 uses Relaxed on NEXT_SLOT_MS and tests the pure helper without mutating global statics; #4432 uses Acquire/Release and also updates sampled.rs sweep_cadence.)

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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7291562009 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4465#issuecomment-7291562009). Originally posted by [tikD1337](https://github.com/tikD1337) on 2026-11-30T20:51:14Z. --- 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 #4432 (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`. (#4465 uses `Relaxed` on `NEXT_SLOT_MS` and tests the pure helper without mutating global statics; #4432 uses `Acquire`/`Release` and also updates `sampled.rs` `sweep_cadence`.) *(AI-assisted build/unit-test check and diff review; game runtime not launched.)*
YounesAH15 commented 2026-12-01 01:41:53 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by YounesAH15 on 2026-12-01T01:41:53Z.


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 #4465) 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)
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7297791456 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4465#issuecomment-7297791456). Originally posted by [YounesAH15](https://github.com/YounesAH15) on 2026-12-01T01:41:53Z. --- ### 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 #4465) | **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) |
trustno1-coder commented 2026-12-01 18:41:07 +00:00 (Migrated from github.com)

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


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:7321340417 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4465#issuecomment-7321340417). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:41:07Z. --- 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!4465
No description provided.