GPU/diagnostics: count the pieces that differ on the relay and card merges #842

Merged
CwWwWwW merged 1 commit from upstream-pr/842 into main 2026-11-29 08:16:58 +00:00
CwWwWwW commented 2026-11-28 07:34:55 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CwWwWwW on 2026-11-28T07:34:55Z.


Ported to trustno1-coder/VIctory-NVIDIA from the same change submitted to fxceless/victory-fork as PR #1479 (head 481290749e, author CwWwWwW). The fork's own line was dropped when it rebased onto 959dcaf (5dbf5ce), so this is submitted here directly. The description below is the original one; its 'Verification' numbers refer to the fork tree. Rebased onto main 63b902f.

Problem

C::BackDiffer is what the frame account prints as "finding N pieces that differ" (copystat.rs:1228). It is added in one place only: Shadow::copy_back_with (shadow.rs:3569), the copy-back path for copies not in the card's memory without the relay.

The other three copy-back merge paths find the differing pieces and put them back, but never count them:

  • Shadow::relay_merge (shadow.rs:3712), the PC relay's landing merge, called once per differing piece from Host::relay_hand_back (host.rs:4997-5001);
  • Shadow::card_merge (shadow.rs:4700), for copies in the card's memory (host.rs:7056, and on the wide-merge threads at host.rs:7039);
  • Shadow::card_merge_relay (shadow.rs:4766), relay plus card memory (host.rs:6628-6634).

Each compares the piece's bytes and finds a difference (via first_difference) before merging, but adds nothing to BackDiffer. In relay/card configurations the account therefore says "0 pieces that differ" while the merges find hundreds per frame, which makes the frame line misreport where the time goes.

Evidence

  • Grep of the tree at 9a9091d: add(C::BackDiffer, ...) appears only at shadow.rs:3569; the three merges' compare blocks have no counter.
  • The counter's unit is 64 KiB pieces (differing.len() at shadow.rs:3569); the merges run once per such piece, so they count 1 each.
  • Found while auditing avatarmanz/VIctory-7900XTX PR #237 item 3 as research evidence; the change is written against this tree's own functions and takes no code from it.

Change

Three #[cfg(feature = "diagnostics")] increments 鈥?one after each merge's compare found the piece differing, i.e. where the merge is about to do work 鈥?for relay_merge, card_merge and card_merge_relay. No other code, no runtime path (the lines do not compile without the diagnostics feature).

Verification

  • default gpu lib suite: cargo test -p victory-gpu --lib --locked -- --test-threads=1 鈥?242 passed, 0 failed, 7 ignored (unchanged)
  • cargo check -p victory-gpu --all-targets --features diagnostics --locked 鈥?clean (exit 0)
  • cargo clippy -p victory-gpu --all-targets --features diagnostics --locked -- -D warnings 鈥?clean (exit 0)
  • git diff --check clean; shadow.rs keeps its 160 pre-existing fmt entries (same count as the base)

Diagnostics-only; no D3D12 call, barrier, ordering or allocation is touched.

