Skip to content

scripts: game-abba.ps1 runs an in-game ABBA comparison over gate runs (D3D12-GAME-ABBA) - #2804

Open
TheGeogeo wants to merge 1 commit into
ProjectLeonida:mainfrom
TheGeogeo:d3d12-game-abba
Open

TheGeogeo wants to merge 1 commit into
ProjectLeonida:mainfrom
TheGeogeo:d3d12-game-abba

Conversation

@TheGeogeo

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-GAME-ABBA (#2570 (comment))

What and why

An A/B between separate runs needs a balanced order, warm caches, the same exe throughout, and every run checked before it counts. Testers still do this by hand, one gate run at a time. This adds the runner that #2783's plan and abba were written for:

  • scripts/game-abba.ps1 takes the order from d3d12_ab_compare.py plan: warm-up runs of each arm, then discarded runs, then -Pairs pairs in ABBA order. It runs each slot through scripts/game-gate.ps1 (d3d12: an in-game gate: one command, one run folder, one summary.json (D3D12-GAME-GATE) #2782).
    • One exe with two settings: -Data, -MoreA, -MoreB.
    • Two builds: -CheckoutA, -DataA, -CheckoutB, -DataB. Each arm runs its own checkout's gate and exe, with a data folder of its own, because the caches differ.
  • The new d3d12_ab_compare.py check checks each measured run. A run counts only if all of these hold:
  • A run that fails a check gets an ab-excluded.txt, which abba now leaves out, and its slot runs again (-Retry, 1).
  • It ends with abba into <Out>/comparison.txt and comparison.json. abba.json records what ran, which exe, and what was left out and why.
  • -DryRun prints the plan and every gate command without starting anything.
  • It refuses:
    • two builds sharing one data folder;
    • one exe with no setting that differs;
    • fewer than 2 pairs;
    • an -Out inside a checkout.
  • It needs PowerShell 7 (#Requires -Version 7.0).
  • docs/measuring_fps.md (section 3) and docs/game_gate.md describe it.

Tested

On Windows 11 Pro 10.0.26300:

  • tests/test_game_abba.py, 6 tests: the switch-mode plan and per-arm settings, the two-build plan with each arm's own gate and data, the refusals and -Out inside a checkout (all through -DryRun in pwsh), the PowerShell 7 line, and a parameter-name check (PowerShell ignores case).
  • tests/test_d3d12_ab_compare.py, 18 tests. They include the new ones for check (a good run; each reason to leave a run out; the JSON output) and for an excluded run being left out by abba.
  • test_game_gate.py, test_tool_stdout_encoding.py, test_ci_registration.py, the docs tests, scripts/check_no_game_data.py on the changed files, and git diff --check are clean.
  • In game, RTX 3080 10 GB, driver 32.0.16.2140, Series S profile, the diagnostics build of main 8f41d7d code: a null A/B, LEONIDA_FPS_LINE=1 against =0 (the top-left frame-rate line). One exe with two settings, 4 pairs, 120 s in the world per run, with the driver mod from mods: gate_driver takes a run from the menus into the world (D3D12-GATE-DRIVER-MOD) #2784 enabled through -More.
    • 11 runs. All 8 measured runs passed their gate, none was left out, and none was retried.
    • Verdict "no clear difference": effect -0.08 ms (-0.2 %), standard error 0.53, 95 % [-1.78, +1.63] ms, 3 of 4 pairs agree.
    • The world median frame time of the measured runs was 41.05 / 40.50 / 39.45 / 37.92 / 38.49 / 37.79 / 37.89 / 38.48 ms in ABBA order. The first pair was still a little slower, which the balanced pairs absorb.
    • An earlier attempt of the same A/B had all its runs stopped early by an outside guard. It showed the other path: every run was marked and left out, each slot ran again once, and the verdict was "not enough runs".

GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140, Windows 11 Pro 10.0.26300

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

… (D3D12-GAME-ABBA)

The runner takes the order from d3d12_ab_compare.py plan (warm-up runs, discarded runs, then ABBA pairs) and
runs each slot through scripts/game-gate.ps1, for one exe with two settings or for two builds (a checkout and
a data folder per arm). Each measured run is checked by the new `d3d12_ab_compare.py check`: its gate passed,
the pipeline cache was warm before the measured window, its exe is its arm's first one, and its arm's own
settings show in the runtime's settings line when there is one. A run that fails gets an ab-excluded.txt,
which `abba` now leaves out, and its slot runs again (-Retry, 1). The runner ends with the comparison in
<Out>/comparison.txt and comparison.json, and abba.json says what ran and what was left out. -DryRun prints
the plan and the gate commands. It needs PowerShell 7 (#Requires).
@OreoFR

OreoFR commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12, head 413212ff9, main b7a1be296. CPU only, no pwsh and no game on this machine.

MEASURED

  • Red (main + only this PR's tests): 6 failed, 14 passed, 4 skipped.
    • In test_d3d12_ab_compare.py, the four new Runs tests fail: check doesn't exist on main.
    • In test_game_abba.py, test_it_needs_powershell_7 and test_no_variable_takes_a_parameters_name_in_another_case fail: the script doesn't exist on main.
  • Green (main + this PR, merge-tree): 20 passed, 4 skipped (test_d3d12_ab_compare.py 18 passed; test_game_abba.py 2 passed, 4 skipped).
  • The 4 skips are test_game_abba.py:50, :65, :81, :97, all "needs Windows and pwsh". So the parts of game-abba.ps1 that run are not exercised here. Only the static checks ran (the #Requires -Version 7.0 line and the variable/parameter case clash).

READ IN CODE

ASSUMED

  • The ABBA run itself (order, retries, exclusions, abba.json) needs a Windows run, or at least -DryRun under pwsh 7. Not reproduced here.

AI-assisted: Claude Code

@fiestorra

Copy link
Copy Markdown
Contributor

Verified on Windows, with the control that matters: the tests fail when the change is reverted.

Cherry-picked onto main d920d850d in a clean worktree, Python 3.13.14:

python -m pytest tests/test_game_abba.py + tests/test_d3d12_ab_compare.py -q with this pull request: 6 + 18 passed with scripts/game-abba.ps1 y tools/d3d12_ab_compare.py from main: 6 failed (script borrado) y 4 failed (tool de main)

So the new tests are tied to the change and not to each other's fixtures. No part of this needed a GPU, a display or game data, which is what the gate tests are built for.

What I could not test: the script against a real run folder - game-abba.ps1 drives one, and this machine has the game but not the gate harness the other contributors used, so the shape is proven and the run is not.

AI-assisted: yes - DeepSeek v4.1 (flash), applied and ran both arms on the machine above.

Written with an AI assistant.

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified with pwsh here: 6/6 test_game_abba.py, 18/18 test_d3d12_ab_compare.py, 21/21 test_game_gate.py. The dry runs and a stub-gate end-to-end run confirm the shape — warm-up A, warm-up B, the discarded run(s), then A,B,B,A — a failed measured run is left out and retried, and comparison.txt/json + abba.json are written. plan (tools/d3d12_ab_compare.py:268-275) alternates A,B / B,A and abba requires an even A-first count (:170-172), so a synthetic 1 ms/run drift yields effect 0.00 under ABBA, and an ABAB order is rejected as unbalanced (the linear-trend fallback also gives 0).

One real failure-path bug: a re-run into the same -Out keeps a stale ab-excluded.txt. Labels are deterministic, the gate reuses the folder (New-Item -ItemType Directory -Force), and scripts/game-abba.ps1:112 only writes the exclusion. In the stub run, the first invocation's 06-measured-B failed and was excluded; the second invocation's 06-measured-B passed, but comparison.txt still said left out (excluded: gate FAIL) while abba.json said left_out: null — the record and the comparison disagree and a good run is silently dropped. Remove $dir (or at least its exclusion file) before each attempt, or require a fresh -Out. The previous run's data copy is left behind the same way.

Two smaller ones:

  • In two-build mode -Out inside the runner's checkout is accepted: the guard (:65-67) loops only -CheckoutA/-CheckoutB; add $repo. I passed -Out inside the runner's tree and the dry run was happy.
  • A failed warm-up or discarded run is neither checked nor retried, so a broken environment runs every measured slot (about an hour) before failing with "not enough runs". Fail fast on a warm-up gate failure.

Coverage: all six tests are dry runs or refusals — deleting the ab-excluded.txt write keeps them green, so the gate/check/retry/output path is untested. A stub game-gate.ps1 writing run.json/summary.json (the shape tests/test_game_gate.py's Fake already uses) would cover it and the stale-file case. Also abba.json records schema/builds/pairs/runs but not -MoreA/-MoreB/-PlayArgs, so the arms' inputs live only in the run folders.

@merzleckeier

Copy link
Copy Markdown
Contributor

I checked 413212ff9 on bf30e2585. All 18 comparison tests passed. I also forced the ABBA dry-run tests to execute on Linux with PowerShell 7.4.21. Five of six passed. The checkout-containment case failed because the check appends a Windows path separator on Linux. Using [IO.Path]::DirectorySeparatorChar for both paths passes all six with the same fixtures, without launching a game.

This is a portability note for Linux dry runs. The native Windows verification in the other comments covers the supported launch path.

AI-assisted with OpenAI Codex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants