Skip writeback waits for unchanged page-mapping batches #4607

Closed
github-bot wants to merge 38 commits from github-bot/gh-4606 into main AGit
Owner

@⁠yumaste on GitHub · 2026-11-30 23:44 UTC · original
yumaste:nvidia/perf-noop-page-remaps → main · +1793 −986 · 42 files · 36 commits · closed without merging

What it changes

CopyPageMappingsBatchX waits for overlapping GPU writeback before the mapper can see whether the batch actually changes any physical page. With VICTORY_REMAP_SKIP_UNCHANGED=1, the single-threaded mapper checks the whole batch under the physical view lock before that wait. It can complete the batch when each alias still points to the same section and page index and each unmap covers an existing hole. A change to any page, contention on the view lock or VICTORY_REMAP_SYNC=1 sends the batch through the existing wait and mapping path. VICTORY_REMAP_TIMING=1 reports skipped batches and separates the check from the writeback wait in slow calls.

How it was tested

Windows, RTX 5080 Laptop GPU, commit e0945309. The A/B adds 256 copies of 64 MiB ahead of a GPU write to a synthetic title page. The queue benchmark uses a stand-in mapper and verifies the written byte after each flight lands. Separate XMem tests exercise the real page identity and hole checks. Each reported result is the median of 10 timed calls per case in an isolated process.

Case Baseline Opt-in
Same physical mapping with writeback pending 42.86–42.87 ms 0.005 ms
Changed mapping with writeback pending 42.87–42.93 ms 42.87–42.90 ms

Forcing VICTORY_REMAP_SYNC=1 restores the wait in the unchanged case (42.85 ms). The test isolates one potentially avoidable streaming stall. Gameplay and frame-time A/B are pending. The published trace in #3909 reports 0.0 remap waits per frame at its displayed precision, so the frequency of eligible stalls and the effect on frame times still need a route that reproduces them.

  • cargo test --locked -p victory-gpu --lib -- --test-threads=1 passed with 1,133 tests and 67 ignored.
  • cargo test --locked -p victory-hle --lib modules::xmem::tests -- --test-threads=1 passed with 48 tests and 1 ignored.
  • Ran remap_during_a_gpu_flight_ab --ignored --nocapture --test-threads=1 in isolated GPU test processes with VICTORY_ADAPTER=RTX 5080, VICTORY_RELAY=2, VICTORY_LAND_BEFORE_REMAP=1 and both values of VICTORY_REMAP_SKIP_UNCHANGED. One run also forced VICTORY_REMAP_SYNC=1.
  • cargo clippy --locked -p victory-hle -p victory-gpu --all-targets -- -D warnings passed, also with --all-features.
  • cargo run --locked --quiet -p xtask -- policy --staged passed.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. #1575 narrows the writeback wait to overlapping ranges, #3277 excludes explicitly skipped ranges, #3850 batches mapping work after the wait, and #4366 extends the queue to 2 MiB page mappings. This patch checks whether a batch of requested mappings changes physical backing at all.
**@⁠yumaste** on GitHub · 2026-11-30 23:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4606) `yumaste:nvidia/perf-noop-page-remaps` → `main` · +1793 −986 · 42 files · 36 commits · closed without merging ## What it changes `CopyPageMappingsBatchX` waits for overlapping GPU writeback before the mapper can see whether the batch actually changes any physical page. With `VICTORY_REMAP_SKIP_UNCHANGED=1`, the single-threaded mapper checks the whole batch under the physical view lock before that wait. It can complete the batch when each alias still points to the same section and page index and each unmap covers an existing hole. A change to any page, contention on the view lock or `VICTORY_REMAP_SYNC=1` sends the batch through the existing wait and mapping path. `VICTORY_REMAP_TIMING=1` reports skipped batches and separates the check from the writeback wait in slow calls. ## How it was tested Windows, RTX 5080 Laptop GPU, commit `e0945309`. The A/B adds 256 copies of 64 MiB ahead of a GPU write to a synthetic title page. The queue benchmark uses a stand-in mapper and verifies the written byte after each flight lands. Separate XMem tests exercise the real page identity and hole checks. Each reported result is the median of 10 timed calls per case in an isolated process. | Case | Baseline | Opt-in | | --- | ---: | ---: | | Same physical mapping with writeback pending | 42.86–42.87 ms | 0.005 ms | | Changed mapping with writeback pending | 42.87–42.93 ms | 42.87–42.90 ms | Forcing `VICTORY_REMAP_SYNC=1` restores the wait in the unchanged case (42.85 ms). The test isolates one potentially avoidable streaming stall. Gameplay and frame-time A/B are pending. The published trace in #3909 reports 0.0 remap waits per frame at its displayed precision, so the frequency of eligible stalls and the effect on frame times still need a route that reproduces them. - `cargo test --locked -p victory-gpu --lib -- --test-threads=1` passed with 1,133 tests and 67 ignored. - `cargo test --locked -p victory-hle --lib modules::xmem::tests -- --test-threads=1` passed with 48 tests and 1 ignored. - Ran `remap_during_a_gpu_flight_ab --ignored --nocapture --test-threads=1` in isolated GPU test processes with `VICTORY_ADAPTER=RTX 5080`, `VICTORY_RELAY=2`, `VICTORY_LAND_BEFORE_REMAP=1` and both values of `VICTORY_REMAP_SKIP_UNCHANGED`. One run also forced `VICTORY_REMAP_SYNC=1`. - `cargo clippy --locked -p victory-hle -p victory-gpu --all-targets -- -D warnings` passed, also with `--all-features`. - `cargo run --locked --quiet -p xtask -- policy --staged` passed. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. #1575 narrows the writeback wait to overlapping ranges, #3277 excludes explicitly skipped ranges, #3850 batches mapping work after the wait, and #4366 extends the queue to 2 MiB page mappings. This patch checks whether a batch of requested mappings changes physical backing at all.
Co-authored-by: Andrei Turcan <[email protected]>
Co-authored-by: Andrei Turcan <[email protected]>
`slots_showing` took the slot's `Made` key with `?`, but `Made` has keys
for the title's `count` slots only while `kept` also has the dynamic
ones: a host texture shown by a dynamic slot was no longer reported, so
it was no longer blocked and could be chosen (freeing nothing, as the
dynamic slot holds a reference, while the title made a second copy).
Those slots are reported again with key 0, as before the key was carried;
they are never put back to waiting, only counted as blocking. Test:
`a_dynamic_slot_showing_a_texture_still_blocks_its_eviction`.

