GPU: skip unmapped regions after a failed bulk read into host memory #202
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!202
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-202"
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?
@ifBars on GitHub · 2026-11-24 01:24 UTC · original
ifBars:gpu/sparse-host-reads→main· +77 −0 · 1 files · 1 commits · openDuring first-story rendering on Windows 10, about 650 bulk reads per frame fell back to 64 KiB and 4 KiB retries in one sample. Those reads encountered roughly 136 MB of unmapped memory. This patch keeps the successful bulk read unchanged. After a failed read of at least 64 KiB into host memory, it uses VirtualQuery to skip contiguous holes and reads committed regions through the kernel. If the mapping changes before the read completes, the existing page retries recover the readable bytes. It queries again on every copy.
Validation
d2a4bae, the GPU crate passed 44 tests with one ignored. The asset policy check passed.AI-assisted. No game assets or derived shader data are included.
@TheHoracio on GitHub · 2026-11-24 01:34 UTC · original
Independent timing of this change on another platform: Ryzen 7 9800X3D, Windows 11 Pro 10.0.26300, release build (
cargo test --release). The benchmark is synthetic, with no game data: an#[ignore]d test appended locally tocrates/victory-gpu/src/host.rsthat callscopy_mapped. Each value is the mean of 5 or 10 repetitions after one warm-up.dcf6664)copy_mappedmemcpy(reference)ReadProcessMemory) runs at about 8.7 GB/s here, against about 17 GB/s formemcpy. At the ~350 MB per frame reported in #135, that is about 40 ms. So most of the 240–470 ms per frame of copies that testers report likely comes from fallbacks like the ones this PR removes, not from raw copy speed.Benchmark (local only)
Not tested: in a title, on Windows 10, on other CPUs.
AI use: Claude Code (Claude Opus 5.5) wrote the benchmark, ran it on the machine above and drafted this comment.
@SkippySteve on GitHub · 2026-11-24 01:36 UTC · original
I ran this under Wine/Proton on Linux using only the synthetic
victory-gputests. I used no game data and did not run a title session.Setup
wine-11.0) with its bundled vkd3d-proton, in a fresh Proton prefix. I created the prefix withproton run, then ran the test executables with Proton'sfiles/bin/wineandd3d12,d3d12core,dxgi=n,b.cargo xwin test -p victory-gpu --target x86_64-pc-windows-msvc --no-run, debug profile.mainatd2a4bae(the PR's base), the PR atdcf6664, andmainwith only the new test added. The last build runs the new test against the old page-retry path.Test results (3 runs each,
--test-threads=1; every run gave the same result)sparse_copies_preserve_islands_and_observe_remapsmainmain+ new test onlyAll three builds fail the same 3 tests, so the PR adds no failures. Those failures are already known on Wine:
indirect::tests::argument_clamp_builds: Wine'sD3DCompile(#170)pipeline::library::tests::a_rejected_blob_gives_an_empty_libraryresource::tests::buffer_data_reaches_the_host_texture: #128The PR leaves #128 unchanged. That bug is on the
title_dst = truepath, whereVirtualQueryreports vkd3d-proton's mapped destination asMEM_FREE. This PR only changes the!title_dstfallback, after a failed bulk read. Its sources there are title memory from the shadow, texture readback andFillpaths. That memory comes fromVirtualAlloc, which Wine tracks, soVirtualQueryreturns the correct state and the new test passes under Wine with the remap checks included.Timing under Wine (an ignored ad-hoc test I added locally, not part of the PR). It copies 32 MiB with 32 committed 64 KiB islands, spaced 1 MiB apart, using
copy_mapped(.., false). Each run is 10 copies, every one checked byte for byte; the table shows the median for each of 3 runs, in a debug build.main(page retries)That is about 5–7× faster. You measured about 22× on Windows (27.36 → 1.23 ms). On Wine the
VirtualQuerycalls are not free, but they cost far less than the failedReadProcessMemoryretries they replace. I didn't see anything Wine-specific that argues against the change.Not tested: release builds, AMD/RADV, and any in-game load.
@tanishq-dubey on GitHub · 2026-11-24 02:11 UTC · original
Independent Wine test of head
dcf666486a3cb1fd47ad60437ef110d94c9f810e: cross-built thevictory-gpuWindows test binary and ransparse_copies_preserve_islands_and_observe_remapsunder Wine 11.22 on Linux x86_64. 1 passed, 0 failed, including the protection change and newly committed page.I also tried the same code in a world run alongside other local changes; it remained black and the runs are not controlled enough to attribute the timing difference to this PR. No game data attached. AI-assisted.
@tcurtsinger on GitHub · 2026-11-24 02:31 UTC · original
Independent Windows 11 timing on a Ryzen 9 9950X3D, comparing
d2a4baeanddcf6664. The benchmark called the production copy path and checked every destination byte, including zero-filled holes. Four fresh processes per revision ran in interleaved order, each with three warm-ups and nine timed copies. The values below are medians of the four process medians.In a separate RTX 4080 intro run, one sample on the previous build spent 299.8 ms copying 172.9 MB. A sample with this PR and four other changes spent 76.6 ms copying 172.6 MB. Only the synthetic comparison isolates this PR. The cutscene and memory results are in the RTX 4080 run report.
AI-assisted testing (Codex).
@andrewpozdnakov7-jpg on GitHub · 2026-11-24 10:53 UTC · original
Independent Windows check of
dcf6664merged ontoffe310e, prompted by the query/read window in #783.I forced one 4 KiB page inside a committed 128 KiB region to be decommitted immediately after
VirtualQueryreported the region and before the kernel copy.copy_mappedrecovered the readable bytes on both sides, zeroed the new hole, and preserved the destination sentinels. Removing theread_piecesretry after a failed region read made the test fail. Restoring it passed along with the existing sparse-copy test.I also compared the existing piece retries and the region scan in one binary. Both timings include the initial failed bulk read. These are medians of three fresh-process medians. Each process alternated the two routes, used seven timed samples per route after warm-up, and compared every output byte.
The speedup on this setup depended on how much of the address range was unmapped. The query/read regression exercises the host-destination read path, and the timing is a synthetic copy benchmark.
AI-assisted; run on Windows using process-owned test memory.
@Marvisak on GitHub · 2026-11-25 00:22 UTC · original · edited 2026-11-25 15:55 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-gpu/src/host.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (merge-candidate) was for an older state ofmain.Generated by Claude Code
@ifBars on GitHub · 2026-11-25 10:03 UTC · original · edited 2026-11-25 10:05 UTC
Rebased onto current
main(940d32f) and pushed2ea6961. The conflict was two tests added at the same location inhost.rs; both tests are preserved. The sparse-copy behavior is unchanged. I also added the safety comment required by the current Clippy check besideVirtualQuery.Validation on Windows 10:
--locked -- -D warnings.mainon this machine has 139 passed, the same 4 failed, and 2 ignored. Those failures aredynamic_slots_are_held_until_released,a_texture_written_in_one_format_reads_in_another_through_a_placed_view,lists_share_a_table_and_copies_keep_their_views, andpipelines_load_on_many_threads_at_once.GitHub now reports the PR as mergeable. AI-assisted (Codex).
Hosted validation: CI passed for commit
2ea6961, including both Clippy configurations and the full workspace test suite.2ea696147eto356b10dd30@mercuryVM on GitHub · 2026-11-24 09:55 UTC · original · approved these changes
Tested
dcf6664on Windows 11, RTX 5070, MSVC: the workspace passes (196 outsidevictory-shader, which has its own known parallel-GPU hang and I ran separately), includingsparse_copies_preserve_islands_and_observe_remaps. I could not compare in-game copy times.!title_dst) takes the new route.VirtualQueryper region turns the 64K/4K probe storm over large holes into one zero-fill per hole. A committed region whose read still fails, because a mapping changed between query and read, falls back toread_pieces, so a race can't lose bytes. The test covers that remap case.PAGE_NOACCESSis zero-filled like a hole, which matches whatread_piecesproduced for those pages before.No issues found.
AI-assisted (Claude Code).
@ifBars on GitHub · 2026-11-26 12:47 UTC · original
Rebased again onto current
main(63bcca4) and pushed356b10d.The conflict was with the new fallback timer. It remains in
copy_mapped, wrapping both the sparse-region reads and the existing piece retries, so diagnostics still measure the complete fallback. The PR remains a single commit with 77 added lines inhost.rs.Both workspace Clippy configurations, the sparse-copy regression with default and all features, and the asset-policy check pass locally. Hosted CI passed, including the full workspace tests. GitHub reports the PR as mergeable again.
AI-assisted (Codex).
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 13:23 UTC · original
@ifBars I compared exact
356b10dagainst63bcca43with the same 8 MiB test calling productioncopy_mapped. Each timed copy was checked byte for byte, including all committed data and zero-filled holes. The GPU crate was built with-C opt-level=2for this CPU-only test.Each figure is the median of three process medians, with 15 copies per process and interleaved revisions. The fully committed and one-hole ranges overlap across processes, so I would treat those as inconclusive. The alternating-page case was faster in all three PR processes, about 2.7× at the median. Your existing remap regression passed too.
The opt-in benchmark is test-only and directly on your head.
Run the emitted GPU test executable with
--exact host::tests::sparse_copy_shape_matrix --ignored --nocapture --test-threads=1. If you reuse the test, please retain the Git author, or addCo-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding it into another commit. AI-assisted with Codex.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.