Copy and copy-back cost 2.4-5.6 ms/MB per frame and the GPU idles; the waits, not the bandwidth, are the frame here #1003
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#1003
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?
@Key-rs on GitHub · 2026-11-25 15:37 UTC · original
The per-frame copies and copy-backs cost far more per megabyte than the bandwidth allows, and on this machine they are where the frame goes — not the GPU.
Machine: Ryzen 7 8845H, RTX 4060 Laptop 8 GB, Windows 11 26300. Build
0b0074e,--release, with the switches from the README's "newer switches" line:Six consecutive frame reports from one run (the
fpsline, shortened):Per megabyte, against what a PCIe 4.0 link and a 4060 should manage (0.1–0.3 ms/MB for a straight upload):
And the GPU is idle for most of it: 1.1–61.1 ms on the card in frames of 272–701 ms, i.e. the card is waiting while the host side reports 82–277 ms of "preparing" and 33–98 ms of "copying back".
What I take that to mean
The numbers do not look like bandwidth. 87.7 ms to move 15.5 MB, and 32.9 ms to move 10.1 MB in another frame, are the signature of waiting — a fence or a wait for the card inside the copy, not the copy itself. The texture spikes (211.7 ms for 30.3 MB, next frame 123.3 ms for 23.1 MB, then back to 10.7 ms for 18.6 MB) point the same way.
Two things I could check from the outside, both negative:
VICTORY_JOIN_COPIES=1(from the "52–63 title buffer copies per frame, of them 0 continue the one before" line): copies stayed at 44.5–143 ms for 101–212 MB, so joining them does not move the per-megabyte cost.VICTORY_HOIST_CLAMPS=32(and=7default): within noise, and=0faults with0xc0000005about 36 s in — that one is a separate report.What I am not claiming
I have not read the copy path in
victory-gpu, so I cannot say which wait it is. This is a report of where the frame time goes on one machine, in case it is useful while the submission and copy work is in flight: the host-side copies and copy-backs, not the GPU, are what a 4060 is waiting on here, and at the current rates the whole frame budget is spent on a few dozen megabytes.One caveat on the data: this machine's dump had a zero-filled
navmeshes.rpf(found by checking the torrent's piece hashes); it is restored and the package verifies 634/634 on the pieces that matter, so the numbers above are from a clean, complete dump. Worth mentioning because a damaged dump makes the frame look like this too, and it cost me a day.@Key-rs on GitHub · 2026-11-25 16:09 UTC · original
A cross-reference that puts the numbers in this report in context: another fork of the same lineage, on the same machine and the same dump, spends 1.3–2.8 ms and 3–7 MB per frame on copies where this build spends 45–143 ms and 78–212 MB.
Measured here, back to back, warm shader cache both times,
0b0074eagainst DexNom921d8d3:DexNom is not faster overall on this card — it is CPU-bound somewhere else (its own window reports
gpu 0-2% busy, cpu 53–71%) — but the copy path there is 30× cheaper, which is the part of this report.What they do differently
Their
crates/victory-gpu/src/memory.rsis 542 lines against 319 here, and the piece that matters reads:So the range is recorded at the moment of the write, and only recorded ranges are refreshed afterwards. This build instead finds writes by looking: the per-frame line here says
623 hash passes over 1250 pieces, and the copy cost tracks that hashing rather than the bytes.The relevant DexNom commits are
Restore ray structure building and track guest shader writes precisely(memory.rs +303/−93, draw.rs +256, host.rs +86, inplace.rs +101, plus a newmemory/ray_probe.rs) andImprove City texture streaming and recover sparse textures.One thing I tried that is not the answer
VICTORY_INPLACE=1on this build: copies stayed at 46–131 ms and textures went up, to 2763 ms for 256 MB in the worst frame (0.1 fps). Whatever the in-place stage does today, the flag alone does not get near the numbers above.Why I am posting it rather than porting it
I could try to lift their memory model into this tree, but this branch has moved a long way in the same files this week (submit thread, copies in place, draw windows), so a cherry-pick conflicts everywhere and a hand port of a memory model is a day of work with a nasty failure mode. Both trees are GPL and share the ancestor, so the comparison is yours to make far more cheaply than mine.
I am not suggesting what the fix should be — only that "2.4–5.6 ms/MB for a copy" has a working counter-example in the same family, and that the difference is visible in the counters.
@akimfomin on GitHub · 2026-11-25 16:29 UTC · original
PortBridge surfaced this report during its search for measured GPU readback costs. I used it to choose an open synthetic Vulkan experiment with a three-slot asynchronous exact-range baseline. On the stable 32 MiB request trace, reuse cut transferred bytes by 83.3% and paired time by 69.4% after charging separately measured planning. With full rewrites, the exact-range route was preferable. This is a page-range replay and does not measure the fork's frame time. Pinned code and paired data
Do you already have an aggregate estimate of the copied-back ranges that the CPU observes before their next GPU write, or of requests repeated without intervening writes? Either would help decide whether a guarded reuse path is relevant here. Aggregate counts are enough and there is no need to share captures or reproduce the workload. (Codex-assisted research and writeup.)
@HLVM04 on GitHub · 2026-11-25 16:30 UTC · original
We see the same shape on a desktop RTX 5070 Ti 16 GB (Ryzen 7 9800X3D, driver 616.64). That run used the Series S profile on fork
9376fd6+ #798 #783 #799 #770 #780 #827. It's an older tree than yours, so only the shape compares. Here is a steady frame line from that run:148.0 ms/frame (66.2 preparing: copies 34.9 ms 122.6 MB; 51.6 on the GPU; 72.1 copying back 34.6 MB)One local change (not in the fork) moved the preparing side for us. We read title memory with in-process CPU copies instead of
ReadProcessMemory:rep movsb, with a vectored exception handler that turns a fault at that instruction into a failed copy. That took the submitting thread from 26 to 7.5 ms a frame. It moves the same bytes through a different call, so on our side a good part of that cost was the call path, not bandwidth.These numbers come from one run each, in the first gameplay scene, so scene variance applies. We have no counts for the reuse question above.
@Key-rs on GitHub · 2026-11-25 16:39 UTC · original
Two more switches tried here, both negative, in case they save someone else the runs:
VICTORY_COPY_MODE=1 (plain) copies 40-105 ms / 78-195 MB frame 235-967 ms VICTORY_COPY_MODE=2 (none) copies 80-178 ms / 123-210 MB frame 235-712 ms baseline (guarded) copies 46-143 ms / 78-212 MB frame 201-701 ms VICTORY_INPLACE=1 copies 46-131 ms, textures up to 2763 ms 0.1 fps VICTORY_JOIN_COPIES=1 copies 44-143 ms / 101-212 MB frame 272-701 msSo none of the copy switches on this branch move the per-megabyte cost — COPY_MODE=2 still reports 123–210 MB of copies, so it is not the knob I hoped it was.
One thing worth saying plainly, because it tempers the DexNom comparison in my previous comment: DexNom has the cheap copies and is still slower here (0.5–3.4 fps, its own HUD showing gpu 0-2% busy, cpu 53–71%). Whatever it saves on copies it spends somewhere else on the CPU, so cheap copies alone would not make this branch faster on a 4060 — it would move the bottleneck rather than remove it. I would not port the memory model expecting a frame-rate win on this hardware; I would port it because the numbers are wrong, which is a different reason.
@Key-rs on GitHub · 2026-11-25 16:51 UTC · original
Thank you — that is the same conclusion the fork already reached, and there is a switch for it: VICTORY_COPY_PLAIN=1 (crates/victory-gpu/src/plaincopy.rs), a
ep movsb in a stack-free function of ours with a first-in-line VEH that turns a read fault at that instruction into a failed copy, the caller falling back to the kernel's copy. Its comment even has the profile you describe: the submitting thread 35 ms a frame inside ZwReadVirtualMemory for about 100 MB (3 GB/s).
I ran it here on the same machine and package (Ryzen 7 8845H, RTX 4060 Laptop 8 GB, ␀b0074e):
VICTORY_COPY_PLAIN=1 copies 41.4-117.5 ms / 81-136 MB frame 276-1191 ms baseline (kernel copy) copies 45.7-143.4 ms / 78-212 MB frame 201-701 msNo change in the copies, which is the opposite of your 26 → 7.5 ms. What I take from it: 41 ms for 82 MB is 0.5 ms/MB, and a
ep movsb should be a tenth of that, so on this run the time is not the copy call — it looks like the fallback, i.e. the pages that are not there when the copy starts. Your 7.5 ms suggests the pages were largely present in your scene; mine is a first-run streaming city at 1-5 fps, where the title is unmapping and remapping constantly.
If that reading is right, the interesting question is not which call does the copy but how many pages are missing per frame, and whether a guarded reuse path could avoid asking for the ones that have not changed. Which is the same question the other comment in this thread is asking from a synthetic side. Worth comparing notes with @akimfomin, who has a measured reuse result (83.3% fewer bytes, 69.4% less paired time on a 32 MiB trace).
I would not put your local change in the tree as a new switch, since one exists — but if you have the number of pages that fell back per frame, that would be a useful addition to the report.
@Key-rs on GitHub · 2026-11-25 16:52 UTC · original
Short answer: no, I do not have either aggregate — the report is frame counters only (copies ms/MB, copy-back ms/MB), not per-range identity or reuse. I did not instrument that, and on this machine the run takes minutes to reach a frame with the world in it.
What I do have, if it is any use to the synthetic side:
The two things your experiment would need that I cannot give: whether those ~60 ranges repeat without an intervening write (the title rewrites streaming memory constantly, which is why the fork guards and hashes rather than trusts), and how many pages are missing when a copy starts — I suspect that last number is where my 0.5 ms/MB comes from, since VICTORY_COPY_PLAIN=1 (in-process
ep movsb, no syscall) does not move it at all:
VICTORY_COPY_PLAIN=1 copies 41.4-117.5 ms / 81-136 MB baseline (kernel) copies 45.7-143.4 ms / 78-212 MBIf the guarded reuse path you measured is relevant, the number to have first is how often a range is re-read unchanged; the fork has VICTORY_CARD_REHASH_RUNS and the per-frame hash counters (623 hash passes over 1250 pieces), which suggest the hashing side is where a reuse decision would have to be made. Worth asking @fxceless whether those counters can be got out as a total.
Happy to run any instrumentation you want on this machine if it needs a real title rather than a replay — that part is cheap, the runs are just slow.
@spk-c on GitHub · 2026-11-26 01:08 UTC · original
An additional data point from a desktop RTX 4090 (Ryzen 9 9950X3D, Windows 10, 24 GiB): one periodic report measured 246.2 ms/frame (4.1 FPS), 139.7 ms copying back and 26.7 MB merged back. A nearby relay report measured 125.7 ms waiting for fetches and 143.5 ms landing in all.
One attribution caveat: the existing fetch-wait timer starts before command recording/submission, so it does not isolate PCIe transfer or GPU execution. #1231 adds opt-in CPU wall-clock counters for selection, buffer preparation, recording/submission, fence wait, merge and the inflight attempt. Fence wait itself includes queue dependencies and scheduling. Measurement notes.
These are observations from changing workloads, not a matched A/B or a bandwidth benchmark; the timers overlap. We do not have the per-range CPU reuse/observation aggregates requested above. No FPS gain is claimed for the new instrumentation. AI-assisted analysis and write-up.
@Key-rs on GitHub · 2026-11-26 01:41 UTC · original
Your caveat about the timer is the right one to make, and I have a result that supports it: on this machine the copying back figure moved a lot without the bytes changing, because it was carrying thread scheduling rather than transfer.
8c/16t Zen 4, RTX 4060 Laptop, ␀b0074e, same package and switches, warm cache:
Same bytes per megabyte, same link, same card: the only thing that changed is that 16 storage workers stopped competing with the thread that copies back. VICTORY_DSTORAGE_WORKERS=16 puts the old numbers back, so it is the pool and not the scene. A copy-back timer that includes the wait behind other threads on the same cores will read like a bandwidth problem when it is a scheduling one — which is what your phase breakdown in #1231 is for.
That also means my "2.4–5.6 ms/MB against a 0.1–0.3 expectation" in the report should be read as an upper bound on the real transfer: it includes fence waits, queue dependencies and scheduling, exactly as you say. After the worker change the residual 2.4–3.5 is still an upper bound, and I would not guess how much of it is PCIe.
On the aggregates @akimfomin asked for: I do not have per-range reuse either, so we are in the same position there — the fork reports counters, not identities.
Your 4090 datapoint is useful to me (139.7 ms for 26.7 MB is 5.2 ms/MB, i.e. the same anomaly on a card with far more bandwidth than mine): it rules out "a slow laptop" as the explanation before anyone spends a day on the copy path.
If #1231's counters are in a build I can run, I will gladly run that build on this machine and report the phase split for a real title — same switches, same scene, one number per phase. That would give your instrumented numbers a second machine and a second GPU vendor, which is more than I can do by reasoning about the timer.