Skip to content

GPU: speed work for Radeon and 32 GB hosts (buffer reuse, burying thread, fills through placed copies) + measured switches - #1044

Open
imad7x wants to merge 22 commits into
trustno1-coder:mainfrom
imad7x:amd-speed-patches
Open

imad7x wants to merge 22 commits into
trustno1-coder:mainfrom
imad7x:amd-speed-patches

Conversation

@imad7x

@imad7x imad7x commented Nov 28, 2026

Copy link
Copy Markdown

22 commits on top of 63b902f: speed work for a Radeon card on a 6-core CPU with 32 GB of RAM. Three changes are on by default and each has a switch back; the rest are live switches and counters that are off by default. Please take what is useful: I can split this into smaller pull requests or drop the switches.

Tested on

One machine only: i5-12500, 32 GB DDR4-3200, RX 7900 GRE 16 GB, Windows 11, 1440p output. Upscaling and frame generation 2x go through OptiScaler. Every number below is the rendered frame time in the opening prison room (about 5,800 draws), not the open world. No NVIDIA card was tested.

On by default

Change Switch back Measured
A fill inside a copy placed earlier in its list reads that copy's source VICTORY_FILL_THROUGH_PLACED=0 submitting thread's wait 24.3 -> 2.7 ms a frame; frame 56.9 -> 53.8 ms
Retired objects are dropped by a thread of their own (victory-bury), handed over by a channel VICTORY_BURY_ASIDE=0 landing thread 46.5 -> 17.7 ms a frame; frame unchanged on its own
Upload and shared buffers are kept for reuse when their last holder lets go lab switch reuse=0 with limited_host_ram() (32 GB): slow destroys 84 -> 12 a frame, frame about 53 -> 50 ms
Fills look for a placed copy only in lists that have one none about 11 ms of CPU a frame less on the list threads
Streamline saying its plugins already have a device is no longer fatal at the hand-over none needed when OptiScaler creates the device first
DirectStorage workers below normal priority and the reflection stand-in's depth (from foxhound), plus a fat-LTO lab profile none not measured separately

Over these changes the same scene went from about 57 ms to 45.6 ms on the older base (959dcaf, native 1440p). On 63b902f it runs 43.0 ms (23.2 fps) without ray tracing and 55 to 59 ms with it.

Off by default (live switches read from VICTORY_LAB_FILE)

  • w: the title's fence waits are woken when the card answers. -0.4 ms while the card is the limit, nothing otherwise.
  • p: the submitting thread (and with 2 its helpers) at priority "highest". About -1 ms with p=2.
  • spin, once: the guards' lock. All threads' waits at it 58 -> 20 ms a frame; frame -0.3 ms, inside the noise.
  • q: a refresh that copies nothing learns so with no lock taken. Refreshes on helper threads 8,500 -> 2,900 a frame; frame unchanged.
  • seal: private ranges of 16 MB and more that stayed clean for 2 s are made read-only instead of asked about, by 64ths. Write-watch asking 11.6 -> 8.7 ms a frame with ray tracing; frame -0.5 ms because the card is the limit there. Three tests in watch::seal_tests.
  • gap, u, hot, own, wide, lists: measured slower or no gain. Kept only so the result can be reproduced.
  • cyc, t, frames, g, h, nf, cut: counters, traces and the statistics lines used for the numbers above.

What I found, in case it helps others

  • On this CPU the submitting thread is the wall without ray tracing: it works about 37 of 42 ms a frame and the card idles about 6.5 ms behind it. With ray tracing the card is the wall (94 to 98 % busy), so CPU savings do not reach the frame.
  • With ray tracing, about 22 title buffers of 64 MB are asked whole by four submissions a frame (about 7 ms of write watch).

Not verified

  • cargo clippy -- -D warnings was not run locally. The branch was built with cargo check and the lab profile, and the watch:: module's tests pass.
  • Single runs repeat to about 0.6 ms without ray tracing and about 3 ms with it.

🤖 Generated with Claude Code

imad7x and others added 22 commits November 28, 2026 17:28
… reflection stand-in's depth; a fat-LTO play profile

From readmet3xt-lab/foxhound 454ffea (dstorage.rs, draw.rs), applied unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… copy's source (the bytes it gets anyway)

With flights in the air such a fill read the copy's destination, so the submission waited for every
flight (card steps refused it: BEHIND_PLACED, 0.2-0.65 a frame, 5-24 ms of waiting in runs 27-30).
VICTORY_FILL_THROUGH_PLACED=0 turns it off; the frame block counts what was read through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…thread that lands flights

VICTORY_BURY_ASIDE=0: as before. What the dropping costs is in the frame-rate block.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… holder lets them go

