Skip to content

victory-gpu: start slot eviction when the card is over its budget - #3454

Open
Cooperos wants to merge 1 commit into
trustno1-coder:mainfrom
Cooperos:slot-evict-over-budget-v5
Open

Cooperos wants to merge 1 commit into
trustno1-coder:mainfrom
Cooperos:slot-evict-over-budget-v5

Conversation

@Cooperos

@Cooperos Cooperos commented Nov 29, 2026 •

Copy link
Copy Markdown

What it changes

The slot_evict plan subtracted the free ranges of the placed blocks from
the card's use whatever the budget said (resource.rs). The over_budget
branch right below it (idle 3 s, cap 768 MB) was therefore dead code: with
enough block space free, the plan weighed the use under its high line while
the card sat past the driver's budget, and never turned on.

This change makes that branch reachable: at or over the budget the plan
weighs the card's use as it is; under the budget the subtraction stands (a
new placement reaches the free ranges without a new block, so evicting
there would only churn). It mirrors the direction VICTORY_ROOM_REAL
(v2026.11.29.05, foxhound 4349ab56) already takes on the placement side of
the same free-in-blocks accounting.

What it does not do

It is not a fix for the 0x80070057 crash family:

  • In the one over-budget session where this trigger engaged (v2026.11.29.04
    base, card at 7,805/7,148 MB, VICTORY_SAMPLED_EVICT=0), the pass let go
    20 copies (4.8 MB, interval sums) - its candidates were
    indexed-slot-blocked - and the run still ended on 0x80070057.
  • With VICTORY_SAMPLED_EVICT=1 on main, the sweep keeps the card under
    budget in an 8 GB city bench (@nick0451: 0 % samples over, ~1.2 GB less,
    no fps loss), so the trigger rarely engages there.
  • A same-release prologue A/B (save reset, single run each) was
    inconclusive: main crashed with the card under its budget the whole run,
    so the differing factor was not this trigger - that crash belongs to the
    still-open invalid-command family (Texture copies the host does not take are left out instead of ending the run (0x80070057) #3678 was closed "not the cause").

What it does change: in the state the v2026.11.29.03 run died in (card at
7,261/7,064 with 1,698 MB free in blocks, the plan weighed 5,563 MB against
a 6,004 MB line and read "not evicting" to the end), the plan now turns on.
Whether the pass then finds takeable candidates depends on
VICTORY_SAMPLED_EVICT and on what is evictable at that moment - this PR
and that switch are the two halves of one gate.

How it was tested

  • cargo test -p victory-gpu --lib: 914+ passed + the new
    slot_plan_used_ignores_block_room_only_when_the_card_is_over_its_budget.
  • Release and diagnostics builds compile (cargo build --release --locked -p victory; the diag tree here also carried the copystat/timing fixes
    that have since landed in 41adb551).
  • Shader wave sizes: N/A (no shader changes).
  • Rig behind the runs cited: RTX 3070 Ti 8 GB, driver 610.88; Series S,
    scene 1280x720, DLSS quality, frame generation off; Ryzen 7 5700X,
    64 GB, Windows 11 26H2.
  • Measurement note: the "since the start" cumulative line resets with the
    interval logger (GPU: report slot eviction totals and whole texture blocks let go #3766 fixes it) - the numbers above come from summing
    the "slot eviction since the last line" interval lines.

Checked for overlap

#2591 (sweep eviction under host RAM pressure) and #2549 (bounds the sweep,
backs off empty slot_evict passes) are complementary; #2778's analysis
(unmapped_only, slot keyspaces) does not cover this trigger;
VICTORY_ROOM_REAL (v2026.11.29.05) covers the placement side.

The plan subtracted the free ranges of the placed blocks from the card's use whatever the budget said. The ranges are committed memory either way: the driver's budget is spent on them, and only letting a texture go - and, in time, its emptied block - gives memory back. With enough block space free, the plan could weigh the use under its high line while the card sat past the driver's budget, and the over_budget idle and cap right below never came into play. On an RTX 3070 Ti 8 GB (Series S, DLSS quality, no frame generation, 2026-11-29) the card sat at 7,261 MB of a 7,064 MB budget with 1,698 MB free in blocks, the plan weighed 5,563 MB against a 6,004 MB line ('not evicting') to the end, and the run ended on 'a host command list did not close (0x80070057)' (trustno1-coder#2778).

Under the budget the subtraction stands: a new placement reaches the free ranges without a new block, so evicting there would only churn.
RitonDJ added a commit to rubenalkapov/VIctory-NVIDIA that referenced this pull request Nov 29, 2026
Mise à jour du 30/11 à 0h50 : éviction des textures quand la carte dépasse son budget (trustno1-coder#3454)
ForthtuN added a commit to ForthtuN/VIctory-NVIDIA that referenced this pull request Nov 30, 2026
…criptor churn

Integrate trustno1-coder#3475 with tested 60s held-texture grace and opt-in expensive census; trustno1-coder#3454 real over-budget eviction; trustno1-coder#2234 idle snapshot reclamation adapted to idle list trim; trustno1-coder#2956 cap descriptor sync; trustno1-coder#2607 advance unmatched remap cursor; trustno1-coder#3503 normalize descriptor footprint cache keys. Preserve shader translator, cache keys and settings.
@nick0451

nick0451 commented Nov 30, 2026 •

Copy link
Copy Markdown

Test on an emulated 8 GB card. This change isn't reached in this scene, so these runs neither confirm nor rule it out. The numbers on main may still be useful.

Setup

  • RTX 3090 24 GB with VICTORY_VRAM_BUDGET_MB=6800, i9-14900K, 32 GB (corrected; I first wrote 64 GB) RAM.
  • Series S, the bench settings, frame generation and RT off.
  • A frozen city-street save, standing with a tap every 25 s, 20 min per run.
  • Window kept off screen (VICTORY_WINDOW_OFFSCREEN=1), and VICTORY_COMPILE_MEMORY=0 because of the Pipelines: driver compiles are admitted by memory, and put off rather than refused #1625 start stall.
  • victory play defaults, so VICTORY_SLOT_EVICT=1.
  • v2026.11.29.05 (41adb551) against this PR (a466fcb0), alternating, 2 runs each.
run "memory now" samples with the card's own use over the 6,800 MB budget highest at the end commit at the end mean fps
main, run 1 44 % 7,779 MB 7,766 MB 26,500 MB 17.6
this PR, run 1 86 % 7,992 MB 7,987 MB 25,789 MB 16.2
main, run 2 68 % 8,121 MB 8,121 MB 26,197 MB 17.2
this PR, run 2 80 % 8,294 MB 8,289 MB 26,324 MB 17.8

In all four runs the slot eviction line reads since the start: 0 textures (0 MB), and the queue of textures picked by index is empty ("0 slots"). This scene has no slot-picked textures for the pass to let go, so the plan's weighing never matters. The difference between the rows is run-to-run spread (main alone ranged from 44 to 68 %).

What this does show, for #191's 8 GB case: main ends 1.0–1.5 GB over its 6,800 MB budget in the city, and nothing there gives the memory back. I'll follow up with VICTORY_SAMPLED_EVICT=1 (the sampled marks are on by default in victory play, the eviction isn't) on the same runs.

🤖 Generated with Claude Code

@tyr0nsur

Copy link
Copy Markdown
Contributor

Additional 8 GiB data point on v2026.11.29.05. Desktop RTX 4060 (621.14), Ryzen 7 5800X, 31.9 GiB RAM, Windows 11 26H2. Series X at 2560×1440, DLSS Ultra Performance, 2× frame generation with MFG Unlocker, RT off.

  • DXGI local usage peaked at 7,292 MiB against 6,821 MiB. Shared GPU memory peaked at 9,353 MiB.
  • The texture queue reported no room in 12 of 17 samples. Across 11 scene intervals with at least 500 draws/frame, the queue peaked at 24,269 waiting slots and median base FPS was 15.3.
  • Slot eviction reported evicting and had released zero textures. At the last logged sweep, 21,130 textures looked idle and 14,129 were protected by bindless slots. Sample marks were on and sampled eviction was off.

This is from the release build before applying this PR. It provides another case to test candidate eligibility once the budget trigger is active. The next comparison is sampled eviction off/on with the same save and route, tracking evicted bytes and how many pool blocks return to the driver.

JustOptimize added a commit to JustOptimize/VIctory-Enhanced that referenced this pull request Nov 30, 2026
…rustno1-coder#3454)

Port of trustno1-coder#3454, applied clean. The slot_evict plan subtracted the free ranges of the placed blocks from the card's use whatever the budget said, so with enough free block space it never evicted while the card sat past the driver's budget; now over the budget the plan weighs the full use (under it the subtraction stands). Upstream: RTX 3070 Ti 8 GB, a 42-minute run without a crash with VICTORY_SAMPLED_EVICT=1; the unit tests only otherwise. Changes when eviction starts on this PC (eviction is on by default here).
JustOptimize added a commit to JustOptimize/VIctory-Enhanced that referenced this pull request Nov 30, 2026
@nick0451

nick0451 commented Nov 30, 2026 •

Copy link
Copy Markdown

A correction to my comment above, and a follow-up.

Correction. I wrote that this scene "has no slot-picked textures for the pass to let go". That was wrong: I read the upload queue's "0 slots" line. On main in this scene the sampled-marks line shows 31,924 textures shown by a slot that shaders pick by index, and 26,751 of them (1,969 MB) marked by no shader within the idle time. Slot eviction let go of 0 because victory play sets VICTORY_SAMPLED_MARKS=1 but VICTORY_SAMPLED_EVICT=0, so marked-idle textures are never released. Not because there was nothing to let go. The conclusion for this PR still stands: it didn't change anything measurable in these runs. My reason for it was wrong.

Follow-up, same setup as above: emulated 8 GB card (VICTORY_VRAM_BUDGET_MB=6800), city save, 20 min per run, v2026.11.29.05 41adb551, alternating.

run samples with the card's own use over 6,800 MB highest end commit at end mean fps
main, run 1 68 % 8,056 MB 8,051 MB 26,353 MB 18.9
main + VICTORY_SAMPLED_EVICT=1, run 1 0 % 6,796 MB 6,794 MB 25,043 MB 18.9
main, run 2 67 % 7,991 MB 7,987 MB 26,235 MB 18.7
main + VICTORY_SAMPLED_EVICT=1, run 2 0 % 6,706 MB 6,706 MB 24,843 MB 19.8
  • With sampled eviction on, the card never passed its budget in either run. That is about 1.2–1.3 GB less on the card and 1.3–1.4 GB less commit at the end, with no loss in frame rate.
  • What it costs: in 20 minutes it put 93,000–105,000 slots back to null, and 61,000–70,000 of them were queued again when a shader read them later. That is reload churn, which could show as brief pop-in or a texture going black for a moment.
  • These runs took no screenshots, so I haven't checked for pop-in yet. I'll run a picture comparison at 8 GB before calling it safe as a default for small cards.

No crashes in any run. RTX 3090 with the budget capped, i9-14900K, 32 GB (corrected; I first wrote 64 GB), Series S, window off screen.

🤖 Generated with Claude Code

@tyr0nsur

Copy link
Copy Markdown
Contributor

Follow-up on my earlier “zero textures” observation. The periodically reported “since the start” value was reading counters reset by the interval logger, so that line cannot establish how many evictions occurred in a session. In a later RTX 4060 Series S capture with sampled eviction enabled, summing the interval lines gave 175,338 host copies let go, 101,925 made again, and 9,738 made again within two seconds. These counts describe slot churn. The telemetry PR #3766 fixes the cumulative log and adds a measurement for whole heap blocks released by the texture pools.

@Cooperos

Copy link
Copy Markdown
Author

Follow-up on my earlier “zero textures” observation. The periodically reported “since the start” value was reading counters reset by the interval logger, so that line cannot establish how many evictions occurred in a session. In a later RTX 4060 Series S capture with sampled eviction enabled, summing the interval lines gave 175,338 host copies let go, 101,925 made again, and 9,738 made again within two seconds. These counts describe slot churn. The telemetry PR #3766 fixes the cumulative log and adds a measurement for whole heap blocks released by the texture pools.

confirmed on my side: summing the interval lines instead of the
cumulative one gives 194,814 let go / 119,774 made again in a 32-minute
fixed-build prologue run - the same order as your capture. Your telemetry
point stands, and it corrects my own earlier "0 let go" reading twice over.

@Cooperos

Copy link
Copy Markdown
Author

Updated the description above. In short, per @nick0451's correction and
@tyr0nsur's telemetry finding:

  • the PR no longer claims to fix the 0x80070057 crashes. In the one
    over-budget run where this trigger engaged, the pass let go 20 copies
    (interval sums) - its candidates were indexed-slot-blocked - and the run
    still ended in the crash; with VICTORY_SAMPLED_EVICT=1 on main, the
    sweep already keeps the card under budget in the 8 GB bench;
  • what remains is the narrow accounting fix: the plan's over_budget
    branch (idle 3 s, cap 768 MB) was unreachable while free block ranges
    were subtracted from the card's use; now it is reachable at or over the
    budget, mirroring what VICTORY_ROOM_REAL does on the placement side;
  • the numbers in the description come from summing the interval lines -
    the "since the start" cumulative one cannot be used to judge the pass
    (GPU: report slot eviction totals and whole texture blocks let go #3766 fixes it).

@nick0451

Copy link
Copy Markdown

Follow-up on VICTORY_SAMPLED_EVICT=1: the picture check I said I'd do.

Setup: same emulated 8 GB card (VICTORY_VRAM_BUDGET_MB=6800), city street, v2026.11.29.05. 10 min per run, two runs each with and without, alternating. A window shot every minute from minute 3 to minute 9, after the card has filled and eviction is at work.

Result:

  • With eviction on, the street, the parked SUV, the character's shirt, signs and buildings look as sharp as without it, in every one of the 14 shots.
  • No black or blurred surfaces.
  • The grey-level difference between a run with eviction and one without (13–22) is close to the difference between two runs of the same kind (10–17). That gap comes from traffic and clouds.
  • No crashes.

Not covered: these are stills a minute apart while standing. A texture that reloads in under a second, or pop-in while turning the camera, wouldn't show. In the 20-minute runs above, 61,000–70,000 slots were queued again after being let go, so a check while moving would be the next step.

🤖 Generated with Claude Code

PranThow added a commit to PranThow/VIctory-NVIDIA that referenced this pull request Nov 30, 2026
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.

3 participants