panel: VICTORY_PANEL_LOG=1 logs the HUD's numbers at each refresh #401

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

@⁠h-dowd on GitHub · 2026-12-04 00:23 UTC · original
h-dowd:panel-log → main · +36 −0 · 2 files · 1 commits · open

The performance panel shows frame rate, 1% low, hitches, submit, copy and upload times, draws and memory, but only on screen, so a session can't be read back afterwards.

With VICTORY_PANEL_LOG=1, each panel refresh (every 250 ms while the panel is shown) also writes one panel info line with the same numbers:

fps, ms, low_1pct_fps, worst_ms, hitches_10s, cpu_pct, sys_cpu_pct, submit_ms, gpu_idle_ms, cpu_wait_gpu_ms, copy_prep_ms, tex_upload_ms, upload_mb, draws, dropped_draws, vram_used_mb, vram_budget_mb, shared_mb, title_card_mb, title_ram_mb, tex_waiting, working_mb, sys_avail_mb

I used it to bucket fps by draw count and to line hitches up with submit-thread and upload spikes across whole sessions. That showed which scenes drop and that the hitches near land come from streaming bursts, which the per-second stats: frame line averages away.

  • Off without the switch: one OnceLock read per refresh, nothing else.
  • Works in release builds, not only PROFILE=diag.
  • Documented in the settings table of docs/DIAGNOSTICS.md.

🤖 Generated with Claude Code

**@⁠h-dowd** on GitHub · 2026-12-04 00:23 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/401) `h-dowd:panel-log` → `main` · +36 −0 · 2 files · 1 commits · open The performance panel shows frame rate, 1% low, hitches, submit, copy and upload times, draws and memory, but only on screen, so a session can't be read back afterwards. With `VICTORY_PANEL_LOG=1`, each panel refresh (every 250 ms while the panel is shown) also writes one `panel` info line with the same numbers: `fps`, `ms`, `low_1pct_fps`, `worst_ms`, `hitches_10s`, `cpu_pct`, `sys_cpu_pct`, `submit_ms`, `gpu_idle_ms`, `cpu_wait_gpu_ms`, `copy_prep_ms`, `tex_upload_ms`, `upload_mb`, `draws`, `dropped_draws`, `vram_used_mb`, `vram_budget_mb`, `shared_mb`, `title_card_mb`, `title_ram_mb`, `tex_waiting`, `working_mb`, `sys_avail_mb` I used it to bucket fps by draw count and to line hitches up with submit-thread and upload spikes across whole sessions. That showed which scenes drop and that the hitches near land come from streaming bursts, which the per-second `stats: frame` line averages away. - Off without the switch: one `OnceLock` read per refresh, nothing else. - Works in release builds, not only `PROFILE=diag`. - Documented in the settings table of `docs/DIAGNOSTICS.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The panel shows frame rate, 1% low, hitches, submit, copy and upload
times, draws and memory, but only on screen: a run cannot be read back
afterwards. With VICTORY_PANEL_LOG=1 each refresh (every 250 ms while
the panel is shown) also goes to the log as one `panel` line, so fps can
be bucketed by draw count or matched against hitches after the session.
Off without the switch; release builds included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 00:23:54 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 07:36 UTC · original

Checked 728df1e. Looks fine overall, one suggestion about which thread does the write, rest are small.

The switch is read once into a OnceLock and only 1 turns it on, same shape as VICTORY_TIMER_LOG in frame.rs:292 (panel.rs:2185-2186). It sits inside the 250 ms refresh block, after the early return at panel.rs:2125, so per-frame work is unchanged, and with it off the refresh only pays one OnceLock read. No allocation or formatting happens unless it's on.

When on it is one tracing::info! per refresh, through the shared subscriber to stderr (victory-core/src/logging.rs:30-32). The game inits it at info (apps/victory/src/main.rs:191) and release caps at info (logging.rs:14-18), so "Release builds too" holds. The line only appears while the panel is not hidden and the menu is closed (panel.rs:2084-2092), which matches "while it is shown". The block itself adds no lock, dropped_now is an atomic load (draw.rs:640-641).

The one thing I'd change is where the write happens. frame() is called from present_real while the presenter is borrowed (victory-gpu/src/host.rs:9170), so the log write and its stderr lock sit on the present path, about four times a second. The frame meter's own periodic lines are deliberately handed to the "victory-meter" thread "so presenting goes on" (host.rs:7755-7760). All the logged values are Copy, so wrapping the info! in super::meter_lines(move || ...) should be a small change and keep the present thread free of log writes. Its cost does at least show up in the HUD's overlay line on the next refresh, since self.cost is taken after it (panel.rs:2266).

The fields come from the same locals the Snapshot is built from, so they match the HUD. Smaller notes.

  1. gpu_idle_ms is the raw c[1], while the HUD shows GPU busy as ms - min(idle, ms) (panel.rs:1199-1200, 1389). Anyone reading the log has to do that subtraction and clamp themselves. Logging gpu_busy_ms instead, or next to it, would line up with what's on screen.
  2. dropped_now() is read twice, once for the log (panel.rs:2204) and once for the Snapshot (panel.rs:2234). It's a plain atomic load (draw.rs:640-641) so the two can differ by a few draws. Reading it once into a local would keep the log and HUD identical.
  3. Memory fields are whole MiB (b >> 20, panel.rs:2188), the HUD shows GB with two decimals. Finer in the log, which is fine, just a different unit.
  4. The doc says every 250 ms, but a refresh can come at 125 ms when the frame meter line is due (panel.rs:2125). Also the line only appears when the log filter allows info, so VICTORY_LOG=warn hides it. Might be worth a word in DIAGNOSTICS.md:19.
  5. The code comment says times are per frame, upload_mb and draws are per frame too (they come from Counters::since, panel.rs:804-811). Could say so in the field name or doc.

