Repository navigation
fix(gpu): recheck uncommitted blocks before skipping writes - #514
jeremygold02 wants to merge 2 commits into
Conversation
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>
Only cache whole uncommitted 64 KiB blocks and revalidate contiguous regions on each refresh so ordinary page commits become visible.
|
Ran this in the world on NVIDIA / Linux, in case that helps (it was tested on Windows only). RTX 5080, CachyOS, proton-cachyos (vkd3d-proton 3.2.0), Series X 1.0.2.1, diagnostics build of AI-assisted (Claude Code); numbers from the run's log. |
|
Tested the partly committed view-block change in a Windows integration build alongside #515. All nine watch tests passed, including writes_in_partly_committed_view_blocks_are_reported and unmapped_blocks_are_reported_once_until_mapped. I have no isolated frame-time measurement for this patch. |
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 8540a0e (on top of #464) on Windows 11, RTX 5070, MSVC: cargo test -p victory-gpu -- --test-threads=1 45 passed, including writes_in_partly_committed_view_blocks_are_reported. Clippy's 1 warning is the existing one in host.rs.
- The fix matches the failure: a block cached as
absentis skipped only while oneVirtualQuerystill shows its regionMEM_RESERVE/MEM_FREE. A block that has since been committed by an ordinaryVirtualAlloc(MEM_COMMIT), which raises no runtime remap notification, is reopened and copied, so its writes are no longer lost. uncommitted_untilreuses one query for the following blocks of the same region, which keeps the optimisation that #464 was after.title_memory_remappedalso clearsabsentin the remapped range, so a remap can't leave a stale "unmapped" entry.- The rest of the test diff is rustfmt reflow of existing assertions.
AI-assisted (Claude Code).
…before skipping writes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Measured on Linux: RTX 5090 (620.73.04), Wine 11.22 with the wineserver view-tree patch from #340, vkd3d-proton from GE-Proton11-14. Prologue, about 3,100 draws per frame; medians over about 55 world summary lines per run. Base:
AI-assisted (Claude Code). |
Dependency and scope
This follow-up is stacked on #464 at
41af42e. The additional change is the single commit8540a0e. It keeps the sparse-memory copy optimization and fixes two ways it can miss ordinary writes.#185 also exercises a partially committed range in its broader shadow-copy implementation. This patch targets the
Guards::absentcache introduced by #464 and inherited by #490.After a failed attempt to guard a 64 KiB block, #464 queries its first address. A section can have a reserved first page and a committed, writable 4 KiB page farther into that same block. Marking the entire block absent makes a later write to the committed page invisible to the journal. An ordinary page commit after the first refresh can also go unnoticed if it does not go through the runtime's physical-view remap hook.
The change requires the queried uncommitted region to cover the entire block. Before skipping a previously absent block, the next refresh rechecks the region. Adjacent absent blocks use the same query result for that pass. A failed query or partial coverage leaves the block eligible to be reported dirty.
Windows verification
0x19and0x27. After the guest wrote0xA6and0xB7, submission throughHost::executeleft both mapped D3D12 shadows at their seed values on GPU: remember unmapped guarded view blocks instead of re-copying them every submission #464. With this commit both host shadows contained the new bytes. The synthetic submissions contained no draws or dispatches.host.rson GPU: remember unmapped guarded view blocks instead of re-copying them every submission #464 and on this branch.The focused test command is
cargo test -p victory-gpu --lib watch::tests:: -- --test-threads=1.