GPU: copy statistics per frame count the frames since their last line #228

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

@⁠Ingenioeren on GitHub · 2026-11-26 05:07 UTC · original
Ingenioeren:fix/copystat-frame-window → main · +44 −5 · 1 files · 1 commits · open

What

Count presented frames between copy-statistics log lines. Use that count to compute the per-frame figures and reset it when the next line is logged.

Why

A local test run reported implausibly large copy figures, including several gigabytes refreshed per frame. The copy counters covered roughly five seconds, while the divisor counted only the frames in the latest one-second FPS sample.

Testing

  • cargo test -p victory-gpu passed on two reruns with 114 passed and four ignored. The new test checks that five windows of 10 frames produce a divisor of 50 and that the next interval starts fresh. Reinstating the one-second reset made the test fail with a divisor of 10. The regression test also passed with --features diagnostics.
  • Two write-watch assertions and a Windows process exit occurred on earlier parallel runs of the patch and were absent from 11 parallel origin/main runs. A serial run reproduced written_pages_are_reported_to_every_asker on both revisions. A separate occlusion-query test failed once on origin/main.
  • cargo clippy -p victory-gpu --all-targets completed with the same warnings as origin/main. cargo run -p xtask -- policy --staged passed.
  • Live in-game copy-statistics output remains unverified for this patch.

AI assistance: prepared with Claude Code, reviewed by Ingenioeren.

This matches the separate frame counter upstream VIctory already uses for its copy statistics (copy_stats_frames).

**@⁠Ingenioeren** on GitHub · 2026-11-26 05:07 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/228) `Ingenioeren:fix/copystat-frame-window` → `main` · +44 −5 · 1 files · 1 commits · open ## What Count presented frames between copy-statistics log lines. Use that count to compute the per-frame figures and reset it when the next line is logged. ## Why A local test run reported implausibly large copy figures, including several gigabytes refreshed per frame. The copy counters covered roughly five seconds, while the divisor counted only the frames in the latest one-second FPS sample. ## Testing - `cargo test -p victory-gpu` passed on two reruns with 114 passed and four ignored. The new test checks that five windows of 10 frames produce a divisor of 50 and that the next interval starts fresh. Reinstating the one-second reset made the test fail with a divisor of 10. The regression test also passed with `--features diagnostics`. - Two write-watch assertions and a Windows process exit occurred on earlier parallel runs of the patch and were absent from 11 parallel `origin/main` runs. A serial run reproduced `written_pages_are_reported_to_every_asker` on both revisions. A separate occlusion-query test failed once on `origin/main`. - `cargo clippy -p victory-gpu --all-targets` completed with the same warnings as `origin/main`. `cargo run -p xtask -- policy --staged` passed. - Live in-game copy-statistics output remains unverified for this patch. AI assistance: prepared with Claude Code, reviewed by Ingenioeren. This matches the separate frame counter upstream VIctory already uses for its copy statistics (`copy_stats_frames`).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:01:48 +00:00
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-26 19:55 UTC · original

Tested natively on Windows 11 (MSVC, RX 7900 XT, driver 32.0.32029.2010), head faab565 against base 4f62c2a. Other heavy jobs were running on the machine at the same time.

  • cargo clippy -p victory-gpu --no-deps --all-targets, with and without --features diagnostics: same warnings as base, none new.
  • cargo test -p victory-gpu --lib --features diagnostics, 20 runs each, base and PR interleaved: 6/20 base runs and 4/20 PR runs had a failure. None of the failing tests is in host.rs. Tests that failed on the PR side and never on base in these runs, once each: query::tests::host_timestamps_are_on_the_title_clock, queue::tests::present_runs_after_a_queues_wait and pipeline::library::tests::concurrent_atomic_writes_publish_one_complete_file. The last two are intermittent on this machine under load.
  • The new test also passes without diagnostics.

I also ran a local test (not part of this PR). It drives a Meter with a null HWND at 3 fps for 11 s, which gives two log lines. Each frame adds 1 MB of title copies through copystat::add/copystat::range and touches 256 fresh pages. I ran it with GPU_TIMES empty and with it filled (10 ms per frame), 3 runs each:

