Repository navigation
Textures no longer wait for remappings of other title memory - #95
LastThylacine wants to merge 1 commit into
Conversation
Reads of title memory in place (texture refreshes at submission, rectangle vertices) and the runtime's changes of its mapping (XMemMapPhysicalPages, its scatter form, map_alias) shared one lock over all of title memory. While the world streams in the title changes mappings 650-1,100 times a frame, many a page at a time, so every refresh waited for changes anywhere and every change for the refresh under way. Now a read holds the bytes it reads and a change the bytes whose mapping it changes (the range, and the whole of the views unmap takes away and maps again); they wait for each other only where those meet. A change waiting for a read keeps new reads of its bytes out, as the lock's writers did. VICTORY_MAPPING_RANGES=0 holds all of title memory, as before. A new frame line gives the changes per frame, the time they waited for reads in place and the time they were under way. Paired runs on one exe (1684989 + this change) with a warm shader cache, RTX 5070 Ti, 8 min each, medians over the world; A with VICTORY_MAPPING_RANGES=0, B without: - frame 801 -> 486 ms (mean 1,099 -> 524, p90 2,199 -> 670) - textures 371 -> 47 ms, of them waiting for title memory to hold still 203 -> 0 ms (mean 389 -> 0.6) - texture bytes read 233 -> 288 MB/s: nothing is left out - the runtime's changes waiting for reads 37 -> 0 ms a frame - GPU 150 -> 135 ms, copies 44 -> 45, copy back 79 -> 72; drops 375 -> 363 - no device removal in either; slow submissions 4 and 5 - frames: the same lit opening scenes, B further into them in the time For comparison, VICTORY_TEXTURE_NO_WAIT=1 on 1684989 (pair 768 -> 530 ms) reads 91 MB/s against 228 and leaves ~61 refreshes a frame for later. Tests: victory-gpu (new: reads and changes of other bytes go on, and a change that waits keeps new reads of its bytes out), victory-hle (the read-in-place stress test of xmem), the workspace; clippy in both CI configurations. Rebased onto 4e17478 without conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verified on Linux/Proton (
(Note: measured as a bundle alongside |
|
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
For scale, plain One thing I noticed in the new frame line: with ranges the changes of mapping stay under way much longer. A: |
…or remappings of other title memory (by Last Thylacine)
|
On an RTX 5090 with current 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.
How 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, I only measured the three together, so these numbers can't be split between #95 and the other two. The |
|
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. |
Adapt fxceless/victory-fork#95 (b18da0e) while retaining the local flight-aware refresh path.
Problem
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 main 1684989 (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(GPU: 512 MiB pipeline-worker stacks #28, Turn undocumented_unsafe_blocks back on: six SAFETY comments the lint can read #30, GPU: parallelize host-copy refreshes on multicore systems #38, Turn five of the switched-off style lints back on #43, gpu: scale texture VRAM floor and per-frame staging budget from VRAM #45, gpu: scale snapshot, scratch, and command-list pools from system RAM #47, gpu: tighten idle eviction and library trim timers under VRAM/RAM pressure #48, Textures: hash guarded textures at every check while they are new or changing behind the guard #58, GPU: clarify slow command-list timing diagnostics #59, GPU: hash textures that changed lately at every check (fixes startup flicker) #63, GPU: upload dirty title textures in HostList::prelude #80).🤖 Generated with Claude Code