Repository navigation
Conversation
Each constant buffer fill of a submission was one ReadProcessMemory call, 0.7-1 us for a few hundred bytes. A leaf routine now copies in user mode; a vectored handler makes it return false when one of its own accesses faults, and the page-by-page fallback runs as before. Runs of fills are timed as one. 4096 fills of 256 B: 2.94 ms -> 0.046 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DenRakEiw
left a comment
There was a problem hiding this comment.
Tested head e99253e (fast-forward on main ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP (VICTORY_D3D12_WARP=1):
cargo test -p victory-gpu(RTX 5090): 56 passed, 0 failed, 3 ignored (including all newtitle_copy::tests::*andhost::fills::steps_run_in_order_and_unmapped_pages_read_as_zeros)VICTORY_D3D12_WARP=1 cargo test -p victory-gpu(WARP): 56 passed, 0 failed, 3 ignoredcargo clippy -p victory-gpu --all-targets: 0 warningscargo xtask policy: ok (156 files ok)
Clean SEH-guarded title-memory copy avoiding per-copy syscalls, with strong fault/protection/unmap test coverage. Approving.
AI-assisted (Gemini 4 Neon).
|
Thanks for testing on the RTX 5090 and WARP. |
|
In-game A/B on AMD/Linux, since the description only has the microbenchmark:
No measurable difference here: the copies in this workload are dominated by large watched ranges and page holes (the #783 path), not by the many small fills the microbenchmark targets, or the user-mode path falls back on this setup. Not a controlled same-save A/B, so treat it as directional. Not tested: Windows/NVIDIA (where the microbenchmark was taken), and the #943/#322 combinations you mention. |
|
Thanks for the in-game A/B. That matches what we see: in the world, large watched ranges and page holes dominate the copies, and this PR only speeds up the copy call itself (small fills most). Please read its numbers as the microbenchmark they are; I claim no frame-time gain for it alone. A run of ours on an RX 6800 was too noisy to add a number. |
Reading title memory directly spends a page's guard, which the kernel's copy does not; the fallback then read the page and copied its bytes where it read as zeros before. The handler now puts the guard back, with the page's other protection, before the copy fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed 79c9b93 (fast-forward): when a copy meets a guard page, the read spends the guard, which the kernel's copy on main does not. The handler now makes the page a guard page again, so the title still gets its guard fault. Between the fault and that call, a title touch of the page is not reported; the code comment says so. New tests: guard pages of three protections stay guarded, and the bytes match the kernel copy's (zeros for that page); two threads copying the same guard page; a thread that touches the page while copies run. AI-assisted (Claude Code). |
|
Thank you for this, @TG0000! Many pull requests here are still waiting to be merged, so I've ported this one to 465d6a0eac/AgentRecompVI, a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/36. You're credited as the author there. This stays the original. Test results
|
|
RTX 5060 Laptop GPU: in the world this PR takes frames from ~3.0 s to ~1.7 s (0.36 → 0.64 fps), and the run outlasts the title-pool stop at Setup. NVIDIA GeForce RTX 5060 Laptop GPU, driver 32.0.16.2124, Intel Core 7 240H, 32 GB, Windows 11 Pro 26200, title 1.0.2.1, Series X mode. Release build with World frames only, from the
The run without this PR ends at the title's empty-pool assert that #1232 reads as a frame-rate symptom; with this PR it does not come within the run, which fits that reading. Copies still move only ~270 MB/s here, so they remain the largest part of "preparing". Tests. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged main in (fast-forward); both the per-step timer of main and the run of fills timed as one are kept. 139 perf/shader-address-sums : PUSHlocal ref: prready/139 (90cf2f6), GitHub head 697c4bc 999 perf/shader-lane-condition-search : MERGED, CENSUS BEFORE THE PUSHlocal ref: prready/999 (255377d), GitHub head 3ca9456 No push needed (mergeable, no failing check, no open question)prready/1000, 993, 188, 172, 153, 126 = head + main, only to prove that they merge and build: do not push. Worktree: C:\Users\theo_\victory-prs (detached at origin/main). |
|
Automated triage for the maintainers. Needs rebase. This pull request conflicts with Generated by Claude Code |
Plain reads of title memory now read only the 4 KiB pages that the kernel's copy has read whole (a lock-free two-bit page table in shadow.rs). Other pages go through ReadProcessMemory, which fails on a guarded page and leaves the guard. If a plain read still meets a guard (the title guarded a page after reads found it unguarded), the page goes back to the kernel's copy for good. The common path adds no system call: a VirtualQuery or QueryWorkingSetEx per read would cost more than the kernel's copy that 0751149 replaced. Follow-up of the Codex review of c4893c8 (task fea654e8, finding A): - P1: fills_lose_no_alarm_of_a_guard_page_the_title_uses counts every alarm of a title's guard page under concurrent fills (25,205 to 28,723 of as many, three runs, about 3,000 fills each; 672 of 60,390 were lost before). Its handler runs ahead of XTP's and matches by address only. With every page read plainly, as before, the test fails. - P2: guard_again puts the guard back only on the protection the fault left. It undoes its call only while the page still has the protection it set, so a later change by the title stays. - P3: after a plain read stops, the kernel's copy reads again by 4 KiB page. On a poisoned lock, a pending copy-back view next to a page with no access keeps the GPU's bytes (two views tested). With the whole-region read, as before, the test fails. - P4: tested. A title handler ahead of XTP's that matches by address takes a plain read's fault for its own: one alarm too many, none lost. - P5: guard_again's credit now reads "Ported from Marvisak/VIctory#1010 (79c9b93) by TG0000". Still open: a page the title guards after reads found it unguarded is met once, and a title access in that microsecond window raises nothing. A page freed and committed again at the same address during guard_again gets the guard. Closing both needs the title's VirtualProtect and frees (watch.rs, xmem.rs) to report to shadow.rs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged main 940d32f in (fast-forward). The only conflict was the comment on Windows (RX 6800 and WARP, one thread): victory-gpu 152 and victory-shader 247 passed; clippy |
Summary
Every constant buffer fill of a submission is one
ReadProcessMemorycall, about 0.8 us for a few hundred bytes, and a world frame makes many of them. A leaf routine now copies in user mode. A vectored handler makes it return false when one of its own accesses faults, and the page-by-page fallback then runs as before. Runs of small fills are timed as one, so the timing no longer costs more than the copy.Measured
title_copy_bench(included, ignored by default), release build, Ryzen 9 5900X, Windows 11. Other builds were running, so treat the numbers as approximate. Time per copy:A copy that fails: 4.1 us before, 2.8 us now. 4096 fills of 256 B: 2.94 ms before, 0.046 ms now (the source is in cache here, so the gain in a real frame is smaller). This is a microbenchmark; the in-game frame time of this branch alone was not measured.
Verification
Rust 1.98.1 MSVC, base
ffe310e:cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: clean.cargo test --workspace --locked --no-fail-fast: 347 passed, 1 failed. The failure isframe::tests::waits_end_on_ticks_and_count_frames, which this PR does not touch: it fails the same way on unmodifiedmainin the same session (341 passed, 1 failed, loaded PC) and passes 20 of 20 times alone on both. GPU: a frame wait takes its tick before it sleeps #174 and GPU: let the frame-wait test tolerate a loaded scheduler #689 are about that kind of wait.Overlap
Conflicts textually with #943, which changes how the fallback of the same functions finds regions, not the copy itself; I will rebase on whichever lands first. #322 (copies into title memory without a region query first) and #202 (skips unmapped regions after a failed bulk read) edit the same area of
host.rs.AI-assisted: written, benchmarked and checked with Claude Opus 5.5. No game data.
🤖 Generated with Claude Code