Verification on this tree (base 63b902f, 2026-11-27)

  • cargo check --workspace --all-targets --locked: pass (Rust 1.98.1, the version pinned in rust-toolchain.toml)
  • cargo check --workspace --all-targets --all-features --locked: pass
  • cargo clippy --workspace --all-targets --locked -- -D warnings (and --all-features): this change adds no clippy finding. The only failures are on unmodified lines of main (clippy::manual_is_multiple_of at crates/victory-gpu/src/shadow.rs:1708 and crates/victory-gpu/src/descriptor.rs:1234, clippy::let_and_return at crates/victory-shader/src/emit/mod.rs:2768); CI run 46104876336 on 63b902f failed on those before this change.
  • cargo test was not run in the author's environment (Windows VM without an MSVC toolchain; test binaries could not be linked there). CI on Windows and a run on the card should confirm.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5537939605 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/842). Originally posted by [CwWwWwW](https://github.com/CwWwWwW) on 2026-11-28T07:34:55Z. --- Ported to trustno1-coder/VIctory-NVIDIA from the same change submitted to fxceless/victory-fork as PR #1479 (head 481290749efc8431145b043908361e43940f4a7b, author CwWwWwW). The fork's own line was dropped when it rebased onto 959dcaf (5dbf5ce), so this is submitted here directly. The description below is the original one; its 'Verification' numbers refer to the fork tree. Rebased onto main 63b902f. ## Problem `C::BackDiffer` is what the frame account prints as "finding N pieces that differ" (`copystat.rs:1228`). It is added in **one** place only: `Shadow::copy_back_with` (`shadow.rs:3569`), the copy-back path for copies not in the card's memory without the relay. The other three copy-back merge paths find the differing pieces and put them back, but never count them: - `Shadow::relay_merge` (`shadow.rs:3712`), the PC relay's landing merge, called once per differing piece from `Host::relay_hand_back` (`host.rs:4997-5001`); - `Shadow::card_merge` (`shadow.rs:4700`), for copies in the card's memory (`host.rs:7056`, and on the wide-merge threads at `host.rs:7039`); - `Shadow::card_merge_relay` (`shadow.rs:4766`), relay plus card memory (`host.rs:6628-6634`). Each compares the piece's bytes and finds a difference (via `first_difference`) before merging, but adds nothing to `BackDiffer`. In relay/card configurations the account therefore says "0 pieces that differ" while the merges find hundreds per frame, which makes the frame line misreport where the time goes. ## Evidence - Grep of the tree at `9a9091d`: `add(C::BackDiffer, ...)` appears only at `shadow.rs:3569`; the three merges' compare blocks have no counter. - The counter's unit is 64 KiB pieces (`differing.len()` at `shadow.rs:3569`); the merges run once per such piece, so they count 1 each. - Found while auditing `avatarmanz/VIctory-7900XTX` PR #237 item 3 as research evidence; the change is written against this tree's own functions and takes no code from it. ## Change Three `#[cfg(feature = "diagnostics")]` increments 鈥?one after each merge's compare found the piece differing, i.e. where the merge is about to do work 鈥?for `relay_merge`, `card_merge` and `card_merge_relay`. No other code, no runtime path (the lines do not compile without the diagnostics feature). ## Verification - default gpu lib suite: `cargo test -p victory-gpu --lib --locked -- --test-threads=1` 鈥?**242 passed, 0 failed, 7 ignored** (unchanged) - `cargo check -p victory-gpu --all-targets --features diagnostics --locked` 鈥?clean (exit 0) - `cargo clippy -p victory-gpu --all-targets --features diagnostics --locked -- -D warnings` 鈥?clean (exit 0) - `git diff --check` clean; `shadow.rs` keeps its 160 pre-existing fmt entries (same count as the base) Diagnostics-only; no D3D12 call, barrier, ordering or allocation is touched. ## Verification on this tree (base 63b902f, 2026-11-27) - cargo check --workspace --all-targets --locked: pass (Rust 1.98.1, the version pinned in rust-toolchain.toml) - cargo check --workspace --all-targets --all-features --locked: pass - cargo clippy --workspace --all-targets --locked -- -D warnings (and --all-features): this change adds no clippy finding. The only failures are on unmodified lines of main (clippy::manual_is_multiple_of at crates/victory-gpu/src/shadow.rs:1708 and crates/victory-gpu/src/descriptor.rs:1234, clippy::let_and_return at crates/victory-shader/src/emit/mod.rs:2768); CI run 46104876336 on 63b902f failed on those before this change. - cargo test was not run in the author's environment (Windows VM without an MSVC toolchain; test binaries could not be linked there). CI on Windows and a run on the card should confirm.
Dukestar69 commented 2026-11-28 07:46:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T07:46:02Z.

Review: APPROVED


Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean 6-line merge in crates/victory-gpu/src/shadow.rs; cargo xtask policy passed (294 files ok).
  • Tests (RTX 5090):
    • cargo test -p victory-gpu --lib shadow:: passed (36 passed; 0 failed; 2 ignored) and --features diagnostics --lib shadow:: passed (36 passed; 0 failed; 2 ignored).
    • cargo test -p victory-gpu --lib host:: and --features diagnostics --lib host:: both passed (129 passed; 0 failed; 16 ignored).

Clean #[cfg(feature = "diagnostics")] counter accounting for BackDiffer on relay and card merges. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6096610174 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/842#pullrequestreview-6096610174). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T07:46:02Z. **Review:** APPROVED --- Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean 6-line merge in `crates/victory-gpu/src/shadow.rs`; `cargo xtask policy` passed (`294 files ok`). - **Tests (RTX 5090)**: - `cargo test -p victory-gpu --lib shadow::` passed (`36 passed; 0 failed; 2 ignored`) and `--features diagnostics --lib shadow::` passed (`36 passed; 0 failed; 2 ignored`). - `cargo test -p victory-gpu --lib host::` and `--features diagnostics --lib host::` both passed (`129 passed; 0 failed; 16 ignored`). Clean `#[cfg(feature = "diagnostics")]` counter accounting for `BackDiffer` on relay and card merges. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Sign in to join this conversation.
No reviewers
No labels
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.

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