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

Closed
github-bot wants to merge 1 commit from gh-pr/2069/head into gh-pr/2069/base
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 04:20 UTC · original
fuzeofficlal:fix/gpu-copystat-frames-guard-919 → main · +315 −144 · 1 files · 1 commits · closed without merging

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 04:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2069) `fuzeofficlal:fix/gpu-copystat-frames-guard-919` → `main` · +315 −144 · 1 files · 1 commits · closed without merging 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`.
Clamp non-positive or non-finite frame counts in copystat::log to 1.0 so per-frame divisions never format NaN or inf while still draining counters, snapshots, and copy ranges, extract parse_mode, and encapsulate counter state so unit tests verify draining and finite formatting without racing parallel diagnostics producers.

Closes #919
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:53:53 +00:00
github-bot closed this pull request 2026-11-26 04:53:53 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 04:25 UTC · original

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.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2069#issuecomment-7152822530) **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://git.gtahub.st/github/Marvisak--VIctory/pulls/1188) - 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.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 04:41 UTC · original

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

**@⁠upipibi** on GitHub · 2026-11-25 04:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2069#issuecomment-7153082619) 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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 05:00 UTC · original

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 05:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2069#issuecomment-7153364723) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:25 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 10:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2069#issuecomment-7159683939) <!-- 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)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 10:46 UTC · original

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 10:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/2069#issuecomment-7160144690) 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

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!2069
No description provided.