Switches from a file while the title runs (VICTORY_LAB_FILE), memory made counted by the place that asked,
last references dropped counted by what they were.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ts for; fills look for a copy at its place only in lists that have one

Also: stages slowed by a switch (b, c, d, e) to find which one a frame waits for; the helpers' waking spin by switch a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… itself when a value or fence is there

Switch f=1: as before (the helper thread, after resetting the landed lists). Also: the line's waits and the draws in
the lab line, scratch chunks used again unzeroed, a list's upload buffers in sizes that come again,
VICTORY_LIMITED_RAM to say whether the PC's memory is short.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ty of the translating threads and of the landing thread by switches g and h

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…switch w); presents in the line by switch frames; a trace of a frame (switch t); the write watch's askings and what the line stood at, counted

The title waits for our fences with monitorx/mwaitx and Sleep(0) between
looks; on an Intel processor those instructions are a pause, so its render
thread went round that loop about 50,000 times a frame (run 40). With w=1
the sleep of such a loop waits until a fence is set or a value written
behind a flight. The trace (t=<frames>) writes what the title, the line,
the flights and the landings do, with their times, to the log.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D2kQMUumNuQVLeC5nJg148
…ne on from at our hand-over (AMDNR gives it the device first)

With AMDNR (an OptiScaler build) loaded as dxgi.dll, its hook of
D3D12CreateDevice gives Streamline the device before slSetD3DDevice of
ours, which then answers invalid integration (19); DLSS and frame
generation were left off for it. VICTORY_SL_DEVICE_STRICT=1: as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D2kQMUumNuQVLeC5nJg148
…he heaviest commands' notes whole; the upscaling has a name of its own

Diagnostics build only (VICTORY_GPU_TIMING): the card's time by the size written (a draw's viewport and target,
a compute pass's largest texture written), every fourth frame line the longest note of each heavy command in full
(what it binds, at what size), an indirect dispatch's group counts as title memory has them, and notes around the
Streamline upscaling (inputs, the upscaling, its end). Runs 45 and 46.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D2kQMUumNuQVLeC5nJg148
u=1: a write fault of the title's opens its block without the guards'
lock (as VICTORY_FAULT_UNLOCKED=1). hot=<ms>: a block written again and
again is left open that long (as VICTORY_GUARD_HOT). own=1|2: the
submitting thread on the last physical core alone, or with the landing
thread beside it; every other thread on the other cores.

Static room, DLSS Quality + frame generation 2x through AMDNR, at equal
draws against the plain periods of the same run: u=1 +0.9 ms, hot=50
+2.2, both +3.3 (run 49); own=1 +3.7, own=2 +4.2, own=1 with w=1 +7.4
(run 50). Nothing here changes what the build does with the switches at 0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D2kQMUumNuQVLeC5nJg148
…translating threads are in use; measured, no gain; 0)

shadow.rs: eight threads are made for work spread over threads and
wide_threads() of them are in use: VICTORY_WIDE_THREADS (1 to 8, as
foxhound 9f8838b names it) or lab switch wide; the default stays a
quarter of the logical processors, 2 to 6. A thread out of use looks
again every 100 ms and passes a wake-up on.
list/thin.rs: twelve threads are made and in_use() of them take work:
VICTORY_THIN_THREADS or lab switch lists; the default stays eight.

Run 51 (static room, DLSS Quality + frame generation 2x): wide=2, 4, 6
and lists=5, 6, 11 within 0.4 ms of the plain periods beside them (the
noise between plain periods); wide=1 +0.7 ms.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D2kQMUumNuQVLeC5nJg148
…by part of its work (switch cyc), and its waits inside its work by name

Run 51's thread table had the submitting thread on a processor 28 ms of a 45.6 ms frame while it counts
41-44 ms as work. lab.rs: `cycles` (QueryThreadCycleTime of the submitting thread, with switch cyc=1),
`on` / `piece` / `waited_for`, and `on_line`, which writes two lines a second: "the submitting thread's waits
inside its work per frame" (every run: its time on a processor, its waits for the helpers at the end of work
spread over threads, for the guards' lock, the journal, ranges asked about, two descriptor locks; work spread
over threads, the kernel's write watch and blocks made read-only by the clock) and, with cyc=1, "the
submitting thread on a processor per frame" (each part of host.rs's split: ms by the clock / ms on a
processor). host.rs `Split` counts cycles with its parts; shadow.rs `wide`, watch.rs `waited`,
`kernel_written`, `protect`, descriptor.rs `waited` tell the lab. At cyc=0 the exe does what 85502be did
but for a few clock reads at waits. Measured in run 52: cyc=1 costs nothing that shows (+0.07 ms).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D2kQMUumNuQVLeC5nJg148
…with 2 its helpers as well; 0: as made)

