GPU: the copies timing no longer counts the flush before a title copy twice #1217

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

@⁠neonbyte1 on GitHub · 2026-11-24 16:28 UTC · original
neonbyte1:fix/copies-timing → main · +7 −1 · 1 files · 1 commits · open

The copies figure on the frame-rate line counts some refresh time twice.

HostList::run_deferred starts a timer before each step. For Step::Copy it then calls batch.title_written(), whose Batch::flush already adds each pending refresh's time to PREPARING[0]. The step then adds started.elapsed(), which includes that flush again. Step::Run's RunUs counter (diagnostics) also included the flush.

The timer now restarts after the flush in both places. Nothing else changes: the copies themselves, the order of the steps, and every other counter are as before. The reset in the Run arm is behind the diagnostics feature because only RunUs reads it there.

Why it matters

In world frames with thousands of small title copies per frame, the double counting made copies look several times larger than the work behind it. That misattributed the CPU cost of world frames.

Measured on an RTX 5090 under Wine 11.22 + vkd3d-proton (prologue, ~3,100 draws/frame, medians over ~55 summary lines):

Build copies ms/frame ms/frame Unmapped MB/frame Fallbacks/frame
Before (main + other open PRs) 96.4 324.9 351.9 1,331
After, with #514 also merged 21.4 255.8 5.8 135

The frame-time drop comes from #514; this change only removes the double count from copies.

Checks

  • cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings, with and without --features diagnostics: clean. Cross-compiled from Linux.
  • No test covers these counters.

AI-assisted (Claude Code).

**@⁠neonbyte1** on GitHub · 2026-11-24 16:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1217) `neonbyte1:fix/copies-timing` → `main` · +7 −1 · 1 files · 1 commits · open The `copies` figure on the frame-rate line counts some refresh time twice. `HostList::run_deferred` starts a timer before each step. For `Step::Copy` it then calls `batch.title_written()`, whose `Batch::flush` already adds each pending refresh's time to `PREPARING[0]`. The step then adds `started.elapsed()`, which includes that flush again. `Step::Run`'s `RunUs` counter (diagnostics) also included the flush. The timer now restarts after the flush in both places. Nothing else changes: the copies themselves, the order of the steps, and every other counter are as before. The reset in the `Run` arm is behind the `diagnostics` feature because only `RunUs` reads it there. ### Why it matters In world frames with thousands of small title copies per frame, the double counting made `copies` look several times larger than the work behind it. That misattributed the CPU cost of world frames. Measured on an RTX 5090 under Wine 11.22 + vkd3d-proton (prologue, ~3,100 draws/frame, medians over ~55 summary lines): | Build | `copies` ms/frame | ms/frame | Unmapped MB/frame | Fallbacks/frame | |---|---|---|---|---| | Before (main + other open PRs) | 96.4 | 324.9 | 351.9 | 1,331 | | After, with #514 also merged | 21.4 | 255.8 | 5.8 | 135 | The frame-time drop comes from #514; this change only removes the double count from `copies`. ### Checks - `cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings`, with and without `--features diagnostics`: clean. Cross-compiled from Linux. - No test covers these counters. AI-assisted (Claude Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:24:03 +00:00
Author
Owner

@⁠TG0000 on GitHub · 2026-11-24 16:57 UTC · original

Confirmed by reading: the same double count was in the copies column of my own measuring tool (timer started before batch.title_written()); its wall-clock columns (whole frame, preparation, copy back) do not have it. Thanks for finding it.

AI-assisted (Claude Code).

**@⁠TG0000** on GitHub · 2026-11-24 16:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/1217#issuecomment-7138461942) Confirmed by reading: the same double count was in the `copies` column of my own measuring tool (timer started before `batch.title_written()`); its wall-clock columns (whole frame, preparation, copy back) do not have it. Thanks for finding it. _AI-assisted (Claude Code)._
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 17:59 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at a2e532d: cargo test -p victory-gpu passes, 50 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 17:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/1217#issuecomment-7140008084) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at a2e532d: `cargo test -p victory-gpu` passes, 50 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:19 UTC · original · edited 2026-11-26 01:18 UTC

Automated triage for the maintainers.

Merge candidate. The rebase onto current main resolved the earlier conflict, and it merges cleanly now.

