Textures no longer wait for remappings of other title memory #95
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!95
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-95"
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?
@LastThylacine on GitHub · 2026-11-24 21:26 UTC · original
LastThylacine:perf/texture-remap-lock→main· +271 −34 · 5 files · 1 commits · openProblem
Texture refreshes at submission read title memory in place under
watch::MAPPING, a lock over all of title memory that the runtime takes alone while it changes a mapping (XMemMapPhysicalPages,XMemMapPhysicalPagesScatterpage by page,map_alias). While the world streams in, the title changes mappings 650-1,100 times a frame. Every refresh waited for changes anywhere in memory, and every change waited for the refresh under way. On an RTX 5070 Ti that was 203 ms of an 801 ms frame (median; mean 389 ms) spent "waiting for title memory to hold still".Change
watch.rs: reads in place and changes of mapping hold only the bytes they touch (a mutex and a condvar over the ranges under way). They wait for each other only where those bytes meet. A change that waits for a read keeps new reads of its bytes out, as the writers of the old lock did.title_memory_reading,title_memory_reading_nowandtitle_memory_remappingnow take(at, len).xmem.rs:reach()gives the bytes a change touches: the range, plus the whole of the viewsunmaptakes away and maps again.VICTORY_MAPPING_RANGES=0holds all of title memory, as before.Measurements
Pair of runs on one exe (
1684989+ this change), warm shader cache, RTX 5070 Ti + i5-13600KF, 8 min each, medians over the world. A =VICTORY_MAPPING_RANGES=0, B = default.A matches plain main
1684989(768 ms frame, 191 ms waiting). The captured frames show the same lit opening scenes, and B gets further into them in the same time. Nothing is skipped: B reads more texture bytes per second.For comparison,
VICTORY_TEXTURE_NO_WAIT=1on main1684989(same exe, warm) gives 768 → 530 ms. It reads 91 MB/s of textures against 228 and leaves about 61 refreshes a frame for later, because pages of streaming textures are missing when it reads through the kernel. This change gets the frame time without skipping refreshes. The switch still works and now only gives up when the texture's own bytes are being remapped.Tests
cargo test --workspace --locked: all pass.VICTORY_MAPPING_RANGES=0.cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings: clean.texture.rs,host.rsordraw.rs(#28, #30, #38, #43, #45, #47, #48, #58, #59, #63, #80).🤖 Generated with Claude Code
@BitWuehler on GitHub · 2026-11-24 22:39 UTC · original
Verified on Linux/Proton (
CachyOS,Ryzen 7 9800X3D,RTX 5080620.73.04,GE-Proton11-14, release profile, Series X files), combined on4e17478with#454,#127,#154,#92,#108, and#159(vs the same local stack without#95/#108/#92/#159immediately beforehand):draws >= 100)230242,n=38)#95+#108+#92+#159(232121,n=41)waiting for title memory to hold still(med / mean / max)22.25 ms/280.66 ms/3,536.60 ms0.00 ms/0.00 ms/0.00 mstexturesinsidepreparing(med / mean / max)596.55 ms/892.66 ms/3,865.10 ms91.30 ms/122.55 ms/561.60 msms/frame(med / mean)1,190.20 ms(0.85 fps) /1,845.95 ms867.10 ms(1.20 fps, max6.10 fps) /1,312.95 msindirectdropped draws (mean / max)207.89/2,0733.49/10gpumedian67.55 ms50.90 ms5,426draws/frame):1.9 fps(521.4 ms/frame:102.4preparing withtextures 10.5 ms 8.1 MB,75.6GPU,16.6copy-back42.3 MB;49–67mapping changes/frame,0.0 mswaiting for reads in place).victory-gpu(114/115non-ignored pass; only known vkd3d-protonCreatePipelineLibrarystub fails) andvictory-hlexmemtests pass underGE-Proton11-14. Clean 353 s world session with 0 crashes or device removals.(Note: measured as a bundle alongside
#108,#92,#159, so overall gains reflect the bundle; the0.00 mselimination ofwaiting for title memory to hold stilldirectly reflects#95. AI-assisted log extraction.)@marquezinii on GitHub · 2026-11-25 05:27 UTC · original
Measured on the 6-core setup from #612: Ryzen 5 5600X, 32 GB, RTX 5070 12 GB (driver 621.40), Windows 11, Series X profile, diag build of
310c6ebwith this PR cherry-picked (no conflicts). One exe, paired runs of 480 s each with the same scripted Enter input, warm shader cache, medians of the frame lines in the last 3 minutes in the world:VICTORY_MAPPING_RANGES=0For scale, plain
310c6ebon a cold cache: 0.6 fps, 1,709 ms/frame, 1,103 ms of textures (e.g. 3,020.6 of 3,044.2 ms of refreshes waiting for title memory to hold still). With the PR that wait is 0.0 ms in every line. No device removal in any of the three runs;cargo test -p victory-gpu watchand-p victory-hle xmempass.One thing I noticed in the new frame line: with ranges the changes of mapping stay under way much longer. A:
94 changes, 0.5 ms waiting for reads in place, 2.6 ms under way. B:91 changes, 0.0 ms waiting, 228.6 ms under way(207.7 in the line before). The code under the hold is the same, so my guess is that they now run beside the refreshes and copies and get less of a 6-core CPU, or meet the reads in the kernel's address-space lock. I have not measured which yet. The frame is still 2.5x faster, but the title's streaming threads spend longer per remap.@JRamos1993 on GitHub · 2026-11-25 11:01 UTC · original
On an RTX 5090 with current
main(9376fd6), this PR together with #108 and #809 brings the median frame of the first two minutes in the world from 2.0 s to 0.76 s, and the time texture refreshes wait for remaps from 0.4–2.6 s a frame to 0.Setup: Windows 11, RTX 5090, diagnostics build, Series X files, warm shader cache, network off. The same save and the same scripted keys for every run, 330–420 s each, with runs of the two builds interleaved. Times count from the first frame line with 500+ draws.
9376fd6, 4 runs.9376fd6with #95, #108 and #809 merged (no conflicts), 3 runs.mainHow long frames stay slow varies a lot from run to run on both builds. The waiting time and the texture time don't: B has no wait in any run.
No crashes in B's runs. On the merged tree,
cargo test -p victory-hle -p victory-gpu --lockedpasses: 100 and 145 tests.I only measured the three together, so these numbers can't be split between #95 and the other two. The
VICTORY_MAPPING_RANGES=0pairs in the description and the comments above isolate #95.@NotADonky43 on GitHub · 2026-11-25 21:04 UTC · original
I tested the disjoint-range approach in a separate Windows reproduction, alongside an ordered GPU copy-back/remap change. The important overlap is the full existing Windows view: replacing the middle page of a three-page view had to wait for a reader on either neighbor, because Windows temporarily unmaps the view. A reader on a separate allocation continued, and all three page contents matched afterward.
The range version also passed the D3D12 readback case where an earlier GPU copy is held behind a fence and must reach the old backing before the remap. This was an adapted implementation, not a test of the exact PR head. I don't have a synchronized moving-scene benchmark for #95 and wouldn't attribute an FPS gain to it from these checks.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.