GPU: guard non-positive frame counts and test copystat #2067

Closed
fuzeofficlal wants to merge 1 commit from upstream-pr/2069 into main
fuzeofficlal commented 2026-11-25 04:20:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T04:20:39Z.


Closes #919.

Summary

  • Clamp non-positive or non-finite frames inputs in copystat::log to 1.0 so per-frame averages never format NaN or inf while still draining counters, snapshots, and copy-range maps.
  • Extract parse_mode for deterministic VICTORY_COPY_MODE unit testing.

Testing

  • Added unit tests in crates/victory-gpu/src/copystat.rs verifying counter array length alignment, parse_mode, range/snapshot accumulation and draining, NaN/inf-free log formatting across 0.0, -3.0, NAN, and ±INFINITY, and process memory queries.
  • cargo test -p victory-gpu --features diagnostics --locked copystat, cargo clippy, and cargo xtask policy.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6597132173 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2069). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T04:20:39Z. --- Closes #919. ### Summary - Clamp non-positive or non-finite `frames` inputs in `copystat::log` to `1.0` so per-frame averages never format `NaN` or `inf` while still draining counters, snapshots, and copy-range maps. - Extract `parse_mode` for deterministic `VICTORY_COPY_MODE` unit testing. ### Testing - Added unit tests in `crates/victory-gpu/src/copystat.rs` verifying counter array length alignment, `parse_mode`, range/snapshot accumulation and draining, `NaN`/`inf`-free log formatting across `0.0`, `-3.0`, `NAN`, and `±INFINITY`, and process memory queries. - `cargo test -p victory-gpu --features diagnostics --locked copystat`, `cargo clippy`, and `cargo xtask policy`.
catminou4 commented 2026-11-25 05:05:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:26:33Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Non-positive frame counts guarded + copystat test — validation hardening on the copy path.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051851428 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2069#pullrequestreview-6051851428). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T04:26:33Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Non-positive frame counts guarded + copystat test — validation hardening on the copy path.
DenRakEiw commented 2026-11-25 05:05:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:41:41Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --features diagnostics --lib copystat:: — 4 passed, 0 failed
  • cargo clippy -p victory-gpu --features diagnostics --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean non-positive frame-count guard and unit test coverage for copystat. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051958797 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2069#pullrequestreview-6051958797). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T04:41:41Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --features diagnostics --lib copystat::` — 4 passed, 0 failed - `cargo clippy -p victory-gpu --features diagnostics --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean non-positive frame-count guard and unit test coverage for `copystat`. Looks good. AI-assisted (Gemini 4 Neon).
jeremygold02 commented 2026-11-25 05:06:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:25:00Z.


Triage verdict — Keep the diagnostic guard, isolate the global-state regression (98dd74f)

Evidence

  • @fuzeofficlal’s frame guard and mode parsing match @geiyiliyabumo’s earlier #1188. This version updates the counter-enum assertion for current main and checks the formatted output rather than treating a floating-point divide as a panic. The older PR closed without merging. Current guard · Prior maintainer feedback
  • The new drain test clears the process-wide counters and maps, then asserts all of them stay empty. Other GPU tests using diagnostics can write those same globals in parallel. An unrelated producer can invalidate the emptiness assertions even if the drain is correct. Drain test

Checks and limits

  • Source comparison of both versions and the current counters. I did not reproduce a parallel test failure.

Next step

  • Run the drain test in an isolated test process or give it isolated counter state. Keep the finite-output assertions and preserve the earlier contribution credit.

This verification was AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152822530 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2069#issuecomment-7152822530). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-25T04:25:00Z. --- **Triage verdict — Keep the diagnostic guard, isolate the global-state regression** (`98dd74f`) **Evidence** - @fuzeofficlal’s frame guard and mode parsing match @geiyiliyabumo’s earlier #1188. This version updates the counter-enum assertion for current `main` and checks the formatted output rather than treating a floating-point divide as a panic. The older PR closed without merging. [Current guard](https://github.com/Marvisak/VIctory/blob/98dd74fe1e7b2399bd89048a037d3b05ef6dc991/crates/victory-gpu/src/copystat.rs#L210-L224) · [Prior maintainer feedback](https://github.com/Marvisak/VIctory/pull/1188#issuecomment-7148650352) - The new drain test clears the process-wide counters and maps, then asserts all of them stay empty. Other GPU tests using diagnostics can write those same globals in parallel. An unrelated producer can invalidate the emptiness assertions even if the drain is correct. [Drain test](https://github.com/Marvisak/VIctory/blob/98dd74fe1e7b2399bd89048a037d3b05ef6dc991/crates/victory-gpu/src/copystat.rs#L395-L446) **Checks and limits** - Source comparison of both versions and the current counters. I did not reproduce a parallel test failure. **Next step** - Run the drain test in an isolated test process or give it isolated counter state. Keep the finite-output assertions and preserve the earlier contribution credit. This verification was AI-assisted.
upipibi commented 2026-11-25 05:06:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T04:41:55Z.


Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at 98dd74f.

  • cargo test -p victory-gpu --locked: 141 passed, 2 failed, 2 ignored. The 2 are #1744's heap-cap failures on main. The new tests aren't in this run, because copystat is cfg(all(windows, feature = "diagnostics")).
  • --features diagnostics -- copystat: 4 passed (counter_enum_matches_array_length, parse_mode_maps_known_and_unknown_values, process_memory_queries_succeed, range_and_snapshot_accumulate_and_log_guards_invalid_frames).

