bench: warm up with play.ps1 before measuring, and flag shader translation during spots #167

Open
github-bot wants to merge 2 commits from github-bot/gh-166 into main AGit
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 20:20 UTC · original
SovietBearz0r:bench-warm-lap → main · +749 −75 · 1 files · 2 commits · open

A benchmark lap taken right after changing a VICTORY_* switch (or updating a build) is not comparable: the shader cache key changed, so that lap translates shaders while the title loads — black frames, compile stalls — and the numbers mix translation cost with rendering. We hit this while A/B-testing shader passes. This PR fixes that class of problem and makes benches repeatable, bounded and comparable.

Measurement correctness

  • -Warm: before measuring, run play.ps1's own documented pre-steps with the same settings — -Shaders (translate every shader) and -Warm (make earlier runs' pipelines). No new translation code paths. Without -Warm nothing changes.
  • -WarmRetry: if a measured lap still translated shaders during the spots, run the pre-steps once and repeat that lap; a clean retry replaces it, otherwise the lap stays excluded.
  • Spot-window translation check: counts shaders translated between the first BENCH_SPOT_START and the last BENCH_SPOT_END, warns loudly ("this lap's numbers are not comparable"), and records translations_during_spots in -Report. Loading-phase translations are reported but not flagged.
  • -Repeats N: N measured laps after the warm-up; aggregated per-spot table with each lap's value plus the median for avg fps, p95/p99, 1%-low, frame/prep ms. Laps with spot translations, device removal, timeout or no log are flagged and excluded from the median (still shown). N=1 prints the old table.
  • Exit codes: 0 clean, 2 no spots, 3 translations during spots, 4 device removed, 5 timed out. Previously always 0.

Bounded runs

  • -TimeoutMin (default 20, fractional allowed): each lap runs from a temporary child script in a child pwsh; Wait-Process against a deadline; on expiry taskkill /T /F plus a game_scarlett_master/victory sweep, the partial log is parsed, the lap is marked timed out, exit 5.

Comparison & provenance

  • -Compare <base.log> <other.log>: offline delta table (avg fps, p95/p99, 1%-low) with spots matched by name and ! marking a spot whose lap translated shaders during the spots / lost the device.
  • Per-spot p95 ms, p99 ms, 1%-low fps added to the normal table (averages hid tails).
  • -Report scorecard now records title SHA-256, layer SHA-256, git revision, build, bench config, requested vs actual GPU, OS/CPU/RAM, every VICTORY_* switch + -More override, translations_during_spots and exit_code; with -Repeats it writes one scorecard per parsed lap.
  • Preflight warnings (continue anyway, yellow): title/victory already running; power plan not High performance/Ultimate; missing known-pipelines.bin when -Warm is used (pipeline warm may be a no-op); -More carrying VICTORY_SHADER_OPT prints the -GpuOpt 255-replacement note.
  • Usability: -ParseLog <file> positional spelling works (previously silently parsed the latest log); help documents the -GpuOpt trap and the new flags; bookmark mode ignores -Repeats.

Verification

  • PowerShell parser check for scripts/bench.ps1; cargo test -p xtask: 9 passed; cargo xtask policy: 442 files ok; -ListGpus still works.
  • No-title paths exercised with a synthetic stub play.ps1: child launch/exit propagation, -Repeats clean (median table, exit 0) and dirty-first (excluded, exit 3), device-removal exclusion (exit 4), -TimeoutMin 0.05 watchdog (killed, partial spot parsed, exit 5), -Warm+-Repeats, -WarmRetry clean-replace/retry-still-dirty, preflight warnings.
  • -ParseLog output is byte-identical to the previous commit on real logs; no-spot logs still exit 2.
  • -Compare on our real logs (bar-base-1 vs bar-on-2) prints, e.g.:
    spawn_idle avg fps 32.7→33.0 (+0.3), cruise_out 33.0→31.4 (−1.6), cruise_back 30.2→29.9 (−0.3), with p95/p99/1%-low rows.

