Skip to content

[pr-performance] [memory] [startup] [NVIDIA] Reduce texture memory pressure and cold-load stalls - #1794

Closed
dapasko wants to merge 17 commits into
trustno1-coder:mainfrom
dapasko:codex/victory-upstream-integration
Closed

dapasko wants to merge 17 commits into
trustno1-coder:mainfrom
dapasko:codex/victory-upstream-integration

Conversation

@dapasko

@dapasko dapasko commented Nov 29, 2026 •

Copy link
Copy Markdown

What it changes

This integration is based on d4b5d51. The commit history keeps the individual changes and credits the original PRs.

Area Changes
Texture streaming and VRAM Adaptive texture heaps and first-use priority (#1562). Charge the actual texture footprint on first upload (#1771). Keep VRAM reclamation active under host-memory pressure (#1772). Bound slot eviction to its sampled history and release the texture table before touching descriptors, with a check that the slot still shows the same host resource (adapted from #1763).
GPU scratch memory Return completed indirect-batch scratch buffers to a bounded shared pool (#1441). Keep indirect buffer bounds checks and the faster card-copy planning path.
Cold loads and pipeline cache Bound compute pipeline waits and leave compilation to workers (#1767, related to #628). Use memory-aware prewarming, avoid unnecessary shader cache reads, stream the pipeline book, and recover when the driver library cannot allocate its save buffer (#1173, #1489, #1651, #1678).
DirectStorage Pair nearby reads without bypassing status or fence order. Reuse worker buffers within a shared budget (#1596). The opt-in stall monitor also tracks paired reads (#1770).
Rendering Exact Wave64 folding on 32-lane NVIDIA hardware (translator commit from #1504), faster shader use lookup (#1569), a DLSS-only Present fix, and a two-plane fallback deadlock fix (#1459).

The due-frame texture index from #1497 is opt-in with VICTORY_DUE_INDEX=1. It uses the same first-upload and recheck priorities as the flat queue. Set VICTORY_DSTORAGE_STUCK_MS to enable the DirectStorage stall monitor.

How it was tested

  • Windows 11 Pro (build 26300), GeForce RTX 4060 8 GB, Rust 1.98.1.
  • Before and after on the same three cached shaders. The pre-integration executable created 2 of 3 D3D12 compute pipelines with VICTORY_HOST_WAVE=32. This branch created 3 of 3, including 6b82bc7d22016cb5, which previously reported no wave32 lowering.
  • DLSS. The standalone 2560×1440 Quality probe presented 120 frames with frame generation off and shut Streamline down successfully.
  • Code checks. The release build succeeded. cargo test --release --locked -p victory-gpu -p victory-hle --lib -- --test-threads=1 passed 568 GPU tests and 205 HLE tests. The checks cover texture byte accounting, simultaneous VRAM and host pressure, bounded compute waits, and parity between the flat and indexed texture queues.
  • The paired DirectStorage request test also passed with VICTORY_DSTORAGE_STUCK_MS=1, verifying that the monitor tracks and clears both requests.

Gameplay FPS, peak VRAM and time to reach a save still need a matched in-game A/B. The changes affect texture residency, pipeline scheduling and graphics resource lifetimes. They can be reverted without a save migration.

Checked for overlap

AI-assisted integration and verification. Hardware results above are from the submitter's Windows machine.

mikael-jarvinen and others added 17 commits November 29, 2026 02:50
… one instead of aborting the process

(cherry picked from commit 5d93fde)
Use the freshly translated shader if cache publication fails. Existing callers can still request a path, and cache publication remains atomic.

Co-Authored-By: Codex <codex@openai.invalid>
(cherry picked from commit 4fd7f4d)
…39f0 translate 25 s to 2.6 s)

(cherry picked from commit 12b4080)
A request's source, its zlib intermediate and the buffer of a write to
scattered pages were each vec![0; size], faulting in all their pages again
for every request. A worker now keeps up to three spare buffers of at most
32 MiB (VICTORY_DSTORAGE_BUFFERS, on), zeroed before reuse, and all workers
together keep at most 256 MB of them (VICTORY_DSTORAGE_BUFFER_BUDGET, in
megabytes, 0 for no bound): 16 workers by 3 by 32 MiB could hold 1.5 GB for
the run in a process the PC has little memory left for. A buffer that does
not fit is freed at the end of its request.

Tests: a spare buffer is reused (same memory), zeroed again, counted while
kept and not kept past the most a worker keeps; a worker keeps three spare
buffers at most; the budget bounds what all workers keep, counts a buffer
again when it leaves, and is no bound when 0.

(cherry picked from commit 5b7ce88)
…AVE_FOLDED, on)

Two console lanes per host lane: a 64-lane wave runs as one 32-lane host
wave, VGPRs in pairs, SGPRs shared, lane masks as two 32-bit ballot words
and the scalar control flow native. Ballots, readlane, mbcnt, LDS within a
group and lane masks behave as on the console. Programs that cannot be
folded keep the forms they had before.

On the shaders of this title (RTX 5070 Ti, before trustno1-coder#35, trustno1-coder#43 and trustno1-coder#52): "no
wave32 lowering" refusals 22 -> 1, 175 programs exact. In the opening
cutscene the staircase shadows on characters go, and moving characters no
longer leave dotted trails (they come back with VICTORY_WAVE_FOLDED=0).

Two faults found with the hair and fixed, with GPU tests:
- a VALU writing the SGPR pair it also reads (v_cmp_eq_i32 s[0:1], s0, v0):
  the high half now goes first, and a program whose halves overwrite each
  other's input is not folded;
- s_or_saveexec_b64 -1 reopening EXEC after lanes left through v_cmpx /
  s_cbranch_execz: branches on EXEC are taken wave-wide in such a program.
CS_HairTileClassify had both: beards and curly hair came out in patches.

VICTORY_WAVE_FOLDED_SKIP / _ONLY (name or hash prefixes) pick programs, for
bisecting. VGPR numbers are u16 (folded pairs pass 255): the new LDS
analysis of trustno1-coder#43 and the ray intersection add to them in u16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 8f0a0c2)
…in room-line admission

(cherry picked from commit f0c5d59)
A host list kept the scratch buffers of its busiest recording for good
(`batch_args` was only pushed to). With about 1,500 lists alive that was
12,719 buffers in eight minutes of play on an RX 7800 XT (16 GB) with
VICTORY_INDIRECT_BATCH=1: 3.2 GB of the card by the system's count
(256 KiB a buffer), past its budget, and 200 ms a frame on the card
from there. No counter saw them, so nothing could let them go.

Now a list gives them back when it is reset (every submission of it
has run, and its last recording left them in the common state), and
the next list to batch takes them, as scratch chunks and preludes
already do. 512 are kept; more than that are retired.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KfgN1FfW7f4Zv2hqXUsNr2
(cherry picked from commit e6bda10)
… own, not without limit (trustno1-coder#628)

trustno1-coder#243 made a dispatch make its compute pipeline on the asking thread, one
after another and with no limit. A fresh build's first start, with most
compute pipelines new, then held a frame past the title's 30 s watchdog
while it loaded and stopped with a null write at +0x23cf683: every first
start on 923e38c, bisected to the merge of trustno1-coder#243 (trustno1-coder#628).

A dispatch now waits as a draw does, in `wait`, with a budget of its own:
VICTORY_COMPUTE_WAIT_MS, 10 s a frame (the screen passes' 10 s beside it,
below the watchdog), while the workers make the pipelines side by side.
trustno1-coder#243's case, a compute program first met at a scene change taking a few
seconds, is still waited for, not dropped. VICTORY_PIPELINE_COMPUTE_WAIT=0
still means the draws' half second. A dispatch waited for more than half a
second is logged.

RTX 3090, i9-14900K, Series S, frozen save, fresh build each time:
- main d4b5d51: first start crashed at +0x23cf683 (7 of 7 on 923e38c-based builds)
- this: 3 of 3 first starts reached the world, 9-12 dispatches waited
  (the longest 10 s each); one more start sat at the menu (no input)
- victory-gpu tests: 550 passed (the test that expected trustno1-coder#243's inline make
  now expects the budgeted wait)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit e60fe0e)
Adapt the eviction fixes from trustno1-coder#1763. Pin the guest texture and the host copy through descriptor eviction, and recheck the slot before clearing it.
…N ms once, by stage (not submitted, not started and what holds it, running, status held behind earlier reads, enqueue waiting on a full queue), and again with its whole age when it moves on (off by default; for the 30 s load stalls)

(cherry picked from commit 85c7e51)
@dapasko dapasko changed the title Codex/victory upstream integration [pr-performance] [memory] [startup] [NVIDIA] Reduce texture memory pressure and cold-load stalls Nov 29, 2026
@dapasko dapasko closed this Nov 29, 2026
@dapasko
dapasko deleted the codex/victory-upstream-integration branch November 29, 2026 01:00
@richards2002

Copy link
Copy Markdown

Tested on a 16 GB card, since the description's testing was on an 8 GB RTX 4060.

System: RTX 4080 16 GB, driver 621.40 · Intel i5-10400, 32 GB · Windows 11 build 26300
Build: this PR's head ab574d0, plus one local commit that keeps frame generation on over movies while a scene is upscaled (the head does not have 9e61270 / #1579 from main). Release build, cargo build --release --locked -p victory.
Baseline: main at d459907 with the same frame generation commit.
Settings, both runs: Series X, 1440p native, DLSS Quality, DLSS frame generation 2x, preloaded (victory preload), the same prologue area, free roam outdoors and indoors.

One run each, and the routes were not identical (draws a frame averaged 6,406 in the baseline and 4,433 here), so treat the fps numbers as indicative.

In the world (frame lines with > 1,000 draws) baseline this PR
Minutes 16.6 14.8
fps rendered, average / median / lowest 10 % 10.6 / 9.7 / 5.9 12.2 / 12.6 / 7.2
Submitting thread, ms a frame 103.7 78.0
Of which refreshes 37.2 30.8
Texture refreshes, all threads, ms a frame 20.8 22.6
Draws dropped without a host pipeline 6.8 % 7.9 %
Textures waiting, average / peak 15,541 / 28,273 13,469 / 35,711
"card has no room" lines a minute 38.7 0
Texture uploads a minute 1.5 GB 2.3 GB
DLSS: the upscaling was not recorded: ... out of VRAM (39) 5,492 (from 9 minutes in) 0
DLSS-FG frames shown per frame rendered while on 0.95 1.9
Warnings in all / errors 13,431 / 0 1,474 / 0

The clearest result is the last rows: in the baseline the card went over its budget about 9 minutes in, and from then on DLSS failed with "out of VRAM (39)" (the output keeps what it had) and frame generation stopped producing frames. With this PR neither happened in 14.8 minutes, and frame generation showed 1.9 frames for each one rendered.

The texture queue is busier (more uploads a minute, a higher peak waiting) but never logged "no room".

One thing for the rebase: on this head, without the movie gate change from main (9e61270), the gate held every present in the world (a looping Bink video was open the whole time). With a frame generation over movies change on top, every one of those presents generated. So frame generation stays off in the world on this head as it is, until it is rebased onto main.

Logs available if useful: victory-nvidia-play-20261128-234051-28348.log (baseline) and victory-nvidia-play-20261129-010121-17492.log (this PR).
victory-nvidia-play-20261128-234051-28348.log
Uploading victory-nvidia-play-20261129-010121-17492.log…

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.