In HostList::run_deferred (crates/victory-gpu/src/host.rs), the Step::Copy arm now restarts started after batch.title_written(). Batch::flush already adds each refresh's time to PREPARING[0], so the old started.elapsed() counted that flush a second time in the copies figure. The Step::Run arm does the same for the RunUs counter, behind diagnostics. I checked that nothing else reads started in between and that the copies themselves and the step order don't change. The per-step Timed watch still measures the whole step, which is fine for a step timer.

CI: passing (check).

Recommending a look, not approving.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1217#issuecomment-7149425958) · edited 2026-11-26 01:18 UTC <!-- victory-triage v1 head=81002a3aa5cf8f1bda20b8945e7001e79d775bf6 verdict=merge-candidate at=2026-11-26T01:18:50Z --> Automated triage for the maintainers. **Merge candidate.** The rebase onto current `main` resolved the earlier conflict, and it merges cleanly now. In `HostList::run_deferred` (`crates/victory-gpu/src/host.rs`), the `Step::Copy` arm now restarts `started` after `batch.title_written()`. `Batch::flush` already adds each refresh's time to `PREPARING[0]`, so the old `started.elapsed()` counted that flush a second time in the `copies` figure. The `Step::Run` arm does the same for the `RunUs` counter, behind `diagnostics`. I checked that nothing else reads `started` in between and that the copies themselves and the step order don't change. The per-step `Timed` watch still measures the whole step, which is fine for a step timer. CI: passing (`check`). Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 16:20 UTC · original · approved these changes

Reviewed 81002a3aa5cf8f1bda20b8945e7001e79d775bf6 (merged cleanly onto 63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 x64 with an NVIDIA GeForce RTX 5090, WARP, and D3D12 Debug Layer.

Audit

  • crates/victory-gpu/src/host.rs:2272, :2294: resetting started = Instant::now() right after batch.title_written() in Step::Copy (and under #[cfg(feature = "diagnostics")] in Step::Run) stops PREPARING[0] and C::RunUs from double-counting Batch::flush() time while _timed = Timed(started, ...) retains the initial Instant by value for whole-step timing. No behavioral or ordering change, and clean under both default and --all-features builds.

Verification

  • Clean merge onto 63bcca43c6a00a758510398fa43096ce7e4f7df0 + cargo run -p xtask -- policy (191 files ok)
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default & --all-features)
  • victory-gpu host:: with VICTORY_D3D12_DEBUG=1:
    • RTX 5090: 34/34 passing (the only failure in the host:: filter is the pre-existing descriptor::host::tests::dynamic_slots_are_held_until_released 1M view-heap cap failure on main; all crate::host:: tests pass).
    • WARP (--features diagnostics, skipping the pre-existing main Debug Layer mismatch in compositor_failure_presents_primary_in_the_same_frame): 35/35 passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 16:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1217#pullrequestreview-6077453696) · **approved these changes** Reviewed `81002a3aa5cf8f1bda20b8945e7001e79d775bf6` (merged cleanly onto `63bcca43c6a00a758510398fa43096ce7e4f7df0`) and verified on Windows 11 x64 with an NVIDIA GeForce RTX 5090, WARP, and D3D12 Debug Layer. ### Audit - `crates/victory-gpu/src/host.rs:2272`, `:2294`: resetting `started = Instant::now()` right after `batch.title_written()` in `Step::Copy` (and under `#[cfg(feature = "diagnostics")]` in `Step::Run`) stops `PREPARING[0]` and `C::RunUs` from double-counting `Batch::flush()` time while `_timed = Timed(started, ...)` retains the initial `Instant` by value for whole-step timing. No behavioral or ordering change, and clean under both default and `--all-features` builds. ### Verification - Clean merge onto `63bcca43c6a00a758510398fa43096ce7e4f7df0` + `cargo run -p xtask -- policy` (`191 files ok`) - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default & `--all-features`) - `victory-gpu` `host::` with `VICTORY_D3D12_DEBUG=1`: - RTX 5090: **34/34** passing (the only failure in the `host::` filter is the pre-existing `descriptor::host::tests::dynamic_slots_are_held_until_released` 1M view-heap cap failure on `main`; all `crate::host::` tests pass). - WARP (`--features diagnostics`, skipping the pre-existing `main` Debug Layer mismatch in `compositor_failure_presents_primary_in_the_same_frame`): **35/35 passed**.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/1217/head:github-bot/gh-1217'
git switch 'github-bot/gh-1217'

Merge

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