Repository navigation
Page-mapping copies: the locks taken once a call (VICTORY_MAP_ONCE, opt-in): worst frame while the world streams 170-210 ms where it was 300-555 ms - #3850
Conversation
…notes recorded at its end, constant-source pages unmapped as one range (VICTORY_MAP_ONCE) Off by default. With VICTORY_MAP_ONCE=1, map_aliases on its one-thread path takes the change of mapping and PHYSICAL once for every destination of the call (remapping_and_views, same order as one range), does each range as alias_as did alone (alias_held), joins pages mapped from one constant pool page into one range (alias_constant: one unmapping for the run, a view a page), and gathers the descriptor queue's notes (descriptor::host::remapped) into one taking of REMAPPED at the end (victory_gpu::title_memory_notes_gathered). With several mapping threads only the notes are gathered. VICTORY_REMAP_TIMING=1 also logs the lock wait and mapping time of the new path. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@duckey-dev Thanks for publishing both A/B ranges and the failure-path difference. Our native 1440p Series X walk with original RT on RTX 4070 Ti SUPER still has long frames and a heavily occupied submit thread. Did you capture the split between |
|
@akimfomin I had not captured the split: my measuring script filtered that log target out, so the runs in the description only compared whole-run frame times. I have now run the walk once each way with
So on this machine the wait for the change of mapping and Two more caveats from this pair. It ran on a branch with about 30 more open PRs merged than the runs in the description (#3733 among them), and there the worst frame was 181 ms off against 143 ms on, far closer than the 300-555 against 170-210 in the description. So treat the size of the gain as unsettled until I have repeats on one tree. The variant you describe exists here only on the several-thread path ( |
… taken once a call, the texture pass's notes recorded at its end, constant-source pages unmapped as one range (VICTORY_MAP_ONCE)) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng paths Wake only draws waiting for the affected pipeline and stop waiting when its compile is deferred. Publish placed-view shapes through immutable numbered slots. Handle adjacent soft copies of the same physical page under bounded remapping locks. Keep large gaps out of initial write-watch queries, retain full in-flight hazard checks, and publish the exact observed pages using word masks. Based in part on upstream profiles and changes in VIctory-NVIDIA trustno1-coder#2188, trustno1-coder#2804, trustno1-coder#3760 and trustno1-coder#3850.
What was wrong
While the open world streams, the title's render thread spends a long time in our
CopyPageMappings(queue.rscopy_page_mappings, thenxmem::map_aliases, thenaliasfor each range). One call took up to 64 ms, and these calls took 433 ms in 3.2 s of a timeline capture. Every other title thread was waiting on the render thread meanwhile.On the one-mapping-thread path, each range of a call took these again, one after another:
victory_gpu::title_memory_remapping(or_ofwithVICTORY_RANGE_LOCK=1) waits for every read of title memory in place to end.PHYSICAL, the views.title_memory_remapped/title_memory_unmapping.REMAPPED, the texture pass's queue, taken once for each note. The 16 DirectStorage workers take the same lock for every request they write (watch::writing).Constant-source ranges (kind 1 in
CopyPageMappingsBatchX: n destination pages that all show one pool page) arrive as n ranges of one page each. Each of those pages went through the whole sequence on its own: the locks, one unmapping and one mapping.The one-mapping-thread path is the one players use. It runs when
VICTORY_MAP_THREADS=1, whichscripts/play.ps1,Play-VIctory.cmdand the foxhound settings set, or whenever soft views are on (side_by_side()returns 1 then).What changes
Everything is behind
VICTORY_MAP_ONCE=1. Off (the default), the code paths are exactly as before.crates/victory-hle/src/modules/xmem.rs:map_aliases, one-thread path (one_after_another): calls the newalias_allinstead ofaliasfor each range.alias_all:PHYSICALonce for all of them, throughremapping_and_views(&wanted). That is the same helper and the same order one range uses.alias_asdid it alone. The first range that fails ends the call, as before.alias_held: the body ofalias_as, moved out unchanged, with the locks taken by the caller.alias_asnow takes the locks and calls it, so the path with the switch off is the same code.aliases_of: joins pages that sit side by side and are mapped from one and the same pool page into one "constant" range. It has a unit test.alias_constant:VICTORY_REMAP_SAME).alias_held.map_aliases, several-thread path (VICTORY_MAP_THREADSover 1): only the notes are gathered. The groups take their locks as before.VICTORY_REMAP_TIMING=1: also logs the new path's lock wait (locks_us) and mapping time (map_us) for calls over 5 ms. This is next to the existing whole-call line inqueue.rs.crates/victory-gpu/src/descriptor/host.rs,watch.rs,lib.rs:remapped_gathered(f): whilefruns on this thread,remappedkeeps its ranges in a thread-local list instead of takingREMAPPED.heap_hooks::changed, which takes no lock).record_ranges).remapped_ranges: split into theheap_hooks::changedstep andrecord_ranges. Its behaviour is unchanged.victory_gpu::title_memory_notes_gathered: the public wrapper forremapped_gathered, re-exported fromlib.rs.Why opt-in
Lock order
alias_alltakes the locks throughremapping_and_views: the change of mapping first, thenPHYSICAL. That is whatalias_asandXMemMapPhysicalPagesdo, so no new order is introduced. It is the same pair, taken once and held longer.VICTORY_RANGE_LOCK=1, the change is taken for what the views say every destination of the call touches, re-checked afterPHYSICALis held, exactly as for one range. A reader outside every destination still does not wait.REMAPPED. While gathering,REMAPPEDis taken once at the end, with the change andPHYSICALstill held. That is the same place it was taken before (insidetitle_memory_remapped/title_memory_unmapping, under the same locks), only once instead of once a range.remappedwas already documented as being called with the runtime's locks held and calling nothing.watch::writing,land) still record directly.How it was tested
VICTORY_MAP_THREADS=1(the launcher'splaysettings). A scripted walk in the open world right after loading a save. 6 runs with the switch, 5 without.VICTORY_MAP_ONCE=1The ranges do not overlap, but the limits are real:
11 runs in all.
One machine.
One route.
Measured on a branch that combined this change with other open pull requests, not on main alone.
cargo testpassed for the crates it touches: no failure that main does not have on this machine (main failsa_read_by_range_waits_only_for_a_remapping_that_meets_itand threebcpackoracle tests here, with or without this change). Both of CI's clippy runs add no warning over main.Not tested
map_aliasestests run with the switch off, so they cover only the unchanged path andalias_held(which now holds the moved body).alias_all,alias_constantandremapped_gatheredare not unit-tested. Onlyaliases_of, the joining rule, has a test.alias_heldandplacewithSoft::NotedCopies, as before, and their notes are gathered.Checked for overlap
None of these replaces this change. As far as I can tell, each one changes something else that the same calls contend on. I test-merged each against this branch with
git merge-tree: #2439, #2650, #3292, #3480, #3553, #3603, #3621, #3650, #3733 and #3760 merge cleanly.RemapQueue::recordunderREMAPPEDcheaper. This PR takesREMAPPEDfewer times during a page-mapping copy. The two fit together. Theirs helps every writer of the queue (DirectStorage, landing), which this PR does not touch: for queue cost in general, theirs is the broader fix. This PR's gathering matters only for the page-mapping thread.REMAPPEDonce for many ranges", on the landing threads' side. Independent and complementary.PHYSICALfor a whole call, Soft views: DirectStorage reads into memory the title mapped write through the section's view #3553 is all the more useful on the soft-view path.RangeLockitself cheaper; with it, unrelated readers are not woken by the one range-lock write this PR holds for a call.set_range_lockthat came in meanwhile): a correctness fix to the switch this PR's lock path reads. Independent.VirtualProtectmoved outside theGUARDSmutex): makes the guard work this PR still does for each range cheaper. Complementary; it is the larger change to the guards themselves.VICTORY_MAP_ONCE, so it does not change what those tests see. With the switch on,alias_allholds the remap lock for a whole call, which is the situation those PRs isolate the test from.🤖 Generated with Claude Code