GPU: attribute the copy term's VirtualQuery work (FIND-49) #3429

Open
github-bot wants to merge 1 commit from github-bot/gh-3429 into main AGit
Owner

@⁠Jackster on GitHub · 2026-11-27 01:27 UTC · original
Jackster:gpu/copy-term-attribution → main · +49 −2 · 3 files · 1 commits · open

What

The frame line already prints the copy term's pieces — copies … MB, runs … ms, queries … ms, moves … ms, watch time: … protecting, snapshots … MB in … ms — but C::Queries / C::QueryUs were never incremented, so the "queries" column was always zero. With borosf's measurement on FIND-49 (the ~927 ms copy term is per-page bookkeeping, not the kernel copy), that left MoveUs, watch time and snapshots attributable and the VirtualQuery work invisible.

This wires the two VirtualQuery walks into QueryUs:

  • host.rs copy_mapped: the committed() check on a title destination.
  • watch.rs protect_noting: the unmapped(page) query. It nests inside ProtectUs, which the frame line also prints; the comment says so, and the two mean different things (per-query cost vs the whole protect loop).

Plus copystat::get under cfg(test) and one regression test.

Why

FIND-49 asks for exactly this: "Anyone optimizing that term should attribute it on the frame line (copystat MoveUs vs QueryUs vs SnapshotUs vs WatchUs) before writing code." There is no behaviour change, and copystat is behind feature = "diagnostics", so a release build pays nothing.

Testing (Windows 11, Radeon RX 7900 XTX)

  • cargo test -p victory-gpu --lib --features diagnostics: 247 passed / 0 failed / 1 ignored
  • cargo test -p victory-gpu --lib (no feature): 231 passed / 0 failed / 1 ignored — the plain build is unchanged
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean
  • cargo test --workspace --locked: 872 passed / 0 failed (the new test is diagnostics-gated, so the default run is unchanged)

Control: with the two lines removed from protect_noting, watch::tests::a_virtual_query_on_an_unprotectable_page_is_counted fails with its own message ("the unprotectable page's VirtualQuery is attributed to queries").

Synthetic only, no game data. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-27 01:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3429) `Jackster:gpu/copy-term-attribution` → `main` · +49 −2 · 3 files · 1 commits · open ## What The frame line already prints the copy term's pieces — `copies … MB`, `runs … ms`, `queries … ms`, `moves … ms`, `watch time: … protecting`, `snapshots … MB in … ms` — but `C::Queries` / `C::QueryUs` were **never incremented**, so the "queries" column was always zero. With borosf's measurement on FIND-49 (the ~927 ms copy term is per-page bookkeeping, not the kernel copy), that left `MoveUs`, watch time and snapshots attributable and the `VirtualQuery` work invisible. This wires the two `VirtualQuery` walks into `QueryUs`: - `host.rs` `copy_mapped`: the `committed()` check on a title destination. - `watch.rs` `protect_noting`: the `unmapped(page)` query. It nests inside `ProtectUs`, which the frame line also prints; the comment says so, and the two mean different things (per-query cost vs the whole protect loop). Plus `copystat::get` under `cfg(test)` and one regression test. ## Why FIND-49 asks for exactly this: "Anyone optimizing that term should attribute it on the frame line (copystat MoveUs vs QueryUs vs SnapshotUs vs WatchUs) before writing code." There is no behaviour change, and `copystat` is behind `feature = "diagnostics"`, so a release build pays nothing. ## Testing (Windows 11, Radeon RX 7900 XTX) - `cargo test -p victory-gpu --lib --features diagnostics`: **247 passed / 0 failed / 1 ignored** - `cargo test -p victory-gpu --lib` (no feature): **231 passed / 0 failed / 1 ignored** — the plain build is unchanged - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean - `cargo test --workspace --locked`: 872 passed / 0 failed (the new test is diagnostics-gated, so the default run is unchanged) Control: with the two lines removed from `protect_noting`, `watch::tests::a_virtual_query_on_an_unprotectable_page_is_counted` fails with its own message ("the unprotectable page's VirtualQuery is attributed to queries"). Synthetic only, no game data. AI-assisted.
The frame line already printed the copy term's pieces, but C::Queries and
C::QueryUs were never incremented, so the 'queries' column was always zero
while MOVES, watch time and snapshots were attributable.