The title asks "highest" for some twenty threads of its own; the submitting thread is made above normal and is off a
processor 15 ms of a 45 ms frame inside its work (run 52). Run 53 compares p=1 and p=2 with plain in the room.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D2kQMUumNuQVLeC5nJg148
spin=<microseconds>: a thread that finds the guards' lock taken asks for it
again and again for so long before it sleeps (watch::guards_taken). once=1: an
asking that guards view memory keeps the lock from its look at the range to
what it makes read-only, where there is no hole to ask Windows about between
them (watch::guard). The lab line of the submitting thread's waits also has
every thread's waits for that lock.

Run 53 (the system's record of thread changes, p=2): the submitting thread
waits for the lock 13 times a frame, 1.0 ms asleep and 1.1 ms with no
processor after the wake; its four helpers 39 times, 2.8 + 1.3 ms. Who holds
it changes one protection, some 13 microseconds.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D2kQMUumNuQVLeC5nJg148
…the costliest large ones by place (the lab line)

With the title's ray tracing on (VICTORY_BVH_BUILDER=1) the submitting thread asks about 26 GB a frame in place of
1.7 GB (runs 58-59: 12.1 ms against 3.6 ms): this says which ranges.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e asking of the write watch still covers; 0: 8)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… halves at once for ten seconds (switch nf=1: as made); switch cut=1 counts what the refreshes inside the asked spans of 8 MB and more cover (the lab line "spans")
… lock taken, and before a thread is woken where a flush has very many (switch q=1: as made); the askings of 64 MB and more by the pages they found written (the lab line)
…watch found clean for two seconds are made read-only and not asked about until a write faults into one (switch seal=1; 0: as made); switch q is off unless asked for
…e alone; an asking of a sealed range asks about its open chunks, and one clean for two seconds is sealed again
465d6a0eac added a commit to 465d6a0eac/VIctory-NVIDIA-Experiment that referenced this pull request Nov 28, 2026
@Exopus-0x65f7ad0

Copy link
Copy Markdown

An NVIDIA run, since the PR says none was tested.

Setup: RTX 5060 Ti 8 GB, 16 GB RAM, Windows 11 26300, native D3D12 (no OptiScaler: VIctory's own Streamline DLSS). Base: 63b902f plus a few local commits, with this PR merged (it merged cleanly). Default switches only, so the three on-by-default changes apply. README launcher defaults: Series X, native 1440p, DLSS Quality, no frame generation. Opening prison room, same save each time, a 90 s scripted walk. The card is GPU-bound and VRAM-full on this scene (no room most of the run), so this is not where CPU savings show best.

Frame lines from the log, every 5 s, counting only lines with ≥ 4,000 draws (the walk and cutscene, not the load):

baseline (no PR) another PR's run (#991) this PR
frame lines 85 74 77
fps, median 15.7 16.0 16.7
ms/frame, median / p90 / p95 63.7 / 85.4 / 87.4 62.3 / 83.8 / 127.9 59.8 / 79.7 / 83.8
"preparing" ms, median / p90 36.1 / 61.8 38.9 / 59.4 38.6 / 58.3
5-s windows over 200 ms/frame 4 2 1
worst 5-s window 4,474 ms 3,841 ms 2,025 ms
  • Steady state: about +6 % on the median, which is within run-to-run noise for one run each on a GPU-bound card. The "preparing" median barely moves here.
  • Hitches: the clearest difference. Fewer and shorter long windows during the walk and cutscene. That fits the bury thread taking drops off the landing thread, and buffer reuse cutting slow destroys. One run each, though.
  • Stability: no new warning kinds and no crash. The single ERROR (Streamline presentCommon() was not observed) appears in the baseline runs too.
  • The Streamline hand-over change was not exercised: there's no OptiScaler here, so Streamline creates the device itself.

I'd be happy to repeat with the on-by-default changes switched off one at a time (VICTORY_FILL_THROUGH_PLACED=0, VICTORY_BURY_ASIDE=0), if that helps you decide how to split the PR.

@tippythetaidum

Copy link
Copy Markdown

One data point for the fill-through-placed commit alone (e9bda4c), on NVIDIA. RTX 5080 + Ryzen 7 9800X3D, 32 GB, Windows 11 26200. It was cherry-picked onto 63b902f with #1014 and #393. Series X 2560x1440, DLSS Quality, frame generation off, indoors, the same save restored each run.

I used one process and a local switch that turned fill_through_placed off every other 30 s, so both sides saw the same scenes. That gave 4 minutes, with 5-second frame lines cut at the switches:

fill through placed copies off
submitting thread, preparing (median) 29.5 ms 30.8 ms
fps (mean of the lines) 18.3 17.8

That's about -1.3 ms on the submitting thread here, no errors, and no visual difference seen. (This PC was paging during that run, so the absolute rates are low.) I didn't test the rest of the PR.

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