`SLOT_LOOKING` is now cleared by a drop guard, so a look that panics does
not stop every later look.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit b23c0c4038)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Search for existing work first, make one change per branch from the latest main, keep the template, never make up results, and get approval before posting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Covers reporting problems and sending pull requests: check for overlap first, test existing pull requests, and don't rely on the label bot's green tick.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`loose_metadata_reads_version_0x403` held 0x118 bytes the title handed
over, as a hex string. The asset policy refuses it
(`crates/victory-shader/src/native.rs: 560-character hex/base64 run`),
so `cargo xtask policy` and xtask's `repository_passes_policy` failed on
main since 698ab79e. The test now builds the same shape with `record()`:
the 0x18-byte header, a sampler, SRV and UAV table, a CBV, a skipped
declaration and the end record. It checks what the old one did, plus the
lower bounds, the root parameters, a container from loose_compute, and a
size that disagrees.

It still catches the 0x403 cases it is for: with the 0x403 arm removed,
or 0x403 read with v3's record offset (0x38), v2's header (0xc) or v2's
record offset (0x10), it fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
split_lds_wave32_read_after_read_barrier_coalescing_and_parity failed on
main at neg_uav_load_between_reads, mask=ALL: BWBRRBWBR where the test
expects BWBRBRBWBR.

The case puts buffer_load_dword v8 between the two LDS reads as a call
that must keep the barrier between them, but nothing reads v8. Since
dbdd6ada, optimise drops dead instructions inside its rounds: round one
keeps the barrier (the load resets the barrier state), DEAD then drops
the unread load, and round two finds the two reads with only the barrier
between them and drops it. That is correct: without the load the case is
adjacent_rar, which the test expects to become BWBRRBWBR. BARRIERS alone
runs no DEAD, which is why only the ALL assertion failed.

The negative now adds the loaded value into v6 before out[128 + t] is
stored. Thread t loads out[t], which starts at 0 and which only thread t
writes, after the load, so the expected outputs stay the same, and the
load stays live under every mask.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `check` job has stopped at its first step on every pull request: with
`-D warnings` Clippy finds, on `main` (84bd61e2):

- `victory-shader`: `Lowered::loop_caps`, kept for tests, is read by none
  now (allowed, with a note).
- `victory-gpu`: `Shadow::ranged` has no caller left; its two parts are
  asked for by `ranged_parts` (removed, its sentence moved there). A test's
  `seed % 3 == 0` is `is_multiple_of`. With all features, the free
  function `mb` of `copystat.rs` is shadowed by a closure of the same name
  wherever it was called (removed).
- `victory-hle`: a `match` that is `unwrap_or_default` (the same value;
  its comment kept).

Nothing of this changes what runs. With it both Clippy steps pass, and
the job reaches its tests, of which two in `victory-gpu` were stale:

- `shader_cache`'s key test still named the four switches of the
  differential fuzzer, which a1fe8350 reverted out of the translator.
- `list::thin`'s `bindings_record_no_work` wants every call named as
  binding, waiting or work; `BEGIN_QUERY` and `END_QUERY` (471d05c4) were
  in none. They are work, as the waits take them today.

`cargo test -p victory-gpu`: 1,133 pass, none fail.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The title's metadata this test replaced had a sampler of root type 4,
and no other test in the crate reaches `RootType::ImmediateSampler` in
`records()`. The made-up 0x403 block now ends with one (slot 9, no user
data); the test checks that it is read (`used`, root type, slot) and adds
no root parameter (`layout` is unchanged).

With that arm removed, or given an SGPR, the test fails, as it does for
the four 0x403 header and offset mistakes it already caught.

Suggested by Lyrnc in the review of #4223.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The label was never removed, so it stayed on issues that now have logs.
Edits and comments by the issue's author are now checked with the same log
test. A manual run checks every open issue that has the label.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
needs-logs: take the label off when the author adds the logs
Add a short CONTRIBUTING.md
Clippy passes on main again, and two tests of victory-gpu the merges left behind (the check job)
Shader tests: the split-LDS read-after-read test's UAV-load negative reads its load (fails on main since #2623)
Shader tests: the 0x403 loose metadata is built in the test, not the title's bytes
Loader: resume late faults through recorded console instruction replacements (#2393)
A second thread reaching an insertq/extrq while the first replaces it can still end the run with 0xc000001d on Intel (#2393, #3775). #2585 makes that much rarer, not impossible; emulating each time never crashes this way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
AGENTS.md: rules for agents opening issues and pull requests
Claude Code reads CLAUDE.md, not AGENTS.md, so agents using it never saw the rules against duplicate issues and pull requests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
An exact duplicate goes on the existing issue or pull request as a comment, not a new one. Every issue and pull request needs its type and area labels, as title tags the bot turns into labels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 23:48:09 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:36 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4606#issuecomment-7321215261) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
github-bot closed this pull request 2026-12-01 18:42:58 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4607
No description provided.