perf(hle,gpu): default-on batched map_aliases lock and scoped descriptor note gathering #275
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/275"
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 Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T00:42:17Z.
Summary
Makes batched
map_aliaseslocking and scoped descriptor invalidation note gathering default-on (replacing per-range lock acquisition / per-rangeREMAPPEDlocking on the CPU submission/remapping path;VICTORY_MAP_ONCE=0acts as a kill-switch):alias_all& default-onmap_once(crates/victory-hle/src/modules/xmem.rs):aliases_ofcoalesces contiguous single-page mappings from the same constant source page intoAlias { constant: true }spans (alias_constantunmaps once and places per-page views).one_after_anothermaps all ranges under a singletitle_memory_remapping()+physical()acquisition (alias_all).map_aliases_by_pagepath,title_memory_notes_gatheredis scoped inside eachwhile at < pages.len()group lock so notes flush cleanly before locks are dropped between groups.VICTORY_MAP_ONCE=0disables;VICTORY_REMAP_TIMINGremoved).crates/victory-gpu/src/descriptor/host.rs,watch.rs,lib.rs):remappedcalls into thread-localGATHEREDinsideremapped_gatheredand flushes once viaremapped_rangesunder a singleREMAPPEDmutex acquisition.remapped_gathered_batches_notes_until_outer_exittestsremapped_gathered_intolocally without touching process-globalSPANNEDorREMAPPED.Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T01:05:35Z.
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):passingReview Summary
CI is passing and the logic looks solid, with clean RAII panic safety and targeted unit tests. Because this enables batched
map_aliaseslocking and scoped descriptor invalidation note gathering by default (VICTORY_MAP_ONCEdefaults to on) across the D3D12 descriptor host (crates/victory-gpu/src/descriptor/host.rs) and HLE page-mapping path (crates/victory-hle/src/modules/xmem.rs), a local real-GPU smoke test is warranted before merging.What Was Verified
crates/victory-gpu/src/descriptor/host.rs,watch.rs,lib.rs):remapped_gathered/remapped_gathered_intobuffersremappedspans in thread-localGATHEREDand flushes once viaremapped_rangesinsideFlush::drop.if GATHERED.with_borrow(Option::is_some) { return f(); }) andGATHEREDis taken before invokingflush, preventingRefCellre-entrancy panics.remapped_rangeslazily acquiresREMAPPEDonly when at least one span overlapsSPANNED, preservingSTALE[1]/STALE[2]accounting and acquiringREMAPPEDunder a subset of the locks previously held (while_changingandphysicalare still held, before releasing them to readers).remapped_gathered_batches_notes_until_outer_exitexercises nested gathering and outer-only flushing without mutating globalSPANNED/REMAPPED.map_aliases& constant-page coalescing (crates/victory-hle/src/modules/xmem.rs):alias_as->alias_heldis a clean lock-hoisting refactor.aliases_ofcoalesces only contiguousPAGE-sized non-zero-source mappings sharing the samefrompage (last.constant || last.len == PAGE), avoiding accidental merges with multi-page non-constant spans or unmaps; covered bypages_from_one_constant_page_join_into_one_range.alias_constantchecks overlap (from < to + len && to < from + PAGE) and falls back to per-pagealias_heldwhen source and destination overlap, unmaps once otherwise, and preservesMAPPING[15]stream-log accounting.map_aliases_by_pagepath,title_memory_notes_gatheredis scoped inside eachwhile at < pages.len()group iteration so notes flush before locks are dropped between groups.VICTORY_MAP_ONCE=0cleanly restores per-range locking and ungathered notes.Minor Observation (Non-Blocking)
remapped_gatheredincrates/victory-gpu/src/descriptor/host.rsmentionsVICTORY_MAP_ONCE=0 disables; on by default, though the env-var gating lives inxmem::map_once()rather than insideremapped_gathereditself.Suggested Local GPU Verification
CopyPageMappingsBatchXstreaming (e.g., cutscene or open-world traversal), and verify no stale/corrupted placed textures, deadlocks, or frame-time stalls.VICTORY_MAP_ONCE=0to confirm the kill-switch path still behaves cleanly and compare frame-time / remapping overhead.Generated with Antigravity CLI (
agy).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T01:22:15Z.
A/B In-World Verification (
--features diagnostics, RTX 4060 Ti 8 GB, 1440p Series X, DLSS Performance, 45–60s)Verified cleanly with 0 crashes and passing visual/VRAM gates (
isolate-indoor,isolate-qw):mapped()Stall A/B:baseline-main(origin/main):26.99 ms/s(21400calls,1985.8 ms, max9.7 ms).isolate-1(VICTORY_MAP_ONCE=0):12.75 ms/s(18600calls,1792.0 ms, max8.6 ms).isolate-2(VICTORY_MAP_ONCE=1):10.82 ms/s(18800calls,1683.6 ms, max18.7 ms), preparing49.8 ms(-19.0 msvsisolate-1).isolate-indoor(VICTORY_MAP_ONCE=1, 60s):8.97 ms/s(19800calls,1526.8 ms, max8.7 ms), preparing48.2 ms.isolate-qw(VICTORY_MAP_ONCE=1):8.92 ms/s(15600calls,1457.7 ms, max22.4 ms,-67%rate vs baseline,-30%vsisolate-1), median10.45 fps(95.95 ms), preparing41.75 ms, VRAM5687 / 6346 MB,[PASS]Visual (edge_energy=6.97).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T01:31:30Z.
Maintainer triage (strict merge gate): keeping
triage: needs work.Blockers to resolve before re-review:
remapped_gathered_batches_notes_until_outer_exit.VICTORY_*switches: Make the batched lock + deferred invalidation-note path the default replacement (at most a=0safety kill-switch if needed) rather than adding opt-inVICTORY_MAP_ONCE=1/VICTORY_REMAP_TIMING=1.--releaseA/B required: Provide isolated plain--release(no--features diagnostics) A/B measurements vsmain(median fps,preparing ms,copyback ms,VRAM max,final_waiting,untranslated,0crashes).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T02:49:52Z.
Triage Blockers Resolved + Plain
--releaseA/B Verification (5d91edb6)emapped_ranges private, and extracted
emapped_gathered_into so
emapped_gathered_batches_notes_until_outer_exit does not mutate/race on global SPANNED or REMAPPED.
Plain --release A/B Benchmark (NO --features diagnostics)
RTX 4060 Ti 8 GB / i7-13700F / 32 GB RAM, 1440p parity preset, DLSS Quality, 45s in-world (aseline-main-release on
d79b9432vs pr275-release):d79b9432)5d91edb6)Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T03:22:34Z.
Maintainer triage (strict merge gate): moving to
triage: needs work.Thank you for fixing CI/test isolation and switching
VICTORY_MAP_ONCEto default-on (=0kill-switch only) with solidpreparing(36.5 -> 33.0 ms),min FPS(2.6 -> 6.1), andVRAM(-232 MB) gains and0crashes.Remaining blocker:
final_waitingincreased13,114 -> 16,850(+3,736) whileuploadeddropped43,622 -> 39,449(-4,173) on plain--release. Please resolve or confirmfinal_waiting <= baselineon a paired plain--releaseA/B run.Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T05:05:25Z.
### Paired 60s Plain
--releaseA/B (origin/maind79b9432vs PR #2755d91edb6)paired-main-release-60spaired-pr275-release-60smapped()stallsOn the paired 60s plain
--releaserun,final_waiting(13,661 -> 15,395,+1,734),preparing(33.6 -> 35.1 ms), andcopyback(23.1 -> 23.8 ms) still regress againstpaired-main-release-60s(d79b9432).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T05:18:54Z.
Closing as regressing on paired 60s plain --release A/B vs origin/main
d79b9432(preparing 33.6 -> 35.1 ms, copyback 23.1 -> 23.8 ms, final_waiting 13,661 -> 15,395, median 14.0 -> 14.0 fps).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-01T05:20:01Z.
Maintainer triage (strict merge gate): keeping
triage: needs work.On
paired-pr275-release-60s,median fpswas flat (14.0 -> 14.0) whilepreparingincreased33.6 -> 35.1 ms(+1.5 ms),copybackincreased23.1 -> 23.8 ms(+0.7 ms), andfinal_waitingincreased13,661 -> 15,395(+1,734,uploaded -1,800). Please rebase onto updatedmainand confirm a clear plain--releaseimprovement without regressingpreparing,copyback, orfinal_waiting.Pull request closed