Real validation (RX 9070 XT, diag build, title run)

  • -Repeats 2 on the real title (builtin:cruise, -Gpu 0, -TimeoutMin 8): both laps completed, exit 0, aggregate table printed with per-lap values and medians — e.g. spawn_idle 47.2 / 46.8 → 47.0 avg fps, p95 25.0 / 24.6 → 24.8 ms, p99 35.6 / 32.1 → 33.9 ms, 1%-low 28.1 / 31.2 → 29.6; cruise_out 42.0 / 42.4 → 42.2; cruise_back 40.2 / 41.0 → 40.6.
  • Watchdog: -TimeoutMin 0.4 killed the lap as designed — printed Watchdog: lap overran 0.4 min - killing the process tree and the title., then lap timed out after 0.4 min; … the partial log is parsed (exit code 5), exited 5, no game_scarlett_master/victory processes left.
  • -Compare on real logs and -ParseLog paths verified offline (output byte-identical to the previous commit for -ParseLog; delta table shown in the body).

Logs of the validation runs are kept outside the repo (data\ingame-verify\bench-repeat-validation.out.txt, bench-watchdog-validation.out.txt).

Still not exercised

  • -Warm/-WarmRetry with a real translation pass (they call play.ps1 -Shaders/-Warm; the wiring is tested with a stub, the translation itself is the existing play mode), and -Report zips under -Repeats on real laps.
**@⁠SovietBearz0r** on GitHub · 2026-12-05 20:20 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/166) `SovietBearz0r:bench-warm-lap` → `main` · +749 −75 · 1 files · 2 commits · open A benchmark lap taken right after changing a `VICTORY_*` switch (or updating a build) is **not comparable**: the shader cache key changed, so that lap translates shaders while the title loads — black frames, compile stalls — and the numbers mix translation cost with rendering. We hit this while A/B-testing shader passes. This PR fixes that class of problem and makes benches repeatable, bounded and comparable. ## Measurement correctness - **`-Warm`**: before measuring, run `play.ps1`'s own documented pre-steps with the same settings — `-Shaders` (translate every shader) and `-Warm` (make earlier runs' pipelines). No new translation code paths. Without `-Warm` nothing changes. - **`-WarmRetry`**: if a measured lap still translated shaders during the spots, run the pre-steps once and repeat that lap; a clean retry replaces it, otherwise the lap stays excluded. - **Spot-window translation check**: counts shaders translated between the first `BENCH_SPOT_START` and the last `BENCH_SPOT_END`, warns loudly ("this lap's numbers are not comparable"), and records `translations_during_spots` in `-Report`. Loading-phase translations are reported but not flagged. - **`-Repeats N`**: N measured laps after the warm-up; aggregated per-spot table with each lap's value plus the median for avg fps, p95/p99, 1%-low, frame/prep ms. Laps with spot translations, device removal, timeout or no log are flagged and excluded from the median (still shown). `N=1` prints the old table. - **Exit codes**: `0` clean, `2` no spots, `3` translations during spots, `4` device removed, `5` timed out. Previously always 0. ## Bounded runs - **`-TimeoutMin` (default 20, fractional allowed)**: each lap runs from a temporary child script in a child `pwsh`; `Wait-Process` against a deadline; on expiry `taskkill /T /F` plus a `game_scarlett_master`/`victory` sweep, the partial log is parsed, the lap is marked timed out, exit 5. ## Comparison & provenance - **`-Compare <base.log> <other.log>`**: offline delta table (avg fps, p95/p99, 1%-low) with spots matched by name and `!` marking a spot whose lap translated shaders during the spots / lost the device. - **Per-spot p95 ms, p99 ms, 1%-low fps** added to the normal table (averages hid tails). - **`-Report` scorecard** now records title SHA-256, layer SHA-256, git revision, build, bench config, requested vs actual GPU, OS/CPU/RAM, every `VICTORY_*` switch + `-More` override, `translations_during_spots` and `exit_code`; with `-Repeats` it writes one scorecard per parsed lap. - **Preflight warnings** (continue anyway, yellow): title/victory already running; power plan not High performance/Ultimate; missing `known-pipelines.bin` when `-Warm` is used (pipeline warm may be a no-op); `-More` carrying `VICTORY_SHADER_OPT` prints the `-GpuOpt` 255-replacement note. - **Usability**: `-ParseLog <file>` positional spelling works (previously silently parsed the latest log); help documents the `-GpuOpt` trap and the new flags; bookmark mode ignores `-Repeats`. ## Verification - PowerShell parser check for `scripts/bench.ps1`; `cargo test -p xtask`: 9 passed; `cargo xtask policy`: 442 files ok; `-ListGpus` still works. - No-title paths exercised with a synthetic stub `play.ps1`: child launch/exit propagation, `-Repeats` clean (median table, exit 0) and dirty-first (excluded, exit 3), device-removal exclusion (exit 4), `-TimeoutMin 0.05` watchdog (killed, partial spot parsed, exit 5), `-Warm`+`-Repeats`, `-WarmRetry` clean-replace/retry-still-dirty, preflight warnings. - `-ParseLog` output is byte-identical to the previous commit on real logs; no-spot logs still exit 2. - `-Compare` on our real logs (`bar-base-1` vs `bar-on-2`) prints, e.g.: `spawn_idle avg fps 32.7→33.0 (+0.3)`, `cruise_out 33.0→31.4 (−1.6)`, `cruise_back 30.2→29.9 (−0.3)`, with p95/p99/1%-low rows. ## Real validation (RX 9070 XT, diag build, title run) - **`-Repeats 2`** on the real title (`builtin:cruise`, `-Gpu 0`, `-TimeoutMin 8`): both laps completed, exit **0**, aggregate table printed with per-lap values and medians — e.g. `spawn_idle 47.2 / 46.8 → 47.0 avg fps, p95 25.0 / 24.6 → 24.8 ms, p99 35.6 / 32.1 → 33.9 ms, 1%-low 28.1 / 31.2 → 29.6`; `cruise_out 42.0 / 42.4 → 42.2`; `cruise_back 40.2 / 41.0 → 40.6`. - **Watchdog**: `-TimeoutMin 0.4` killed the lap as designed — printed `Watchdog: lap overran 0.4 min - killing the process tree and the title.`, then `lap timed out after 0.4 min; … the partial log is parsed (exit code 5)`, exited **5**, no `game_scarlett_master`/`victory` processes left. - `-Compare` on real logs and `-ParseLog` paths verified offline (output byte-identical to the previous commit for `-ParseLog`; delta table shown in the body). Logs of the validation runs are kept outside the repo (`data\ingame-verify\bench-repeat-validation.out.txt`, `bench-watchdog-validation.out.txt`). ## Still not exercised - `-Warm`/`-WarmRetry` with a real translation pass (they call `play.ps1 -Shaders`/`-Warm`; the wiring is tested with a stub, the translation itself is the existing play mode), and `-Report` zips under `-Repeats` on real laps.
A benchmark lap taken right after changing a VICTORY_* switch (or a new build)
is not comparable: the shader cache key changed, so that lap translates the
shaders while the title loads - black frames and compile stalls - and its
numbers mix translation cost with rendering. This adds two things:

