perf(watch): skip refused view askings without PORT_GUARD and track xmem placeholders directly #294
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/TaynanGT--Vice-Tay!294
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-294"
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?
@FredDietrich on GitHub · 2026-11-27 13:58 UTC · original
FredDietrich:perf/write-watch-and-view-tracking→main· +108 −20 · 3 files · 3 commits · merged 2026-11-27 17:20 UTCSummary
Split out from the earlier combined PR as requested (the two opt-in
MEM_WRITE_WATCHallocation switches are now in a separate PR).This PR contains two memory-watch improvements in
victory-gpu/victory-hle:Skip refused
GetWriteWatchcalls on known views withoutVICTORY_PORT_GUARD=1(VICTORY_SKIP_VIEW_ASK, default ON)VIEWSbitmap (refused_as_view,known_views,VIEWS.set) fromport_guard()incrates/victory-gpu/src/watch.rs.VICTORY_PORT_GUARD=1issued ~215 refusedGetWriteWatchsyscalls/frame against view memory.VICTORY_SKIP_VIEW_ASK=0.Track
MEM_RESERVE_PLACEHOLDERreservations directly in an atomicPLACEHOLDERSbitmapvictory_gpu::title_memory_placeholder(at, len)called fromXMemVirtualAllocwhen reserving placeholders (placeholder || kind & MEM_RESERVE_PLACEHOLDER != 0), with fallback toNtQueryVirtualMemory(MemoryRegionInformationEx = 7).NtQueryVirtualMemoryclass 7, soplaceholder()always returnedfalse, silently disablingVICTORY_KNOWN_HOLES(~13,700VirtualQuerysyscalls/frame and ~1,340 block-by-block guard acquisitions/frame).title_memory_freed(at, 0)now always resolves the full freed allocation end viaallocation_end(at, at)and clearsVIEWSandPLACEHOLDERSacross[first, freed_end)even if the first block was already cleared.Measured Results (Proton Experimental, RTX 3060 Ti 8 GB, Series S,
diag)prepcopiesguardsGWWPORT_CONSTANTS/CBV/DESCRIPTORS/JOURNAL + COPY/STORE_BESIDE)GWW/frameVICTORY_SKIP_VIEW_ASK)GWW/frame; texture refreshes 44.7 → 16.3 msPLACEHOLDERSbitmap)questions about holes13,711 → 1–2/frame (-99.99%);block by block1,340 → 60–67/frame (-95%)@TaynanGT on GitHub · 2026-11-27 14:11 UTC · original
@FredDietrich The isolated Proton Experimental run ties the write-watch change to the drop from 43.3 MB of whole-buffer copies to zero. The 10.6 FPS result belongs to the custom Proton build. I'll keep the changes independently testable and check the placeholder map/unmap cycle and address reuse before changing defaults.
@Garu667 on GitHub · 2026-11-27 15:30 UTC · original
Tested on an RTX 3080 10 GB (Series S,
-Machine auto, boat mission autosave, warm shader cache), one run each:maine45051amain+ #294main's (runs onmainalso had single frames of 30–69 s while cutscenes stream in).@TaynanGT on GitHub · 2026-11-27 15:54 UTC · original
@Garu667 The warm-cache boat run gives us a clean image and a useful timing result. Preparation went from 81 to 95 ms while steady FPS stayed in the same range. Keep that run as the Windows comparison when looking at the placeholder and write-watch changes separately.
@FredDietrich on GitHub · 2026-11-27 15:55 UTC · original
Thanks @TaynanGT and @Garu667 for the review and the Windows RTX 3080 test!
@Garu667's
preparingdelta (81 → 95 ms) matches an interesting trade-off we also saw in our Linux diag logs on commit 3 (MEM_WRITE_WATCHonXMemAllocDefault):+0x1412200) droppedcopied whole (memory not watched)from43.3 MB / 13.1 msto0.0 MBand its GPU upload from21.05 MBto0.00 MB.landcopies~20.6 MBback from the GPU into that buffer every frame, those writes re-dirty ~5,100 4 KiB pages, doublingGetWriteWatchdirty pages (~5,140 → ~10,250/frame). On Linux/Wine the saved whole-buffer copy + upload outweighed the extraGetWriteWatchcost (+0.80 fps), whereas on Windows (whereGetWriteWatchreset cost is ~1.4 µs/page andNtQueryVirtualMemoryclass 7 already works natively) the extra dirty pages can add ~7–10 ms topreparing.That completely validates @TaynanGT's point about keeping all three changes independently testable and opt-in first before changing any defaults. Happy to:
=1) and hardentitle_memory_freed(at, 0)so it clearsPLACEHOLDERSacross the full freed allocation even if the first block was already cleared, and/orPLACEHOLDERS+VICTORY_SKIP_VIEW_ASKvs.VICTORY_WATCH_HEAP/VICTORY_WATCH_XMEM_ALLOC).Let me know which shape works best for you!
@TaynanGT on GitHub · 2026-11-27 16:04 UTC · original
@FredDietrich I’d take two PRs. Put placeholder tracking and skipped view queries in the first, including cleanup of the full freed allocation when its first block is already clear. Put the two write-watch options in the second, each opt-in. The Windows and Wine results give us a clear reason to measure them independently.
perf(watch,xmem): write-watch large private buffers, skip refused view askings, and track placeholders directlyto perf(watch): skip refused view askings without PORT_GUARD and track xmem placeholders directly141e379663to503034cff2@FredDietrich on GitHub · 2026-11-27 16:36 UTC · original
Split as requested:
VICTORY_SKIP_VIEW_ASKandPLACEHOLDERStracking, withtitle_memory_freed(at, 0)resolving the full freed allocation end viaallocation_end(at, at)even when the first block is already clear.VICTORY_WATCH_HEAP=1andVICTORY_WATCH_XMEM_ALLOC=1, both opt-in (off by default).@TaynanGT on GitHub · 2026-11-27 16:58 UTC · original
@FredDietrich Resolving the full allocation when its first block is already clear covers the free-path case I was concerned about. The same warm-cache boat run with the smaller #294 will give us a Windows check for the skipped view queries and placeholder tracking. The two switches in #321 can each use that baseline.
@urielbeaupre on GitHub · 2026-11-27 17:06 UTC · original
Measured on Windows 11, RTX 4070 Ti 12 GB, Ryzen 9 7900X, 64 GB, driver 621.40. Setup:
scripts/play.ps1 -Machine 4070 -Console series-s -Windowed, ray tracing off.The base is
8137f71, from #305 (on top ofmainatb06fdd5). #284 and #294 were merged together onto it, so the result below is the two combined. I haven't separated them.Method: unattended opening (the game's own intro sequence, A pressed by
VICTORY_KEYS_FILE); a warm-up run first so no pipelines were being made (checked in the log); then 100 s of the frame lines.That's about +20% at the median, with the slow quarter gaining the most. There was no crash, and the picture looked unchanged. I can split the two PRs into separate runs if that helps.
@TaynanGT on GitHub · 2026-11-27 17:08 UTC · original · edited 2026-11-27 17:13 UTC
@urielbeaupre Please run #294 alone on the same
8137f71setup. Include the refusedGetWriteWatchcount and preparation and copy times if available. Windows CI also hit two write-watch test failures on the split head. A stale view entry can hide a direct query after Windows reuses the address.bcd771brestores the direct query and clears the entry when the kernel accepts it. The native check failed on the previous head and passed with the fix.