Repository navigation
Conversation
Dukestar69
left a comment
There was a problem hiding this comment.
Verified on RTX 5090 against origin/main (63bcca4):
cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: 11/11 passed (includingwithheld_index_matches_overlap_scan).cargo test -p victory-gpu --lib host::withholding -- --test-threads=1: passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Cleanly indexes withheld ranges during copy-back to avoid repeated linear overlap scans.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
AurumCarlos
left a comment
There was a problem hiding this comment.
The index is correct. Sorted by (shadow, start) with a running max end per shadow, the last entry with (copy, start) < (shadow, to) is the latest range of that shadow starting before to, and the overlap test reduces to from < max_end. That matches the old predicate, including empty ranges (start == end), which withheld_index_matches_overlap_scan covers. The host side also keeps the old two-pass behaviour: declared writes are checked against the initial set, marked pages against the final one, with no further propagation. Keeping identities as usize is fine because back holds the Arcs until after copy_back_marks, as your comment says.
Two remarks:
1. The edited test lost a case. In marked_pages_go_back_by_the_bytes_the_gpu_changed, page 2 used to be unmarked ("page 2 not marked"): it checked that a page nobody marked keeps the title's bytes and that the copy's byte there isn't put back. Now page 2 is marked and withheld, and the assertions are the same, so the test passes either way and the unmarked path is no longer exercised. Using a fourth page for the withheld case (the pool would need 4 pages) would keep both.
2. Other open PRs use the old signature. copy_back_marks now takes &Withheld instead of &[(Arc<Shadow>, usize, usize)]. #3099 ("drop only marked pages for withheld marked ranges") and #1998 ("keep valid marked writes beside withheld ranges") both change what a withheld range does in this same function, and both build and pass the slice. #3145 and #3165 rewrite the top of copy_back_marks. You've trial-merged with #3211. A note in the description about the ones that would conflict (or a quick git merge-tree against #3099/#1998) would help whoever merges them in sequence.
|
The test now uses a fourth page for the withheld case ( |
Problem
When a GPU submission withholds writes after a memory miss, the host scans all initially withheld ranges for each declared write. It then scans the final withheld ranges again for each marked page. Both scans include ranges owned by other shadows.
Change
Index larger sets by shadow identity and start address, with the maximum end seen so far for each shadow. Each write or page then needs one binary search. Sets of 32 ranges or fewer still use a linear scan. Declared writes are checked against the original withheld set, and marked pages see the final set after that pass. This preserves the existing overlap and whole-page rules.
Synthetic benchmark
Medians of 20 interleaved runs on Windows, Core Ultra 9 275HX, Rust 1.98.1 with
-C opt-level=3. Each case distributes ranges and pages over 128 shadows. It measures building the range sets and checking declared writes and marked pages. Both implementations produced identical decisions. The benchmark excludes bitmap readback, waiting for the GPU and writing bytes to guest memory.Validation
victory-gpulibrary suite with diagnostics: 247 passed, 1 ignored. Strict Clippy and the asset policy check passed.Integration notes
A trial merge with #3211 succeeds. Trial merges with #3099 and #1998 conflict in
host.rsandshadow.rsbecause they change the input and meaning of withheld ranges. Keep their original range data for the behavior change and use an index for overlap queries. #3145 and #3165 conflict inshadow.rsaround mark processing. Their mark-owner lifetime fix must remain outside the marks lock when combining it with the indexed query.Coordination claim. No game files used. AI-assisted (Codex).