Repository navigation
Conversation
… (240,000 writes a frame under Wine)
Since only the GPU's bytes are written back (upstream #2009), every run of
changed bytes in a piece is a write of its own (`write_mapped`, one
NtWriteVirtualMemory call each). A shader that writes records leaves many
short runs, because every byte of a record that comes out as it was ends
one: in the world frames of the opening scene about 250 pieces a frame held
240,000 to 280,000 runs. At about 4 microseconds a call under Wine that was
0.8 to 1.2 s of every frame ("putting them back" in the frame account).
Runs with fewer than 64 bytes between them are now written as one
(`VICTORY_BACK_RUN_GAP`; `0` writes every run on its own, as before). That
leaves about 4,000 writes a frame.
What it gives up: the bytes between two joined runs are written as they
were read a moment before, so a title write that lands on one of them
between the read and the write is lost. Before #2009 that held for the
whole stretch from a piece's first changed byte to its last; now it holds
for bytes less than 64 bytes from one the shader wrote.
Test: `runs_closer_than_the_gap_are_joined`.
|
Windows numbers for the idea, since the description says they are missing. I have not run this PR and have not tried a gap of 64. These come from an equivalent local join in Setup: RTX 3070 Ti Laptop 8 GB (driver 596.36), i7-12700H, 15.7 GB RAM, Windows 11 build 26300, diagnostics build, Series X profile.
The Limits: one machine, one launch per row. Apart from the last two rows this is not a strict A/B (the gap 0 row was not repeated on AI-assisted (Claude Code). No game data. |
|
Thanks, that's the half I couldn't measure. So it isn't a Wine thing: one write per run costs most of the frame on native Windows as well (632 ms against 37 ms here). Your 256 against 4096 rows fit what I saw with the counts: past a few dozen bytes the number of writes hardly falls any more (about 4,000 at 64 and about 1,100 at 512 here), so a bigger gap only widens the window in which a title write can be lost. I'll leave the default at 64. The PR still merges cleanly onto |
…ack on Windows) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head AI-assisted (Claude Code); no game data. |
Problem
Since only the GPU's bytes are written back (upstream #2009, in
8dd30ab),Shadow::copy_backcallswrite_mappedonce for every run of changed bytes in a piece. A shader that writes records leaves a lot of short runs, because every byte of a record that comes out the same as before ends one.In the world frames of the opening scene I counted 240,000 to 280,000 runs a frame, in about 250 pieces. Each is one
NtWriteVirtualMemorycall. Under Wine a call measured about 4 µs, so "putting them back" in the frame account was 0.8 to 1.2 s of every frame.Change
Runs with fewer than 64 bytes between them are written as one (
join_runs).VICTORY_BACK_RUN_GAPsets the distance;0writes every run on its own, as before.What it gives up
The bytes between two joined runs are written as they were read a moment earlier. A title write that lands on one of them between the read and the write is lost. Before #2009 that was true of the whole stretch from a piece's first changed byte to its last; with this it is true only of bytes less than 64 bytes away from one the shader wrote. The README's
VICTORY_MERGE_RACEcount (none in 138,000 write-backs of whole stretches) is for the other merges, not this one, so I can't put a number on it here.Measurements
RX 7900 XT, RADV (Mesa 26.3.1), Wine 11.22, vkd3d-proton from GE-Proton11-14, diagnostics build, opening scene up to the first room, one run each of about ten minutes.
How the number of writes falls with the distance, counted in one run: under 8 bytes about 15,000 a frame, under 64 about 4,000, under 512 about 1,100.
The picture is the same in both runs (first room with its walls, the character, the "Move around" prompt).
Not measured: Windows. I'd expect the calls to be cheaper there but still a quarter of a million of them a frame.
The tree I ran is this
main(9376fd6) merged into myokex/victory-amd, with two local loader switches and myokex#6 on top;mainalone was not run. Another program used the card during the first minutes of the second run, before the world frames counted above.Related
Tests
runs_closer_than_the_gap_are_joined.cargo test -p victory-gpu --lockedunder Wine: 145 passed.cargo clippy -p victory-gpu -- -D warningsreports two things that are onmainalready (placed_filler_twinsunused withoutdiagnostics,sort_unstable_byindraw.rs), nothing inshadow.rs.No game files, captures or logs are included.