GPU: a bench of preparation over synthetic title memory, with no title or window (host::prepbench) #3820
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3820"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by voidharbor on 2026-11-30T08:22:39Z.
Refs #2415
What it changes
Preparing a submission (asking the write watch what the title wrote, refreshing the copies, sending them to the card) can today be timed only by playing the title. #2415 measures each change with game runs of 300 to 660 seconds, and the audit says the same in 4.3 (
docs/unified-memory-audit.md): "No test drivesHost::submitend to end", andvictory replayprepares nothing.This adds two ignored tests in one new file,
crates/victory-gpu/src/host/prepbench.rs, that drive that code over synthetic title memory with no title, no window and no game files:host::prepbench::preparation_without_the_title, CPU only: the realBatch::addandBatch::flush,watch::ask_once, the write watch and the guards' fault handler, with copies of the test's own (Shadow::unbacked).host::prepbench::submission_without_the_title: the same frames as host lists of refresh steps, sent through the realHost::submit(Host::execute_own) on the PC's card, with copies the runtime makes (shadow::register,shadow::find). It prints the frame line's split of the submitting thread for each scenario. The crate's tests run with the relay off, and then no submission lands: every send keeps its upload memory and its list, and the split's "card copies" grows to 17 to 34 ms a frame of buffers never given back. So withVICTORY_RELAYunset this test runs itself again in a child process withVICTORY_RELAY=2, the title's default. With the relay off it prints a line saying what that row then measures.The memory, all made by the test at run time: 3,000 copies of 224 KiB in write-watched private memory; 1,400 copies of 224 KiB in a section shown at two addresses (views of 64 KiB in a placeholder, as the CPU-less pool is, and one alias view), both told to the runtime with
title_memory_sectionandtitle_memory_view; one 174 MB copy of another section, shown the same two ways. A simulated frame is 30 submissions: the first refreshes every copy, the other 29 refresh 157 random copies each, and the first 20 also the 174 MB copy (8,973 refreshes a frame). Between submissions the test writes 1% of the 64 KiB pages, one 8-byte word each, at the primary address or through the alias. Writes into guarded blocks fault into the runtime's own handler. Six scenarios: nothing written, 1% at the primary address, 1% through the alias, and the same three for the 174 MB copy alone, 20 times a frame.For each scenario it prints refreshes, refreshes known unchanged, MB looked at, MB compared (
VICTORY_SEND_CHANGED=1only), MB taken into copies, MB that would go up (CPU bench), write faults at primary addresses and through aliases, ms of preparation (mean and best frame), ns per refresh, and copies stale after a last full refresh. Stale must be 0 or the test fails: every copy's CPU side is compared with title memory, and in the card bench a compute pass also compares the card's words of copies in its memory with their CPU sides (upcheck's existinglook). Each row is also a CSV line that carries everyVICTORY_*variable set, so two runs can be diffed.How to run it
or the built test executable with the arguments after
--, one bench per process. Each run takes a few seconds and makes about 1.1 GB of title memory and as much again of copies. Switches are read once a process, so an A/B is two runs, with the switch set for the second.Knobs (the bench's own):
VICTORY_PREP_FRAMES(12, of which 2 are warm-up),VICTORY_PREP_PERMILLE(10, that is 1% of pages written a frame),VICTORY_PREP_VIEW_KB(64; 0 for one view),VICTORY_PREP_ONLY(part of a scenario name),VICTORY_PREP_WRITERS(0; threads that keep writing the scenario's memory while submissions are prepared) withVICTORY_PREP_WRITE_US(20). For the card bench,VICTORY_RELAYas above.Results on this PC
Upstream main
41adb551with this change. Ryzen 7 9800X3D, RTX 5070 Ti 16 GB, 64 GB DDR5-4800, Windows 11. Release test binary, no switches set (the card bench setsVICTORY_RELAY=2itself). Median of three runs. ms of preparation a simulated frame, mean of 10 frames, with the best frame in brackets.Stale was 0 in every row of every run, with all 4,401 copies checked. Known unchanged: 8,948 and 8,758 of 8,973 (CPU bench), 8,897 and 8,706 (card bench). Faults count only guarded memory; writes to write-watched memory do not fault. In the card bench's full frames, asking is about 5.6 ms of the total, the lists' steps 1.1 to 2.3 ms, card copies under 1 ms and sending 0.7 to 0.9 ms. The PC was doing other work at the time: two CPU runs and three card runs read 20 to 45% higher and were repeated.
What the numbers can and cannot stand for
They can compare the cost of the refresh, write watch and guard code on one memory shape before and after a change: ms and ns a refresh, faults, bytes taken and compared, and whether the copies are still right (the stale check).
They do not model:
VICTORY_PREP_PERMILLEto bracket it);VICTORY_PREP_WRITERSis a crude stand-in and off by default, so the lock contention #2415 describes is mostly absent here;So it is a comparator for A/B of that code, not a predictor of frame time in the game. In the card bench the runtime places the copies itself: here all but the 174 MB copy stay in PC memory, so fewer copies have a card side than in the CPU bench (1 against 1,401), and its "MB up" column is 0 because the sends happen inside the submissions.
What it touches
crates/victory-gpu/src/host/prepbench.rs: new, test builds only.crates/victory-gpu/src/host.rs:#[cfg(test)] mod prepbench;.crates/victory-gpu/src/shadow.rs:SENDispub(crate), to read bytes compared without the diagnostics build.crates/victory-gpu/src/host/upcheck.rs:#[cfg(test)] pub(super) fn differs_now, which calls the existinglook, for the card bench's check.Nothing changes in what the runtime does outside tests. All data is synthetic and made by the test.
How it was tested
cargo xwinforx86_64-pc-windows-msvc.cargo xwin clippy --workspace --all-targets --locked, and the same with--all-features, report the same warnings as main (35 and 41, compared by file and message), none in this change. With-D warningsboth stop in victory-shader, whose warnings are the same on main.cargo xwin test --workspace --no-run --lockedbuilds.cargo xwin build --release --locked -p victorybuilds.cargo xtask policy: one violation,crates/victory-loader/src/heap_sites/frame_users.rs, which is on main and not touched here, sorepository_passes_policyfails as it does on main.cargo testfor the crate it touches, on Windows (the release test binary ofvictory-gpu, 4 threads): 920 passed and 62 ignored, the two new tests among the ignored. Two tests fail, and they fail the same way on main41adb551without this change:shader_cache::tests::every_switch_of_the_translator_is_in_the_key(every run) andhost::card_steps::tests::places_written_after_sending_are_learned(2 of 2 runs on main, 1 of 2 with this change). The two new tests pass when run by name.Checked for overlap
host/bus.rs,host/placement.rs). #3508 (draft) adds profiling switches and a stress harness inshadow.rs. Neither drives preparation over aliased memory or throughHost::submitwithout the title.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by gabrielecabrini on 2026-11-30T19:11:30Z.
Ran both benches on Linux under Proton (vkd3d-proton), to give the comparator a second platform. Both pass, and stale is 0 in every row of every run. Two things came up: in the card bench, the runtime under Proton handles the section-backed copies differently, so three of its rows measure nothing there; and the bench doesn't reproduce the write-watch cost I see in game under Wine.
Setup: i5-14600KF (20 logical processors), 31 GB RAM, RTX 4070 SUPER 12 GB, NVIDIA 620.73.04, Arch Linux, Proton Experimental 11.0-20261123b (vkd3d-proton
vkd3d-1.1-5776-g30b0eb9bc). This PR merged onto maine1251c31, test exe cross-built withcargo xwin, run with Proton'swineandWINEDLLOVERRIDES="d3d12=n;d3d12core=n;dxgi=n". No switches exceptVICTORY_DXC(pointing at adxcompiler.dll) for the card bench, which setsVICTORY_RELAY=2itself. Three runs each, medians below. Runs agreed within a few percent.CPU bench (
preparation_without_the_title)Known unchanged: 8,948 and 8,758, as on Windows. Different CPUs, so the Windows column is a reference, not an A/B. Under Wine a guard fault costs about 4 to 6 µs of the title's write time (0.452 ms for 77, 0.121 for 28). The 174 MB rows with writes take 2.3x the Windows time. The rest is faster here than in your table.
Card bench (
submission_without_the_title)On Windows the header has 1 copy with a card side and every CPU side checked (your text: "1 against 1,401"). Under Proton it says:
So the 1,401 section-backed copies (the 1,400 and the 174 MB one) get neither side here. In the 174 MB rows nothing is refreshed even with 1% written (20 of 20 unchanged, 0 MB taken, 0 faults). In the full frames only the write-watched copies are taken (0.42 MB, against 5.34 in the CPU bench), and there are no faults. Stale stays 0, but it covers 3,000 copies only.
I haven't looked into why the runtime leaves the section copies unregistered under Proton. A suggestion: the card bench could fail, or print a warning, when a scenario's copies have no side. Then a row that measures nothing can't pass silently on another platform.
What it doesn't show under Wine
In game on the same PC (Series S, release build of main
84bd61e2, same switches as the launcher), the submitting thread's split has "asking the write watch" at a median of 10.4 ms a frame (8 to 18), against about 2 ms here. The bench has 7,686 views. In game the runtime's process-memory line reports about 74,500 regions.docs/linux-proton.md(the view-tree section) says the stock Wine server walks a list of all the process's views on every map and unmap (Wine bug 60868). I suspect the gap comes from the view count, not the per-refresh work. But I haven't measured it, and I don't know whether the write-watch queries go through the same walk. A knob that adds idle views or regions around the bench's memory would test it, and would let the bench reproduce the Wine case.Not tested: Windows on this PC,
VICTORY_PREP_WRITERS, otherVICTORY_PREP_PERMILLEvalues.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.