git grep VICTORY_PANEL_LOG finds only panel.rs:2182,2186 and docs/DIAGNOSTICS.md:19. rustfmt --check is clean on panel.rs.

Tests ran natively on Windows (MSVC, not Wine). cargo test -p victory-gpu --lib panel built with no warnings, but the filter only matches host::panel::tests::preview, which is #[ignore] (panel.rs:2537), so the result is 0 passed, 0 failed, 1 ignored. Nothing actually exercises the new block, so this is a build check, not a test. I didn't add a test for the log line, since the formatting is inline in frame() and testing it would need pulling it into its own function first.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 07:36 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/401#issuecomment-7404864581) Checked 728df1e. Looks fine overall, one suggestion about which thread does the write, rest are small. The switch is read once into a OnceLock and only `1` turns it on, same shape as `VICTORY_TIMER_LOG` in frame.rs:292 (panel.rs:2185-2186). It sits inside the 250 ms refresh block, after the early return at panel.rs:2125, so per-frame work is unchanged, and with it off the refresh only pays one OnceLock read. No allocation or formatting happens unless it's on. When on it is one `tracing::info!` per refresh, through the shared subscriber to stderr (victory-core/src/logging.rs:30-32). The game inits it at `info` (apps/victory/src/main.rs:191) and release caps at info (logging.rs:14-18), so "Release builds too" holds. The line only appears while the panel is not hidden and the menu is closed (panel.rs:2084-2092), which matches "while it is shown". The block itself adds no lock, `dropped_now` is an atomic load (draw.rs:640-641). The one thing I'd change is where the write happens. `frame()` is called from `present_real` while the presenter is borrowed (victory-gpu/src/host.rs:9170), so the log write and its stderr lock sit on the present path, about four times a second. The frame meter's own periodic lines are deliberately handed to the "victory-meter" thread "so presenting goes on" (host.rs:7755-7760). All the logged values are Copy, so wrapping the `info!` in `super::meter_lines(move || ...)` should be a small change and keep the present thread free of log writes. Its cost does at least show up in the HUD's overlay line on the next refresh, since `self.cost` is taken after it (panel.rs:2266). The fields come from the same locals the Snapshot is built from, so they match the HUD. Smaller notes. 1. `gpu_idle_ms` is the raw `c[1]`, while the HUD shows GPU busy as `ms - min(idle, ms)` (panel.rs:1199-1200, 1389). Anyone reading the log has to do that subtraction and clamp themselves. Logging `gpu_busy_ms` instead, or next to it, would line up with what's on screen. 2. `dropped_now()` is read twice, once for the log (panel.rs:2204) and once for the Snapshot (panel.rs:2234). It's a plain atomic load (draw.rs:640-641) so the two can differ by a few draws. Reading it once into a local would keep the log and HUD identical. 3. Memory fields are whole MiB (`b >> 20`, panel.rs:2188), the HUD shows GB with two decimals. Finer in the log, which is fine, just a different unit. 4. The doc says every 250 ms, but a refresh can come at 125 ms when the frame meter line is due (panel.rs:2125). Also the line only appears when the log filter allows info, so `VICTORY_LOG=warn` hides it. Might be worth a word in DIAGNOSTICS.md:19. 5. The code comment says times are per frame, `upload_mb` and `draws` are per frame too (they come from `Counters::since`, panel.rs:804-811). Could say so in the field name or doc. `git grep VICTORY_PANEL_LOG` finds only panel.rs:2182,2186 and docs/DIAGNOSTICS.md:19. rustfmt --check is clean on panel.rs. Tests ran natively on Windows (MSVC, not Wine). `cargo test -p victory-gpu --lib panel` built with no warnings, but the filter only matches `host::panel::tests::preview`, which is `#[ignore]` (panel.rs:2537), so the result is 0 passed, 0 failed, 1 ignored. Nothing actually exercises the new block, so this is a build check, not a test. I didn't add a test for the log line, since the formatting is inline in `frame()` and testing it would need pulling it into its own function first. AI-assisted: yes
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 11:28 UTC · original

Useful, and the units check out: EVERY is 250 ms (host/panel.rs:49) so the documented interval is right, video_memory()/system_ram() really are bytes, and c[0..=9] is in range for the 11 counters.

One doc clause worth adding: dropped_draws comes from crate::draw::dropped_now() (crates/victory-gpu/src/draw.rs:640), a since-start total, while every other field on the line is per-window — the first person to plot this will read it as a per-window draw loss.

Two cosmetic nits: draws truncates a fractional average (c[9] as u64), and mb shifts (b >> 20) where the HUD shows one decimal, so 1023.9 MiB logs as 1023.

**@⁠Luxuride** on GitHub · 2026-12-04 11:28 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/401#issuecomment-7410142605) Useful, and the units check out: `EVERY` is 250 ms (`host/panel.rs:49`) so the documented interval is right, `video_memory()`/`system_ram()` really are bytes, and `c[0..=9]` is in range for the 11 counters. One doc clause worth adding: `dropped_draws` comes from `crate::draw::dropped_now()` (`crates/victory-gpu/src/draw.rs:640`), a since-start total, while every other field on the line is per-window — the first person to plot this will read it as a per-window draw loss. Two cosmetic nits: `draws` truncates a fractional average (`c[9] as u64`), and `mb` shifts (`b >> 20`) where the HUD shows one decimal, so 1023.9 MiB logs as 1023.
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/401/head:github-bot/gh-401'
git switch 'github-bot/gh-401'

Merge

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