RADV/Wine: world frame CPU-bound on title-memory traffic — copies in at ~107 MB/s, shader write-back at ~26 MB/s, GPU 2-6% busy #118
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/fxceless--victory-fork#118
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@DaviTostes on GitHub · 2026-11-24 21:38 UTC · original
RADV/Wine: the world frame is CPU-bound on title-memory traffic — copies in at ~107 MB/s, shader write-back at ~26 MB/s, GPU 2–6% busy
Setup: RX 9060 XT (RDNA4, GFX1200, 16 GB), Mesa 26.3.1 RADV, Arch kernel 7.3.5, Ryzen 5 5500, 16 GB RAM. System Wine 11.22 with Proton Experimental's vkd3d-proton 3.2.0 and DXVK 3.1.1
dxgi,WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n",VICTORY_NO_WATCHDOG=1(upstream #454),VICTORY_TEXTURE_NO_WAIT=1.Build:
main4e17478+ #20 (DXC fallback) + #454. DXC is required: without it Wine'sd3dcompiler_47refusesInterlockedMax/Load4onRWByteAddressBuffer, every indirect execution is dropped and the world stays black. With it the prologue presents a lit scene (6 100–8 400 draws/frame), so this is about speed, not the picture.Numbers from the frame line
Five world samples (>=500 draws) in one run:
copying back(shader-written ranges compared and written into title memory)The card clock agrees that the card is not the limit:
Where it fits
VICTORY_WIDE_REFRESH=1spreads a submission's refreshes but the flush still waits for all of them.What I have not separated: whether the 107 MB/s is Wine's page-fault/
ReadProcessMemory-style read of title memory, the vkd3d-proton mapping, or RADV's per-page cost. The write-back side looks like page faults on first touch of a mapped range.If there is a switch worth trying (
VICTORY_WIDE_REFRESH,VICTORY_JOIN_COPIES,VICTORY_TEXTURE_COPY, …) or a counter you would like captured, tell me and I will run it on this card and report back. Happy to test patches.@HenriqueSBueno on GitHub · 2026-11-24 21:44 UTC · original
A likely reason these two rates are so low under Wine specifically: the copy paths go through the kernel's cross-process memory API even though source and destination are in our own process.
host.rs:5418reads withReadProcessMemory(GetCurrentProcess(), …)andhost.rs:5454writes withWriteProcessMemory, piece by piece. On Windows that is a syscall per piece. Under Wine,NtReadVirtualMemory/NtWriteVirtualMemoryare served by a round trip throughwineserver, which then reads or writes the target process's memory itself. So every 64 KiB piece costs an IPC round trip plus a server-side copy, which fits ~107 MB/s in and ~26 MB/s back with the GPU 2–6 % busy.On native Windows (RTX 3080) we measured the same two terms at roughly 270 MB in ~440 ms and ~12 MB back in ~330 ms per world frame. They are slow there too, but several times faster than your numbers.
What we'd try, in order (they are H-1.2, H-2.1, H-2.3 and H-7.7 in the dossier linked from Marvisak/VIctory#1317):
Read/WriteProcessMemory. This removes the per-piece syscall, and under Wine the wineserver round trip.[min, max]span per shadow.Item 1 alone should show up directly in your
copiesandcopying backMB/s, and more on Wine than on Windows.AI-assisted (Claude Code)
@BitWuehler on GitHub · 2026-11-24 21:56 UTC · original
Opened PR #154 implementing item 1 (
AddVectoredExceptionHandler+ in-processx86_64rep movsbforread/read_into/copy_mappedandwrite_mapped, falling back cleanly on unmapped/PAGE_NOACCESS/PAGE_READONLYpages and delegating write faults throughwatchwhen a block is guarded;VICTORY_DIRECT_COPY=0toggles it off).Microbenchmark on
4e17478under CachyOS Linux +GE-Proton11-14wine(ntsync, Ryzen 7 9800X3D, release test binary,benchmark_direct_copy_vs_kernel_calls):256 MiBbulk read:ReadProcessMemory12.66 ms(20,227 MB/s) vsdirect_copy10.55 ms(24,270 MB/s)1,000 x 64 KiBwrites (62.5 MiB):NtWriteVirtualMemory16.57 ms(3,771 MB/s) vsdirect_copy0.68 ms(91,241 MB/s, 24.4x faster)All
host::tests(13/13),watch::tests(6/6),shadow::(19/19), andtexture::(2/2) pass underGE-Proton11-14. (Full in-world run and native Windows/RADV timing still pending; AI-assisted.)@DaviTostes on GitHub · 2026-11-25 01:00 UTC · original
Two experiments on that path, on the same card (RX 9060 XT, Mesa 26.3.1 RADV, Wine 11.22,
main4e17478+ #20 + #454):1. Direct copy without the guard crashes, as the code's comments warned.
VICTORY_COPY_MODE=plain(in-processmemcpy) runs the menus but dies in the world and the title writes a Breakpad dump: the ranges being copied do contain unmapped pages, so a faster path cannot justmemcpy.2. Skipping holes a run at a time is not the lever. I reworked the fallback so a failed bulk read/write uses the kernel's own "how far did I get" count plus one
VirtualQueryfor the hole, instead of falling to 64 KiB (then 4 KiB) pieces. Result, world frames only:The copy figures moved the wrong way and the write-back is inside the noise; the samples come from different scenes, so this is not a clean A/B, but it does say the time is per byte moved through
wineserver, not per 64 KiB call. Skipping pieces saves round trips, and there were not enough of them to matter.So item 1 looks like the only one that can matter here, and it needs a fault-safe guard. The clean one on this side may be the runtime's own page map rather than SEH:
victory-hle's xmem keepsviews: BTreeMap<usize, (usize, Slice)>for exactly the pages the title has mapped. Ifvictory-gpucould ask it "where does the mapped run at this address end", the copy couldmemcpyrun by run with no kernel call and no fault at all — under Wine that is the difference between a wineserver round trip per run and one per byte.Would a small hook in that direction be something you would take?
victory-gpucannot depend onvictory-hle, so it would be a registration (victory_hlehandsvictory_gpuafn(start, len) -> Option<Vec<(usize, usize)>>at startup), used only by the copy paths. I can write it and measure it on this card.@Ortomanic on GitHub · 2026-11-26 10:17 UTC · original
A Wine-side cause of slow title-memory traffic, with a patch: on this machine it took the world frame from 105–113 ms to 76–91 ms.
Setup: RTX 5080 16 GB, Ryzen 7 9800X3D, 60 GB RAM, CachyOS kernel 7.3.5, NVIDIA 620.73.04, vkd3d-proton 3.1, Wine 11.22 built from source. Series S profile. The build measured is the Neptune VE tree (a descendant of this fork by way of avatarmanz/VIctory-7900XTX), not
main, so treat the numbers as that tree's.What the profile showed.
perf(user space) over 40 s of a settled world scene:wineservertook 7.7 % of all samples, about half a core of a single-threaded process.server/mapping.c:is_valid_view_addr(49.3 %) andreq_unmap_view(45.2 %).The patch keeps the views in a red-black tree by base address beside the existing list (the list stays for load order). Lookup by base, lookup by an address inside a view, and the overlap check for a new view become tree descents. It is against Wine 11.22 and touches only
server/.Result, alternating runs from the same restored save, 5,000–7,000 draws a frame:
After the patch
wineserverno longer shows among the busy threads. A 9-minute run with it had no fault. Runs at the same settings still spread by about 15 ms, so two runs a side is a direction, not a precise figure.Two related notes.
GetWriteWatchthrough userfaultfd (USE_UFFD_WRITEWATCHindlls/ntdll/unix/virtual.c), so write-watch askings are not a signal storm here:virtual_handle_faultwas 0.04 % of samples.VKD3D_CONFIG=no_upload_hvv(upload heaps in system memory instead of host-visible VRAM) gave 104 ms against 125 ms in one pair of runs, and halved the copy-back time. One pair only.Not checked:
mainitself, RADV, and Proton's Wine (which may differ inserver/mapping.c). If someone on RADV can try the patch, the question in this issue is whether the same list walk is behind the 26 MB/s write-back.The patch (Wine 11.22,
server/)AI-assisted (Claude Code): profiling, the patch and this text. Counts and timings only; nothing from the game attached.