Time the two VirtualQuery walks the copy path pays for: the committed()
check on a title destination in copy_mapped, and the unmapped(page) query in
protect_noting (which nests inside ProtectUs; both are printed, and the
comment says so). Diagnostics only, so no release cost.

Control: with the two lines removed, the new test fails with its own message.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:34:34 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-27 01:50 UTC · original · approved these changes

Looks good. Both copy-path VirtualQuery sites (crates/victory-gpu/src/host.rs:2515-2517 around texture::committed in copy_mapped and crates/victory-gpu/src/watch.rs:668-670 in protect_noting's unmapped check) are cleanly attributed to the existing C::Queries and C::QueryUs counters without double-counting, and #[cfg(feature = "diagnostics")] gating keeps non-diagnostics builds warning-free.

Verified on commit f7481f4669e6b6efcdf7c4b72e744e5dbb7deebd:

  • cargo xtask policy passed (191 files ok).
  • cargo clippy -p victory-gpu passed cleanly with -D warnings across all four configurations (--lib, --tests, --features diagnostics --lib, and --features diagnostics --tests).
  • watch::tests passed 15/15 (default) and 16/16 (--features diagnostics, including a_virtual_query_on_an_unprotectable_page_is_counted) on both an NVIDIA RTX 5090 and WARP (VICTORY_D3D12_DEBUG=1).
**@⁠fuzeofficlal** on GitHub · 2026-11-27 01:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/3429#pullrequestreview-6082437145) · **approved these changes** Looks good. Both copy-path `VirtualQuery` sites (`crates/victory-gpu/src/host.rs:2515-2517` around `texture::committed` in `copy_mapped` and `crates/victory-gpu/src/watch.rs:668-670` in `protect_noting`'s `unmapped` check) are cleanly attributed to the existing `C::Queries` and `C::QueryUs` counters without double-counting, and `#[cfg(feature = "diagnostics")]` gating keeps non-diagnostics builds warning-free. Verified on commit `f7481f4669e6b6efcdf7c4b72e744e5dbb7deebd`: - `cargo xtask policy` passed (`191 files ok`). - `cargo clippy -p victory-gpu` passed cleanly with `-D warnings` across all four configurations (`--lib`, `--tests`, `--features diagnostics --lib`, and `--features diagnostics --tests`). - `watch::tests` passed 15/15 (default) and 16/16 (`--features diagnostics`, including `a_virtual_query_on_an_unprotectable_page_is_counted`) on both an NVIDIA RTX 5090 and WARP (`VICTORY_D3D12_DEBUG=1`).
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-27 01:52 UTC · original · approved these changes

LGTM — verified on Windows:

  • cargo test -p victory-gpu --lib watch:: passed (15/15 default; 16/16 with --features diagnostics, including a_virtual_query_on_an_unprotectable_page_is_counted)
  • cargo clippy -p victory-gpu --all-targets -- -D warnings and --features diagnostics --all-targets -- -D warnings both passed with 0 warnings
  • cargo xtask policy passed (191 files ok)

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

**@⁠Dukestar69** on GitHub · 2026-11-27 01:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/3429#pullrequestreview-6082452365) · **approved these changes** LGTM — verified on Windows: - `cargo test -p victory-gpu --lib watch::` passed (15/15 default; 16/16 with `--features diagnostics`, including `a_virtual_query_on_an_unprotectable_page_is_counted`) - `cargo clippy -p victory-gpu --all-targets -- -D warnings` and `--features diagnostics --all-targets -- -D warnings` both passed with 0 warnings - `cargo xtask policy` passed (`191 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3429/head:github-bot/gh-3429'
git switch 'github-bot/gh-3429'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3429'
git switch 'github-bot/gh-3429'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3429'
git switch 'github-bot/gh-3429'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3429'
git switch 'main'
git merge --squash 'github-bot/gh-3429'
git switch 'main'
git merge --ff-only 'github-bot/gh-3429'
git switch 'main'
git merge 'github-bot/gh-3429'
git push origin 'main'
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/Marvisak--VIctory!3429
No description provided.