- -Warm: before the measured lap, run play.ps1's own pre-steps with the very
  same settings - -Shaders (translate every shader into the cache) and -Warm
  (make the pipelines earlier runs drew with). No extra code paths; the
  documented pre-steps are used. Without -Warm nothing changes.
- Parse-BenchLog now counts the shaders translated between the first
  BENCH_SPOT_START and the last BENCH_SPOT_END and prints a prominent warning
  when any were ("this lap's numbers are not comparable"), with the fix
  (-Warm or re-run). The scorecard report gains translations_during_spots for
  -Report. Translation during loading is not flagged: it happens before the
  spots and does not pollute their numbers.

Verified with PowerShell's parser (the repo's scripts-parse test) and on a
real bench log: the warning counts only the spot window, while the loading
translations are reported separately by the log's own cache lines. No game
run was needed for the parsing change; the -Warm path reuses play.ps1's
existing documented modes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 20:25:01 +00:00
A single measured lap is one sample: spot figures move a few percent between
runs, and a lap that translated shaders (or lost the device) is not comparable
at all. A careful A/B needs several laps of the same binary, each bounded in
time, and a way to compare two logs offline. This extends scripts\bench.ps1
without changing what it does by default (one lap, same output, same exit
codes):

- -Repeats N (default 1): the measured lap runs N times after the -Warm
  pre-steps and the summary gains an aggregate table - every spot's per-lap
  values for avg fps, p95/p99, 1%-low and frame/prep ms, and the median across
  the laps that are comparable. A lap that translated shaders during the spots
  or lost the device is flagged and excluded (its values are still shown), and
  the exit code keeps the worst lap's meaning (3 or 4). N=1 prints exactly the
  old single-lap table.
