Title speedups: skip flag stores that change nothing, post submission jobs less often #4943
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4943"
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 happyrain01 on 2026-12-01T14:56:54Z.
What it changes
In a loaded scene the title writes a status bit on its own bookkeeping objects many times a frame, in five stores. Those objects lie in title memory that
victory-gpuwatches for writes, and the first store into each 64 KiB block in a frame is a fault the layer has to handle, whether or not the bit was set already. The layer's fault book (VICTORY_FAULT_BOOK) counted 548 to 598 such first writes a frame; about half of them (304 of 598 in one book) came from these five stores.This adds
KnownBuild::speedups: the five stores are replaced by jumps to caves in the title's own padding (30 to 36 bytes each) that test the bit first and make the store only if it is missing. Memory ends up as it did. They are applied like the other code patches (to the prepared copy; the file you supplied is not touched), independently of the upscaler patches, andVICTORY_TITLE_SPEEDUPS=0leaves them out.docs/title-speedups.mdhas the details, the checks made on the bytes, and how to add another.A second commit adds two branch bytes in the routine that hands a closed batch of command lists to the title's submission thread (+0x2a42d0): it posts the waiting records as a job when 32 of them wait or the frame ends, not at every job boundary and at the end of every batch. That is 26% fewer submissions a frame (each is an execute and a signal). No frame rate gain could be measured from it (see below); it is a separate commit so that it can be dropped. The risk it carries is described in
docs/title-speedups.md.Files:
crates/victory-game/src/lib.rs(the field, the ten patches, the test checks),apps/victory/src/run.rs(applying them),docs/title-speedups.md(the setting is described there; the README's settings table is not in this branch's base).How it was tested
Base: this branch is on the fork's
main(41adb551, 2026-11-29), not on the latest upstreammain: the token used to push cannot update the workflow files that newer commits bring. The same two commits were made on the latest upstreammain(5fabb46e) first, and the tests, lint and release build below were run there; on this branch onlycargo test -p victory-gameand a compile check ofvictorywere run. I will rebase it ontomainif it is asked for.GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): Series S profile, DLSS quality; RTX 3080 as the display card (an RTX 3060 idle in the PC), Ryzen 9 3900X, Windows 11 build 26300. Resolution and frame generation were not recorded.
Before: write faults a frame (fault book, diagnostics build, 3 x 40 frames, the same scene): 548, 587, 598.
After: 245, 287, 331.
Frame rate, measured inside one run so that both sides have the same scene: the caves read one byte of padding, and a diagnostics build flipped it every 6 seconds (switch off = what the title did before), 12 minutes, 162 phases, phases paired with the neighbouring phase of the other side. Scenes of 1,500 draws or more: 40 pairs, +6.5% frames a second (95% interval +3.2% to +8.7%), faster with the change in 33 of 40 pairs (sign test p < 0.0001); the frame-preparing thread took 8% less time and the card's time did not change. 3,000 draws or more: 32 pairs, +7.0%; 6,000 or more: 17 pairs, +5.3%. These scenes run at 10 to 11 frames a second (86 to 97 ms). The switch itself is not in this pull request.
Job posting commit, paired in one run the same way: 35 pairs, +0.4% frames a second (95% interval -3.1% to +2.0%), 26% fewer submissions a frame, no stall in about two hours of runs.
Both measurements above were made on a build of the same patch bytes on top of a different base than this branch (
mainwith other pull requests merged and diagnostics code), not on a build of this branch.cargo test -p victory-game --locked: passed (44 tests, including the new checks that the caves do not overlap and keep clear of the switch byte).cargo clippy -p victory-game --all-targets --locked -- -D warnings: passed.cargo clippy -p victory --all-targets --locked -- -D warnings: fails with 5 errors invictory-gpufiles this pull request does not touch (host/font.rstoo_many_arguments x2,host/menu.rsmanual_is_multiple_of,host/panel.rscollapsible_if x2; clippy 1.98.0), so the same code is onmain. With those three lints allowed (-A clippy::too_many_arguments -A clippy::manual_is_multiple_of -A clippy::collapsible_if) it passes, so the changes torun.rsandvictory-gameare cleancargo xtask policy: asset policy ok (465 files).cargo build --release --locked -p victory: passed. A run of that build on the known build (Series S profile, DLSS quality, the default settings): the 12 patches were printed as applied (the two upscaler patches reported as left out because DLSS is on, as before), the title ran about 5 minutes translating shaders (1,156 translated) with no crash or panic; I closed it before the frame rate settled, so no frame rate was measured with this buildNot tested: other GPUs and CPUs, Series X, a long session compared by eye,
cargo test --workspaceand the all-features clippy gate (the change touches two crates and no feature code). If two threads set different bits of the same byte at the same moment the result can differ from the title's own, which already lost one of the two (the original store is a plain read-modify-write).cargo test -p victory-gamepassed;cargo test --workspacewas not runcargo testpassed for the crates it touches: yesChecked for overlap
crates/victory-game/src/lib.rs: #2448 and #730, which change other things; searches for "title patch", "VICTORY_TITLE_PATCH", "write fault guarded blocks", "conditional write flag", "submission ring title job" found only merged #1841, #68 and #516 and an unrelated #4749).🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by gut0to on 2026-12-01T15:11:29Z.
Review: COMMENTED
AI-assisted review: I inspected the new patch table and the current structural test. I used AI assistance and verified that the test does not currently validate the relative branch destinations.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by gut0to on 2026-12-01T15:11:29Z.
Code review location:
crates/victory-game/src/lib.rs; line 90Could
known_builds_are_well_formedverify the relative jump destinations too? It checks patch lengths, cave overlap, and the switch byte, but not that each siteE9reaches its intended cave or that each cave jumps back to the matching continuation. Since these bytes are applied to executable code by default, a wrong displacement would pass the current checks and redirect execution into unrelated title bytes. A table of site/cave/continuation RVAs with decoded rel32 assertions would make this relationship regression-tested.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by albertik322-sudo on 2026-12-01T16:49:32Z.
Heads-up from testing on a 30-series laptop: these two commits interact badly with the Universal MFG Unlocker (MFGUnlocker.dll v1.7.2.19 — the widely used frame-generation unlocker for RTX 20/30 cards).
Cherry-picked onto main @
5fabb46e, the game crashes silently 4-10 minutes into gameplay, every session. Windows Event Viewer shows the faulting module is MFGUnlocker.dll, exception 0xc0000409 (fail fast), always at the same offset. The crashes happen during shader-compile bursts while the world streams. Without these two commits (everything else identical) the same setup is stable for 20+ minute sessions.My guess: changing how often the submission thread's jobs are posted shifts the present-chain timing enough that the unlocker's hooks hit their failure path. Not a bug in this PR's logic as such — but a lot of players on 20/30-series cards run this game with an MFG unlocker (it's the only way to get frame generation there), so it may be worth checking the timing assumptions before merging.
Setup: RTX 3070 Laptop 8 GB, i7-11800H, Windows 11, Series S, DLSS Performance, FG x4 through the unlocker.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by paales on 2026-12-01T16:52:02Z.
Written by 🤖:
With SERIES X PICTURE 2560X1440 (
VICTORY_NATIVE_1440P=1) the start stops withError: settings cave is not free padding. The cave of "flag store 4" begins at+0x55ff284and is 30 bytes long;apps/victory/src/native_1440p.rsusesSETTINGS_CAVE = 0x055f_f285(59 bytes) for its own code. The speedups go in first, so the 1440p patch finds its cave written.Reproduced on an RTX 5070 Ti with this PR cherry-picked onto a build of
mainfrom 30 Nov: three starts in a row, each ending 2 s in with that line. With both "flag store 4" entries left out, the game starts, the four other stores are patched, and in a save with hardware ray tracing the median frame was 36.0 ms against 37.7 ms without the PR (one run each, back to back).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.