build title copies, MB/frame page faults/frame, 2nd line
base 4f62c2a 4.0 to 5.3 about 1300
this PR 1.0 258 to 260
#213 (ccbf888) 1.0 256 to 261
  • GPU timing on or off made no difference to the copy figures. The GPU time line read 10.0 ms/frame in all three builds, because it already used the interval's frames on base.
  • With either PR, the first line read 418 to 603 page faults/frame. copystat::log starts its fault baseline at 0, so the first line also counts start-up faults. This is the same on base, and neither PR changes it.
  • Zero frames: LogWindow::take is only reached from Meter::frame after frame(), so the divisor is at least 1.

Test coverage: I put the call site back to crate::copystat::log(frames) and kept LogWindow. copy_statistics_count_all_frames_since_the_last_log still passes, but the Meter test reports 4.0 to 5.7 MB/frame. So the new test covers LogWindow on its own, not how Meter::frame uses it.

Overlap with #213: both fix the same divisor and gave the same numbers above. They conflict in Meter::frame, in the 5 s if and in the copystat::log call, so only one can merge as is. The differences:

  • #213 reuses TIMED_FRAMES (diagnostics only), so the GPU time line and the copy line share one count. It adds no test.
  • This PR adds a separate counter (LogWindow, present in all builds) and leaves TIMED_FRAMES for the GPU time line. It adds a unit test for LogWindow.

Not tested: running the game with this build.

**@⁠adrianmjim** on GitHub · 2026-11-26 19:55 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/228#issuecomment-7202105864) Tested natively on Windows 11 (MSVC, RX 7900 XT, driver 32.0.32029.2010), head faab565 against base 4f62c2a. Other heavy jobs were running on the machine at the same time. - `cargo clippy -p victory-gpu --no-deps --all-targets`, with and without `--features diagnostics`: same warnings as base, none new. - `cargo test -p victory-gpu --lib --features diagnostics`, 20 runs each, base and PR interleaved: 6/20 base runs and 4/20 PR runs had a failure. None of the failing tests is in `host.rs`. Tests that failed on the PR side and never on base in these runs, once each: `query::tests::host_timestamps_are_on_the_title_clock`, `queue::tests::present_runs_after_a_queues_wait` and `pipeline::library::tests::concurrent_atomic_writes_publish_one_complete_file`. The last two are intermittent on this machine under load. - The new test also passes without `diagnostics`. I also ran a local test (not part of this PR). It drives a `Meter` with a null HWND at 3 fps for 11 s, which gives two log lines. Each frame adds 1 MB of title copies through `copystat::add`/`copystat::range` and touches 256 fresh pages. I ran it with `GPU_TIMES` empty and with it filled (10 ms per frame), 3 runs each: | build | title copies, MB/frame | page faults/frame, 2nd line | |---|---|---| | base 4f62c2a | 4.0 to 5.3 | about 1300 | | this PR | 1.0 | 258 to 260 | | #213 (ccbf888) | 1.0 | 256 to 261 | - GPU timing on or off made no difference to the copy figures. The `GPU time` line read 10.0 ms/frame in all three builds, because it already used the interval's frames on base. - With either PR, the first line read 418 to 603 page faults/frame. `copystat::log` starts its fault baseline at 0, so the first line also counts start-up faults. This is the same on base, and neither PR changes it. - Zero frames: `LogWindow::take` is only reached from `Meter::frame` after `frame()`, so the divisor is at least 1. Test coverage: I put the call site back to `crate::copystat::log(frames)` and kept `LogWindow`. `copy_statistics_count_all_frames_since_the_last_log` still passes, but the `Meter` test reports 4.0 to 5.7 MB/frame. So the new test covers `LogWindow` on its own, not how `Meter::frame` uses it. Overlap with #213: both fix the same divisor and gave the same numbers above. They conflict in `Meter::frame`, in the 5 s `if` and in the `copystat::log` call, so only one can merge as is. The differences: - #213 reuses `TIMED_FRAMES` (diagnostics only), so the GPU time line and the copy line share one count. It adds no test. - This PR adds a separate counter (`LogWindow`, present in all builds) and leaves `TIMED_FRAMES` for the GPU time line. It adds a unit test for `LogWindow`. Not tested: running the game with this build.
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/228/head:github-bot/gh-228'
git switch 'github-bot/gh-228'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-228'
git switch 'github-bot/gh-228'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-228'
git switch 'github-bot/gh-228'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-228'
git switch 'main'
git merge --squash 'github-bot/gh-228'
git switch 'main'
git merge --ff-only 'github-bot/gh-228'
git switch 'main'
git merge 'github-bot/gh-228'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.