Repository navigation
Conversation
|
From a tester working with Claude (AI-assisted); measured on my own machine (i7-13700KF, RTX 4070 Super). No game data involved. A follow-up on top of this PR (and #440, plus our #1215): the page snapshots and the copy-back comparison run on a persistent pool of Branch, one commit on top of #440 + #497 + #1215: https://github.com/LooperSalty/VIctory/tree/perf/copy-pool-stacked (commit 8cce780). Measured, world stage, DRED off: snapshot about 50 ms, copy back about 73 ms per frame; with the rest of our perf set the world runs at 2.3-2.5 fps (it was 0.2). |
A copy of view memory (physical-page views, which cannot be write-watched) guards each 64 KiB block it took read-only. A block that is not mapped (a placeholder between views of a GPU heap) cannot be made read-only, so it never became clean: every asking reported it written again, and the copy read it through the per-page fallback, whose failing kernel reads cost hundreds of ms per world frame. Note such blocks absent (only after VirtualProtect fails and the block is not committed). An absent block is not reported again until title_memory_remapped, which the runtime calls after mapping or unmapping views, clears it. The copy keeps the zeros it took. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Before a submission runs, the bytes of each range its shaders write are kept to tell afterwards what the GPU changed. They were one buffer per copy, grown to the bounding range of every range the submission declared: each growth took a buffer from a pool of eight (a fresh one, page faults and all, when none was free and big enough) and copied the whole old snapshot into it. Keep them per title page instead, in 64 KiB buffers from a pool of up to 4,096, each page's part grown as ranges in it are declared (newly covered bytes taken from the copy as it is then, as before). A range inside one already taken returns at once. Copy-back compares page by page as it did by 64 KiB piece, with its scratch page from the same pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto current main ( Thanks @LooperSalty for the persistent copy-thread-pool follow-up branch built on top of this PR. Once this one lands it can be proposed as its own PR (nothing imported here). AI-assisted (Claude Code); checked on Windows 11 / RTX 5090. |
5ff3a35 to
92e1d4d
Compare
Stacked on #464. This branch contains #464's commit; only the second commit is new. It is independent of #490.
Problem
Before a submission runs,
Shadow::writingkeeps the bytes of each range its shaders may write, socopy_backcan tell what the GPU changed. Until now that was one buffer per host copy, grown to the bounding range of every range declared in the submission. The world declares overlapping views of its 174 MB heap dozens of times per submission. Each growth:In the world, temporary fault counters around
writingshowed 98K–450K page faults per frame (#464 runs).Change
crates/victory-gpu/src/shadow.rsonly:copy_backcompares page by page, as it did per 64 KiB piece, and checks that the page's snapshot covers the piece. Its 64 KiB scratch buffer comes from the same pool instead of a freshvec![0; 64 KiB]per call.Measured
Diagnostics build, RTX 5090, same save, start screen to world,
copystatworld windows. The snapshot faults are a temporary counter aroundwriting.writing(temporary counter)Example world lines:
2.6 fps, 377.7 ms/frame (210.1 preparing: copies 103.4 ms ...), snapshot faults 142,4932.3 fps, 444.4 ms/frame (172.5 preparing: copies 105.6 ms ...), 1544 draws/frame, snapshot faults 26,271The fault counter clearly drops. Preparing time varies with the scene too much to attribute a precise saving.
Most of the remaining faults come from refreshes, copy-back reads of title memory, and texture refreshes, not from snapshots. That is a separate follow-up.
Tests
New tests, run with a host device and skipped without one:
shadow::tests::copy_back_takes_only_what_the_gpu_wrote: two overlapping ranges over three unaligned title pages, with a refresh between the declarations. Only the bytes the GPU changed go back. A title write made meanwhile stays, and the copy takes it. The page buffers return to the pool.shadow::tests::declaring_a_range_again_keeps_its_snapshot: a range declared again after a GPU write keeps its first snapshot, so the write is still found and copied back.Gate:
cargo fmt --check(shadow.rs): passes.cargo clippy --workspace --all-targetsandcargo clippy -p victory --features diagnostics --all-targets: no new warnings.cargo test --workspace: passes.cargo xtask policy: passes.🤖 Generated with Claude Code