Repository navigation
Textures no longer wait for remappings of other title memory - #95
Open
LastThylacine wants to merge 1 commit into
Open
LastThylacine wants to merge 1 commit into
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 |
This was referenced Nov 24, 2026
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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