Back copy: the kernel write is not the bottleneck (measured) #868

Open
opened 2026-11-25 11:10:59 +00:00 by CQ187901 · 0 comments
CQ187901 commented 2026-11-25 11:10:59 +00:00 (Migrated from github.com)
Contributor

Imported from fxceless/victory-fork. Originally posted by CQ187901 on 2026-11-25T11:10:59Z.


Back copy: the kernel write is not the bottleneck (measured)

Build 9376fd6 + local edits, VICTORY_RELAY=2, VICTORY_LEVELS_ON_DEMAND=0, RTX 4070 12 GB.

run copying back world frame notes
baseline 141-159 ms / 64-76 MB 183-214 ms 4,000-5,300 draws
coalesced adjacent runs in copy_back_with 141-149 ms 181-191 ms no change: per-call overhead is not the cost
+ plain stores instead of NtWriteVirtualMemory (write_mapped) 173-189 ms 1,142-3,357 ms worse, textures preparation 932-2,347 ms/frame

Details on the last one: writing title memory without the kernel's write breaks page coherence for the title's own later reads (it re-fetches hundreds of MB of textures right after), so the whole frame collapses. No crashes, no device loss, but nothing to be gained.

Also worth noting for whoever looks at the back path: the CPU search for shader writes is small, not the cost -
0.0 MB in windows outside buffers, 26.6 MB in 270 ranges of title buffers' copies (23.9 MB snapshotted), 0.0 MB in copies of 1 MiB or more per frame. So moving the compare to the card (#a26859f line) can't buy much; the 74 MB coherent write per frame is what costs.

Conclusion on my side: the remaining ~150 ms is the coherent write into title memory itself. The only structural fix I can see is letting the card write into title memory directly (VICTORY_INPLACE second stage, which the README lists as not done), or reducing the dirty bytes per frame. Any hint on which one you consider viable would be welcome.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6603153189 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/issues/869). Originally posted by [CQ187901](https://github.com/CQ187901) on 2026-11-25T11:10:59Z. --- ### Back copy: the kernel write is not the bottleneck (measured) Build 9376fd6 + local edits, `VICTORY_RELAY=2`, `VICTORY_LEVELS_ON_DEMAND=0`, RTX 4070 12 GB. | run | `copying back` | world frame | notes | |---|---|---|---| | baseline | 141-159 ms / 64-76 MB | 183-214 ms | 4,000-5,300 draws | | coalesced adjacent runs in `copy_back_with` | 141-149 ms | 181-191 ms | no change: per-call overhead is not the cost | | + plain stores instead of `NtWriteVirtualMemory` (`write_mapped`) | **173-189 ms** | 1,142-3,357 ms | worse, `textures` preparation 932-2,347 ms/frame | Details on the last one: writing title memory without the kernel's write breaks page coherence for the title's own later reads (it re-fetches hundreds of MB of textures right after), so the whole frame collapses. No crashes, no device loss, but nothing to be gained. Also worth noting for whoever looks at the back path: the CPU search for shader writes is small, not the cost - `0.0 MB in windows outside buffers`, `26.6 MB in 270 ranges of title buffers' copies (23.9 MB snapshotted)`, `0.0 MB in copies of 1 MiB or more` per frame. So moving the compare to the card (#a26859f line) can't buy much; the 74 MB coherent write per frame is what costs. Conclusion on my side: the remaining ~150 ms is the coherent write into title memory itself. The only structural fix I can see is letting the card write into title memory directly (`VICTORY_INPLACE` second stage, which the README lists as not done), or reducing the dirty bytes per frame. Any hint on which one you consider viable would be welcome.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork#868
No description provided.