perf(victory-gpu): reuse overlay PDH/UTF-16 buffers and harden frametime tests #420

Manually merged
github merged 2 commits from github-bot/gh-420 into main 2026-11-26 18:40:35 +00:00 AGit
Owner

@⁠Lewandox on GitHub · 2026-11-26 18:04 UTC · original
Lewandox:perf/victory-gpu-overlay-and-frametime → main · +227 −91 · 2 files · 2 commits · merged 2026-11-26 18:37 UTC

Summary

Eliminates recurring heap allocations in the performance overlay (overlay.rs) and adds overflow-safe interval timing, stack-buffered NVIDIA driver parsing, and regression tests for frametime.rs.

Changes

  1. overlay.rs — reusable PDH buffer & stack UTF-16 encoding:

    • Stored a reusable buf: Vec<u64> inside Gpu3d so Gpu3d::percent(&mut self) reuses its PDH counter buffer across 500 ms samples instead of allocating a fresh Vec<u64> on every tick; added Drop for Gpu3d to close the PDH query handle cleanly.
    • Added stack-buffered with_utf16 ([u16; 128] with Vec<u16> fallback) and Gdi::measure_wide so Gdi::measure avoids heap allocation for overlay lines and Gdi::draw encodes UTF-16 once instead of twice.
    • Added unit tests for with_utf16 (ASCII, Unicode, surrogate pairs, >128 fallback).
  2. frametime.rs — overflow safety, zero-format! driver parsing, & regression tests:

    • Replaced as_micros() as u64 truncation in tick() with saturating u64::try_from(...).unwrap_or(u64::MAX) and saturating_add accounting.
    • Eliminated intermediate format!("{third}{fourth}") and String digit collection in nvidia_driver_number() using a 5-byte rolling stack buffer.
    • Extracted pure helpers summarize_interval and format_row and added comprehensive unit tests covering zero/single/spike intervals, u64::MAX saturation, NVIDIA driver parsing edge cases, and CSV column-count parity against HEADER.

Verification

  • cargo test -p victory-gpu --lib overlay::tests (default and --features diagnostics)
  • cargo test -p victory-gpu --lib frametime::tests (default and --features diagnostics)
  • cargo xtask policy
**@⁠Lewandox** on GitHub · 2026-11-26 18:04 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/420) `Lewandox:perf/victory-gpu-overlay-and-frametime` → `main` · +227 −91 · 2 files · 2 commits · merged 2026-11-26 18:37 UTC ## Summary Eliminates recurring heap allocations in the performance overlay (`overlay.rs`) and adds overflow-safe interval timing, stack-buffered NVIDIA driver parsing, and regression tests for `frametime.rs`. ### Changes 1. **`overlay.rs` — reusable PDH buffer & stack UTF-16 encoding**: - Stored a reusable `buf: Vec<u64>` inside `Gpu3d` so `Gpu3d::percent(&mut self)` reuses its PDH counter buffer across 500 ms samples instead of allocating a fresh `Vec<u64>` on every tick; added `Drop for Gpu3d` to close the PDH query handle cleanly. - Added stack-buffered `with_utf16` (`[u16; 128]` with `Vec<u16>` fallback) and `Gdi::measure_wide` so `Gdi::measure` avoids heap allocation for overlay lines and `Gdi::draw` encodes UTF-16 once instead of twice. - Added unit tests for `with_utf16` (ASCII, Unicode, surrogate pairs, >128 fallback). 2. **`frametime.rs` — overflow safety, zero-`format!` driver parsing, & regression tests**: - Replaced `as_micros() as u64` truncation in `tick()` with saturating `u64::try_from(...).unwrap_or(u64::MAX)` and `saturating_add` accounting. - Eliminated intermediate `format!("{third}{fourth}")` and `String` digit collection in `nvidia_driver_number()` using a 5-byte rolling stack buffer. - Extracted pure helpers `summarize_interval` and `format_row` and added comprehensive unit tests covering zero/single/spike intervals, `u64::MAX` saturation, NVIDIA driver parsing edge cases, and CSV column-count parity against `HEADER`. ## Verification - `cargo test -p victory-gpu --lib overlay::tests` (default and `--features diagnostics`) - `cargo test -p victory-gpu --lib frametime::tests` (default and `--features diagnostics`) - `cargo xtask policy`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:10:27 +00:00
github manually merged commit 620eeae661 into main 2026-11-26 18:40:35 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.