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

Manually merged
github merged 1 commit from github-bot/gh-842 into main 2026-11-29 08:22:02 +00:00 AGit
Owner

@⁠CwWwWwW on GitHub · 2026-11-28 07:34 UTC · original
CwWwWwW:fix/backdiffer-relay-count → main · +6 −0 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC

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.
**@⁠CwWwWwW** on GitHub · 2026-11-28 07:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/842) `CwWwWwW:fix/backdiffer-relay-count` → `main` · +6 −0 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC 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.
C::BackDiffer is what the frame account prints as "finding N pieces that differ" and was added only in copy_back_with. The relay_merge, card_merge and card_merge_relay merges find the differing pieces but never counted them, so the frame line misreported in relay/card configurations. Add one diagnostics-gated increment after each merge compare.

Note: on this tree the relay paths are fallbacks behind the land paths; counting the land paths too would be a small follow-up.

Ported from fxceless/victory-fork PR #1479 (head d2884ccaf11d85521eedddfe75c199827f741732).
Original author: CwWwWwW <[email protected]>.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 14:28:46 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-28 07:46 UTC · original · approved these changes

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).

**@⁠Dukestar69** on GitHub · 2026-11-28 07:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/842#pullrequestreview-6096610174) · **approved these changes** 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).
github manually merged commit 309137eedf into main 2026-11-29 08:22:02 +00:00
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!842
No description provided.