Same as main on this hardware. Not run: a title.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153082619 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2069#issuecomment-7153082619). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T04:41:55Z. --- Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at `98dd74f`. - `cargo test -p victory-gpu --locked`: 141 passed, 2 failed, 2 ignored. The 2 are #1744's heap-cap failures on `main`. The new tests aren't in this run, because `copystat` is `cfg(all(windows, feature = "diagnostics"))`. - `--features diagnostics -- copystat`: 4 passed (`counter_enum_matches_array_length`, `parse_mode_maps_known_and_unknown_values`, `process_memory_queries_succeed`, `range_and_snapshot_accumulate_and_log_guards_invalid_frames`). Same as `main` on this hardware. Not run: a title. AI-assisted (Claude Code).
fuzeofficlal commented 2026-11-25 05:06:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T05:00:37Z.


Updated in 9fe73dfe — thanks @jeremygold02. Encapsulated counter/range/snapshot state in Stats so unit tests exercise an isolated Stats::new() instance without racing concurrent diagnostics producers on the process-wide STATS singleton.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153364723 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2069#issuecomment-7153364723). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T05:00:37Z. --- Updated in `9fe73dfe` — thanks @jeremygold02. Encapsulated counter/range/snapshot state in `Stats` so unit tests exercise an isolated `Stats::new()` instance without racing concurrent `diagnostics` producers on the process-wide `STATS` singleton.
upstream-sync closed this pull request 2026-11-25 11:03:42 +00:00
Marvisak commented 2026-11-25 11:05:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:25:50Z.


Automated triage for the maintainers.

Proposed close: the guard is for a case that can't happen, and the rest is a refactor of a diagnostics-only module.

  • The guard. copystat::log has one caller, in the frame() function of victory-gpu/src/host.rs. That function increments copy_stats_frames just before it calls log, so frames is always at least 1. The same guard was the reason #1188 was closed.
  • The rest. The other ~300 changed lines move the counters into a Stats struct and add tests of the log formatting, all for a module that only builds with --features diagnostics. No behaviour changes.

A bug in what copystat measures would change this verdict. The PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159683939 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2069#issuecomment-7159683939). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T10:25:50Z. --- <!-- victory-triage v1 head=9fe73dfef7e53c0c29d53ddf4de387f32078ef81 verdict=proposed-close at=2026-11-25T10:25:37Z --> Automated triage for the maintainers. Proposed close: the guard is for a case that can't happen, and the rest is a refactor of a diagnostics-only module. - **The guard.** `copystat::log` has one caller, in the `frame()` function of `victory-gpu/src/host.rs`. That function increments `copy_stats_frames` just before it calls `log`, so `frames` is always at least 1. The same guard was the reason #1188 was closed. - **The rest.** The other ~300 changed lines move the counters into a `Stats` struct and add tests of the log formatting, all for a module that only builds with `--features diagnostics`. No behaviour changes. A bug in what `copystat` measures would change this verdict. The PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-25 11:05:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T10:46:02Z.


Agreed with the triage analysis — host.rs::frame() increments copy_stats_frames immediately before calling copystat::log, so frames == 0 cannot occur on main. Closing to keep the review queue focused.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160144690 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2069#issuecomment-7160144690). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T10:46:02Z. --- Agreed with the triage analysis — `host.rs::frame()` increments `copy_stats_frames` immediately before calling `copystat::log`, so `frames == 0` cannot occur on `main`. Closing to keep the review queue focused.

Pull request closed

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
Marvisak/VIctory!2067
No description provided.