- -TimeoutMin (default 20): a measured lap runs in a child pwsh, written as a
  temporary script with the same switches and -More hashtable, and
  Wait-Process bounds it. On expiry taskkill /T /F kills the tree plus any
  leftover game_scarlett_master/victory, the partial log is still parsed, the
  lap is marked timed out and the exit code is 5 (added to the help's list).
- -Compare <base.log> <other.log> (positional, offline): both logs go through
  the same parser, spots are matched by name and the table gives base/other/
  delta for avg fps, p95, p99 and 1%-low, with spots marked when a lap
  translated shaders during the spots (or lost the device). No game is run.
- Preflight warnings (always on; they only print): a title/victory already
  running, a power plan that is not High performance/Ultimate, a missing
  known-pipelines.bin when -Warm or -WarmRetry is given (victory warm --used
  may then do nothing), and -More VICTORY_SHADER_OPT replacing -GpuOpt's 255.
- -WarmRetry: a measured lap that translated shaders during the spots has the
  -Warm pre-steps run once and the lap repeated once; a clean repeat replaces
  it, otherwise the lap stays excluded and the warnings say what happened.

The run+parse code moved into helpers (Get-BenchSpots / Get-BenchLap /
Invoke-BenchChild / Write-BenchSummary) instead of the inline play.ps1 call
and parser, so -Repeats, -WarmRetry, -Compare and the scorecard share one
parser and one runner.

Verified with PowerShell's parser on every edited script, on real logs (the
existing -ParseLog output and exit codes are byte-identical; -Compare on
data\logs\bar-base-1.log vs bar-on-2.log and inst-base-1.log vs inst-on-1.log
prints sensible deltas) and on synthetic stub play.ps1 logs for the -Repeats,
-WarmRetry, -TimeoutMin and preflight paths, which launch no title. cargo test
-p xtask and cargo xtask policy pass. The paths that need the real title (a
measured lap through play.ps1, and the watchdog killing a running title) are
not exercised: no game was run.
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 22:09 UTC · original

Real-run validation of the new paths on this machine (RX 9070 XT, diag build, builtin:cruise):

-Repeats 2 (exit 0, both laps clean):

spawn_idle  avg fps 47.2 / 46.8 -> 47.0   p95 25.0 / 24.6 -> 24.8 ms   p99 35.6 / 32.1 -> 33.9 ms   1%-low 28.1 / 31.2 -> 29.6
cruise_out  avg fps 42.0 / 42.4 -> 42.2   p95 27.3 / 27.4 -> 27.4 ms   p99 39.3 / 35.2 -> 37.2 ms   1%-low 25.4 / 28.4 -> 26.9
cruise_back avg fps 40.2 / 41.0 -> 40.6   p95 29.0 / 27.4 -> 28.2 ms   p99 39.5 / 40.1 -> 39.8 ms   1%-low 25.3 / 24.9 -> 25.1
(all 2 clean laps, median shown last)

Watchdog (-TimeoutMin 0.4, real title): Watchdog: lap overran 0.4 min - killing the process tree and the title., partial log parsed, exit 5, and no game_scarlett_master/victory processes left afterwards.

-Compare/-ParseLog remain verified offline (delta table and byte-identical parse output). Only -Warm/-WarmRetry's real translation pass and -Report under -Repeats were not re-run with the title; their wiring is covered with the stub.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 22:09 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/166#issuecomment-7446397041) Real-run validation of the new paths on this machine (RX 9070 XT, diag build, `builtin:cruise`): **`-Repeats 2`** (exit 0, both laps clean): ``` spawn_idle avg fps 47.2 / 46.8 -> 47.0 p95 25.0 / 24.6 -> 24.8 ms p99 35.6 / 32.1 -> 33.9 ms 1%-low 28.1 / 31.2 -> 29.6 cruise_out avg fps 42.0 / 42.4 -> 42.2 p95 27.3 / 27.4 -> 27.4 ms p99 39.3 / 35.2 -> 37.2 ms 1%-low 25.4 / 28.4 -> 26.9 cruise_back avg fps 40.2 / 41.0 -> 40.6 p95 29.0 / 27.4 -> 28.2 ms p99 39.5 / 40.1 -> 39.8 ms 1%-low 25.3 / 24.9 -> 25.1 (all 2 clean laps, median shown last) ``` **Watchdog** (`-TimeoutMin 0.4`, real title): `Watchdog: lap overran 0.4 min - killing the process tree and the title.`, partial log parsed, **exit 5**, and no `game_scarlett_master`/`victory` processes left afterwards. `-Compare`/`-ParseLog` remain verified offline (delta table and byte-identical parse output). Only `-Warm`/`-WarmRetry`'s real translation pass and `-Report` under `-Repeats` were not re-run with the title; their wiring is covered with the stub.
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/167/head:github-bot/gh-166'
git switch 'github-bot/gh-166'

Merge

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