fix(vk): lift AMD Anti-Lag 2 Market FIFO 1% lows +11.4% on AMD GPUs by dropping mutex across driver calls and deferring PRESENT to vkQueuePresentKHR #2704

Merged
HumanBean merged 3 commits from Jer9/Longshot:fix/vk-antilag2-mutex-present into main 2026-11-28 01:24:50 +00:00
Contributor

Summary

What a player notices:

  • Helps: Eliminates AMD Anti-Lag 2 frame-pacing stutters on AMD GPUs with VK_AMD_anti_lag, recovering +11.4% Market FIFO 1% low FPS (26.49 -> 29.52 FPS, 83% of the AL0 -> AL1 deficit) and cutting Kokiri Auto FG host GPU resource wait by 25% (0.88 -> 0.66 ms).
  • No measurable impact: Mean FPS (44.62 -> 44.40 FPS Market FIFO, 44.32 -> 44.38 FPS Market Immediate) and setups without VK_AMD_anti_lag (NVIDIA / Steam Deck / RX_VK_ANTILAG=0).

Two bugs in the AMD Anti-Lag 2 integration caused pacing stalls and inaccurate PRESENT timing:

  1. antilag_input() in gpu/vk/vk_antilag.cpp held a.mu across the blocking vkAntiLagUpdateAMD(INPUT) driver call (vk_replay.cpp do_present), stalling display_main (present_commit holds present_image_mu + dev.present_mu while calling antilag_present()). The fix snapshots/allocates state under a.mu and drops a.mu before calling vkAntiLagUpdateAMD, using need_off + in_flight + take_off() so disabling Anti-Lag 2 while a call is in flight emits VK_ANTI_LAG_MODE_OFF_AMD once after all in-flight MODE_ON_AMD calls return.
  2. On non-FG presents (present_thread_on() is always true), present_out hand_off called antilag_present() before presenter_wait_copy(done) instead of immediately before vkQueuePresentKHR. The fix snapshots antilag_id via antilag_frame() at hand_off, carries antilag_id on Presenter::Job, and calls antilag_present() in presenter_loop right before vkQueuePresentKHR (leaving gpu/vk/vk_antilag.h untouched).

Files to read first: gpu/vk/vk_antilag.cpp, gpu/vk/vk_replay.cpp, and tests/test_antilag.py.

Testing

Tested:

  • Hardware / OS: Windows 11 (build 26300), AMD Ryzen AI 7 350 / Radeon 860M (8 CUs, RDNA 3.5 iGPU), Adrenalin 26.10.1 (LLPC).
  • How to test:
    1. Launch Market (market-entrance), walk straight forward 5 s (0:LUP/5000) to the central fountain, and traverse for 19.5 s after a 12.5 s settle under V-Sync On (FIFO) and V-Sync Auto (Immediate) with RX_VK_ANTILAG=1 vs RX_VK_ANTILAG=0.
    2. Launch Kokiri (kokiri-start) at 1600x1000 windowed 120 Hz with Built-in Auto FG (frame_generation=1, frame_generation_by=1) and RX_VK_ANTILAG=1 vs RX_VK_ANTILAG=0.
  • Checks:
    • python -I -B tests/test_antilag.py failed on forge/main (86b3b9e4) for both bugs and passes --strict on 62e78b22 (clang++ and g++, including concurrent want=0 + antilag_frame()/antilag_present() tests).
    • python -I -B tests/run_all.py --strict tests/test_antilag.py tests/test_fps_stats.py tests/test_present_acquire_ahead.py tests/test_present_thread.py: 4 passed, 0 failed, 0 skipped.
    • python -I -B tests/run_all.py --changed forge/main: 130 passed, 0 failed, 12 skipped (7 cargo not on PATH, 4 Linux-only spirv-val/setenv, 1 Vulkan 1.3 offscreen).
    • python -I -B scripts/check_guide_screenshots.py --review-sources: 0 issues on branch-touched files.

Still to test:

  • Discrete AMD RDNA 3/4 (mirrors=1, Windows & Linux Mesa RADV): run Market FIFO/Immediate + Auto FG with RX_VK_ANTILAG=1, expecting recovered 1% lows and zero DEVICE_LOST (@Beanstalk after push).
  • NVIDIA RTX & Steam Deck (VK_AMD_anti_lag absent): short smoke run, expecting clean no-op parity (@Beanstalk after push).

Measurements

Verdict: Market FIFO RX_VK_ANTILAG=1 1% low FPS improved +11.4% (26.49 -> 29.52 FPS, recovering 83% of the AL0 -> AL1 deficit) and Kokiri Auto FG host GPU resource wait dropped -25% (0.88 -> 0.66 ms, matching AL0 0.69 ms), with 0 DEVICE_LOST and 0 without-inputs fallbacks across 27 serialized runs.

Setup: Windows 11, AMD Radeon 860M (26.10.1 LLPC), windowed 120 Hz (4804x1753 Market / 3600x1753 Kokiri DPI-scaled swapchains), nvn: window crop 0,0 2304x1440 (100% render scale, output_res=2560x1440, ultrawide=1, handheld_profile=0), RX_VK_PRECOMPILE=0, 3-round interleaved medians (RX_VK_ANTILAG=1), presenter thread: the copy's fence 2.95–8.91 ms in Kokiri logs. (Benchmark runs executed on ad617253; 62e78b22 only adds the need_off/in_flight Off-transition guard under a.mu with identical steady-state ON hot path.)

Baseline: main @ 86b3b9e4 with RX_VK_ANTILAG=0 (30.14 FPS 1% low Market FIFO, 25.34 FPS 1% low Market Immediate, 0.69 ms gwait Kokiri Auto FG) shows the target pacing ceiling without Anti-Lag 2.

Where it makes a difference:

Metric Before: main @ 86b3b9e4 After: this PR @ 62e78b22
Market FIFO 100% render scale 1% low FPS (RX_VK_ANTILAG=1, FG Off) 26.49 FPS 29.52 FPS (+11.4%)
Kokiri Auto FG gwait (RX_VK_ANTILAG=1, host GPU resource wait) 0.88 ms 0.66 ms (-25.0%)

Where it does NOT make a difference (within run-to-run variance):

Metric Before: main @ 86b3b9e4 After: this PR @ 62e78b22
Market FIFO 100% render scale Mean FPS (RX_VK_ANTILAG=1, FG Off) 44.62 FPS 44.40 FPS (-0.5%)
Market Immediate 100% render scale Mean FPS (RX_VK_ANTILAG=1, FG Off) 44.32 FPS 44.38 FPS (+0.1%)
Market Immediate 100% render scale 1% low FPS (RX_VK_ANTILAG=1, FG Off) 25.69 FPS (R1 trough 17.60) 26.43 FPS (+2.9%, floor cleared)
Kokiri 1600x1000 Auto FG Mean FPS (RX_VK_ANTILAG=1) 32.22 FPS 32.86 FPS (+2.0%)
Kokiri 1600x1000 Auto FG 1% low FPS (RX_VK_ANTILAG=1) 14.18 FPS 13.31 FPS (-6.1%, range 12.37–15.56)

Risks

  • Low risk: VK_AMD_anti_lag vkAntiLagUpdateAMD has no externsync requirement in vk.xml, and in_flight + need_off guarantees MODE_OFF_AMD fires once after all in-flight MODE_ON_AMD calls return.
  • Players can disable Anti-Lag 2 at any time via RX_VK_ANTILAG=0 or the menu toggle; reverting the PR is a clean 2-file revert. Nothing changes in saves, longshot_options.ini, or shader caches.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (python -I -B tests/run_all.py: 744 passed, 14 failed, 102 skipped; all 14 are pre-existing Windows-env failures — 13 shared across clean main + 16-way test_sampler_admission.py flake).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
## Summary What a player notices: - **Helps:** Eliminates AMD Anti-Lag 2 frame-pacing stutters on AMD GPUs with `VK_AMD_anti_lag`, recovering `+11.4%` Market FIFO 1% low FPS (`26.49 -> 29.52 FPS`, `83%` of the `AL0 -> AL1` deficit) and cutting Kokiri Auto FG host GPU resource wait by `25%` (`0.88 -> 0.66 ms`). - **No measurable impact:** Mean FPS (`44.62 -> 44.40 FPS` Market FIFO, `44.32 -> 44.38 FPS` Market Immediate) and setups without `VK_AMD_anti_lag` (NVIDIA / Steam Deck / `RX_VK_ANTILAG=0`). Two bugs in the AMD Anti-Lag 2 integration caused pacing stalls and inaccurate `PRESENT` timing: 1. `antilag_input()` in `gpu/vk/vk_antilag.cpp` held `a.mu` across the blocking `vkAntiLagUpdateAMD(INPUT)` driver call (`vk_replay.cpp` `do_present`), stalling `display_main` (`present_commit` holds `present_image_mu` + `dev.present_mu` while calling `antilag_present()`). The fix snapshots/allocates state under `a.mu` and drops `a.mu` before calling `vkAntiLagUpdateAMD`, using `need_off` + `in_flight` + `take_off()` so disabling Anti-Lag 2 while a call is in flight emits `VK_ANTI_LAG_MODE_OFF_AMD` once after all in-flight `MODE_ON_AMD` calls return. 2. On non-FG presents (`present_thread_on()` is always `true`), `present_out` `hand_off` called `antilag_present()` before `presenter_wait_copy(done)` instead of immediately before `vkQueuePresentKHR`. The fix snapshots `antilag_id` via `antilag_frame()` at `hand_off`, carries `antilag_id` on `Presenter::Job`, and calls `antilag_present()` in `presenter_loop` right before `vkQueuePresentKHR` (leaving `gpu/vk/vk_antilag.h` untouched). Files to read first: `gpu/vk/vk_antilag.cpp`, `gpu/vk/vk_replay.cpp`, and `tests/test_antilag.py`. ## Testing **Tested:** - **Hardware / OS:** Windows 11 (build 26300), AMD Ryzen AI 7 350 / Radeon 860M (8 CUs, RDNA 3.5 iGPU), Adrenalin `26.10.1 (LLPC)`. - **How to test:** 1. Launch Market (`market-entrance`), walk straight forward `5 s` (`0:LUP/5000`) to the central fountain, and traverse for `19.5 s` after a `12.5 s` settle under `V-Sync On (FIFO)` and `V-Sync Auto (Immediate)` with `RX_VK_ANTILAG=1` vs `RX_VK_ANTILAG=0`. 2. Launch Kokiri (`kokiri-start`) at `1600x1000` windowed `120 Hz` with Built-in Auto FG (`frame_generation=1`, `frame_generation_by=1`) and `RX_VK_ANTILAG=1` vs `RX_VK_ANTILAG=0`. - **Checks:** - `python -I -B tests/test_antilag.py` failed on `forge/main` (`86b3b9e4`) for both bugs and passes `--strict` on `62e78b22` (`clang++` and `g++`, including concurrent `want=0` + `antilag_frame()`/`antilag_present()` tests). - `python -I -B tests/run_all.py --strict tests/test_antilag.py tests/test_fps_stats.py tests/test_present_acquire_ahead.py tests/test_present_thread.py`: `4 passed, 0 failed, 0 skipped`. - `python -I -B tests/run_all.py --changed forge/main`: `130 passed, 0 failed, 12 skipped` (7 `cargo` not on PATH, 4 Linux-only `spirv-val`/`setenv`, 1 Vulkan 1.3 offscreen). - `python -I -B scripts/check_guide_screenshots.py --review-sources`: `0` issues on branch-touched files. **Still to test:** - Discrete AMD RDNA 3/4 (`mirrors=1`, Windows & Linux Mesa RADV): run Market FIFO/Immediate + Auto FG with `RX_VK_ANTILAG=1`, expecting recovered 1% lows and zero `DEVICE_LOST` (`@Beanstalk` after push). - NVIDIA RTX & Steam Deck (`VK_AMD_anti_lag` absent): short smoke run, expecting clean no-op parity (`@Beanstalk` after push). ## Measurements **Verdict:** Market FIFO `RX_VK_ANTILAG=1` 1% low FPS improved **+11.4%** (`26.49 -> 29.52 FPS`, recovering `83%` of the `AL0 -> AL1` deficit) and Kokiri Auto FG host GPU resource wait dropped **-25%** (`0.88 -> 0.66 ms`, matching `AL0` `0.69 ms`), with `0` `DEVICE_LOST` and `0` `without-inputs` fallbacks across 27 serialized runs. Setup: Windows 11, AMD Radeon 860M (`26.10.1 LLPC`), windowed `120 Hz` (`4804x1753` Market / `3600x1753` Kokiri DPI-scaled swapchains), `nvn: window crop 0,0 2304x1440` (`100% render scale`, `output_res=2560x1440`, `ultrawide=1`, `handheld_profile=0`), `RX_VK_PRECOMPILE=0`, 3-round interleaved medians (`RX_VK_ANTILAG=1`), `presenter thread: the copy's fence` `2.95–8.91 ms` in Kokiri logs. *(Benchmark runs executed on `ad617253`; `62e78b22` only adds the `need_off`/`in_flight` Off-transition guard under `a.mu` with identical steady-state `ON` hot path.)* Baseline: `main @ 86b3b9e4` with `RX_VK_ANTILAG=0` (`30.14 FPS` 1% low Market FIFO, `25.34 FPS` 1% low Market Immediate, `0.69 ms` `gwait` Kokiri Auto FG) shows the target pacing ceiling without Anti-Lag 2. Where it makes a difference: | Metric | Before: main @ 86b3b9e4 | After: this PR @ 62e78b22 | | --- | ---: | ---: | | Market FIFO `100% render scale` 1% low FPS (`RX_VK_ANTILAG=1`, FG Off) | 26.49 FPS | **29.52 FPS (+11.4%)** | | Kokiri Auto FG `gwait` (`RX_VK_ANTILAG=1`, host GPU resource wait) | 0.88 ms | **0.66 ms (-25.0%)** | Where it does NOT make a difference (within run-to-run variance): | Metric | Before: main @ 86b3b9e4 | After: this PR @ 62e78b22 | | --- | ---: | ---: | | Market FIFO `100% render scale` Mean FPS (`RX_VK_ANTILAG=1`, FG Off) | 44.62 FPS | 44.40 FPS (-0.5%) | | Market Immediate `100% render scale` Mean FPS (`RX_VK_ANTILAG=1`, FG Off) | 44.32 FPS | 44.38 FPS (+0.1%) | | Market Immediate `100% render scale` 1% low FPS (`RX_VK_ANTILAG=1`, FG Off) | 25.69 FPS (R1 trough 17.60) | 26.43 FPS (+2.9%, floor cleared) | | Kokiri `1600x1000` Auto FG Mean FPS (`RX_VK_ANTILAG=1`) | 32.22 FPS | 32.86 FPS (+2.0%) | | Kokiri `1600x1000` Auto FG 1% low FPS (`RX_VK_ANTILAG=1`) | 14.18 FPS | 13.31 FPS (-6.1%, range 12.37–15.56) | ## Risks - Low risk: `VK_AMD_anti_lag` `vkAntiLagUpdateAMD` has no `externsync` requirement in `vk.xml`, and `in_flight` + `need_off` guarantees `MODE_OFF_AMD` fires once after all in-flight `MODE_ON_AMD` calls return. - Players can disable Anti-Lag 2 at any time via `RX_VK_ANTILAG=0` or the menu toggle; reverting the PR is a clean 2-file revert. Nothing changes in saves, `longshot_options.ini`, or shader caches. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (`python -I -B tests/run_all.py`: `744 passed, 14 failed, 102 skipped`; all 14 are pre-existing Windows-env failures — 13 shared across clean `main` + 16-way `test_sampler_admission.py` flake). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
Assisted-by: Antigravity
fix(vk): avoid holding Anti-Lag 2 mutex across driver calls and fire PRESENT right before vkQueuePresentKHR
Some checks failed
PR description / Title and description (pull_request_target) Successful in 5s
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/windows+amd+window 0/1 pass, 0 running, 1 queued
beanstalk/windows+amd+igpu+window 0/1 pass, 0 running, 2 queued
beanstalk/windows+nvidia+window+gpu-rtx-* 0/1 pass, 0 running, 2 queued
beanstalk/windows+intel+window 0/1 pass, 0 running, 2 queued
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
62e78b2261
Assisted-by: Antigravity
Author
Contributor

Tested in game: Windows 11 Radeon 860M (26.10.1 LLPC): 27 serialized 3-round interleaved runs in Market FIFO/Immediate and Kokiri Auto FG; Market FIFO 1% low +11.4%, Kokiri gwait -25%, 0 DEVICE_LOST

Tested in game: Windows 11 Radeon 860M (26.10.1 LLPC): 27 serialized 3-round interleaved runs in Market FIFO/Immediate and Kokiri Auto FG; Market FIFO 1% low +11.4%, Kokiri gwait -25%, 0 DEVICE_LOST
Author
Contributor

@Beanstalk Please run Market FIFO/Immediate + Auto FG (RX_VK_ANTILAG=1) on discrete AMD RDNA 3/4 (Windows and Linux Mesa RADV), plus a short smoke check on NVIDIA RTX and Steam Deck (VK_AMD_anti_lag absent no-op parity).

@Beanstalk Please run Market FIFO/Immediate + Auto FG (`RX_VK_ANTILAG=1`) on discrete AMD RDNA 3/4 (Windows and Linux Mesa RADV), plus a short smoke check on NVIDIA RTX and Steam Deck (`VK_AMD_anti_lag` absent no-op parity).
Member

@Jer9 only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@Jer9 only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Owner
@review
Owner

@beanstalk

@beanstalk
Member
Beanstalk test farm · an earlier run: commit 62e78b2 (the newer results are in a comment below)

Commit 62e78b2 · approved by HumanBean (reviewed) · dashboard

⚠️ Note: Linux RADV and Steam Deck present-path tests are omitted because window scenarios currently run only on Windows; the Windows AMD and NVIDIA targets still exercise the requested paths.
⚠️ Note: The farm cannot reproduce the specified window sizes or refresh rate, measure the reported host GPU resource wait, or verify the exact timing and ordering of driver calls.
⚠️ Note: The Market measurements are stationary after the initial walk rather than the reported traversal, and the live toggle cannot guarantee an in-flight call; the plan also does not compare Anti-Lag on against off.

Started at 00:55 UTC.

Estimate: done in about 1 h 15 min, from the queue and the testers online now; some jobs can't start yet.

Target Result Reports Frame time p99 (ms), main → PR VRAM peak (MB) Crashes
windows+amd+window ⏳ queued 1 1 — — none
windows+amd+igpu+window ⏳ queued 0 of 1 — — —
windows+nvidia+window+gpu-rtx-* (GPU "rtx *") ⏳ queued 0 of 1 — — —
windows+intel+window ⏳ queued 0 of 1 — — —

Couldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.

  • windows+amd+window, report 1: main's longshot-builder failed (exit 1): could not compile 'proc-macro2' (build script) due to 1 previous error
What was tested

What will be tested · AI plan (gpt-6.1-terra)

The plan compares the PR with main in a real Windows window, using three starts per side on AMD, NVIDIA and Intel targets. It measures Market frame times with V-Sync On and Auto, then Kokiri frame times with built-in Auto frame generation, with Anti-Lag 2 enabled and a live off/on toggle. Each measurement lasts 20 seconds after warm-up; the run takes about 40 minutes per tester. A crash, device-lost log, or frame-time regression over 15% fails the plan. The plan does not directly require the reported 11.4% improvement.

  • Where: windows+amd+window (1-2 reports), windows+amd+igpu+window (1-2 reports), windows+nvidia+window+gpu-rtx-* (GPU "rtx *", 1-2 reports), windows+intel+window (1-2 reports).
  • market-and-kokiri: from the repository's save market-entrance (settings vsync=1, amd_anti-lag_2=1, frame_generation=0; switches RX_VK_ANTILAG=1; in a hidden window (the present path runs)), then move the stick, measure market-fifo for 20 s (after 5 s warm-up), set vsync to 0, measure market-auto for 20 s (after 10 s warm-up), set amd_anti-lag_2 to 0, set amd_anti-lag_2 to 1, teleport to Kokiri Forest, set frame_generation_by to 1, set frame_generation to 1, measure kokiri-auto-fg for 20 s (after 10 s warm-up); 3 runs on each side.
  • Measured: crashes, frame times, stutters and hitches, the game's log.
  • The PR fails if: it crashes; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0; or frame time (worst 1%) is more than 15% above main.
  • Time: about 41 min of game runs per tester (6 game starts), plus the two builds.
Measurements on `windows+amd+window`, for the PR description

Verdict: queued on windows+amd+window (1 report).

Hardware: 1: windows+amd+amd-proprietary+dgpu+xess AMD Radeon RX 6700 XT, 2.0.353 AMD Ryzen 7 2700X Eight-Core Processor, 16 GB RAM
Scene: market-and-kokiri, from the repository's save market-entrance (vsync=1, amd_anti-lag_2=1, frame_generation=0, RX_VK_ANTILAG=1); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-and-kokiri: 3 game starts a side, market-fifo 20 s after 5 s warm-up, market-auto 20 s after 10 s warm-up, kokiri-auto-fg 20 s after 10 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Nothing was measured: no metric came back.

Flags and settings

None: the plan varied no setting, switch or build option.

As Markdown for the PR description:

## Measurements

**Verdict:** queued on windows+amd+window (1 report).

Hardware: 1: windows+amd+amd-proprietary+dgpu+xess `AMD Radeon RX 6700 XT, 2.0.353` `AMD Ryzen 7 2700X Eight-Core Processor, 16 GB RAM`  
Scene: market-and-kokiri, from the repository's save market-entrance (vsync=1, amd_anti-lag_2=1, frame_generation=0, RX_VK_ANTILAG=1); each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-and-kokiri: 3 game starts a side, market-fifo 20 s after 5 s warm-up, market-auto 20 s after 10 s warm-up, kokiri-auto-fg 20 s after 10 s warm-up; each number the median of the runs, then of 1 report  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

Nothing was measured: no metric came back.

**Flags and settings**

None: the plan varied no setting, switch or build option.
The testers' hardware
Target Report Ran on
windows+amd+window 1 windows+amd+amd-proprietary+dgpu+xess AMD Radeon RX 6700 XT, 2.0.353 AMD Ryzen 7 2700X Eight-Core Processor, 16 GB RAM
<!-- beanstalk:previous --> <details><summary>Beanstalk test farm · an earlier run: commit <code>62e78b2</code> (the newer results are in a comment below)</summary> Commit `62e78b2` · approved by HumanBean (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/2704) ⚠️ **Note:** Linux RADV and Steam Deck present-path tests are omitted because window scenarios currently run only on Windows; the Windows AMD and NVIDIA targets still exercise the requested paths. ⚠️ **Note:** The farm cannot reproduce the specified window sizes or refresh rate, measure the reported host GPU resource wait, or verify the exact timing and ordering of driver calls. ⚠️ **Note:** The Market measurements are stationary after the initial walk rather than the reported traversal, and the live toggle cannot guarantee an in-flight call; the plan also does not compare Anti-Lag on against off. Started at 00:55 UTC. **Estimate:** done in about 1 h 15 min, from the queue and the testers online now; some jobs can't start yet. | Target | Result | Reports | Frame time p99 (ms), main → PR | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | --- | | `windows+amd+window` | ⏳ queued | 1 [1](https://beanstalk.magicbean.dev/reports/rp_d4e3d6b8cb2e0248) | — | — | none | | `windows+amd+igpu+window` | ⏳ queued | 0 of 1 | — | — | — | | `windows+nvidia+window+gpu-rtx-*` (GPU "rtx *") | ⏳ queued | 0 of 1 | — | — | — | | `windows+intel+window` | ⏳ queued | 0 of 1 | — | — | — | **Couldn't be judged**: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own. - `windows+amd+window`, [report 1](https://beanstalk.magicbean.dev/reports/rp_d4e3d6b8cb2e0248): `main's longshot-builder failed (exit 1): could not compile 'proc-macro2' (build script) due to 1 previous error` <details><summary>What was tested</summary> **What will be tested** · AI plan (`gpt-6.1-terra`) The plan compares the PR with main in a real Windows window, using three starts per side on AMD, NVIDIA and Intel targets. It measures Market frame times with V-Sync On and Auto, then Kokiri frame times with built-in Auto frame generation, with Anti-Lag 2 enabled and a live off/on toggle. Each measurement lasts 20 seconds after warm-up; the run takes about 40 minutes per tester. A crash, device-lost log, or frame-time regression over 15% fails the plan. The plan does not directly require the reported 11.4% improvement. - **Where:** windows+amd+window (1-2 reports), windows+amd+igpu+window (1-2 reports), windows+nvidia+window+gpu-rtx-* (GPU "rtx *", 1-2 reports), windows+intel+window (1-2 reports). - **market-and-kokiri:** from the repository's save `market-entrance` (settings vsync=1, amd_anti-lag_2=1, frame_generation=0; switches `RX_VK_ANTILAG=1`; in a hidden window (the present path runs)), then move the stick, measure market-fifo for 20 s (after 5 s warm-up), set vsync to 0, measure market-auto for 20 s (after 10 s warm-up), set amd_anti-lag_2 to 0, set amd_anti-lag_2 to 1, teleport to Kokiri Forest, set frame_generation_by to 1, set frame_generation to 1, measure kokiri-auto-fg for 20 s (after 10 s warm-up); 3 runs on each side. - **Measured:** crashes, frame times, stutters and hitches, the game's log. - **The PR fails if:** it crashes; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0; or frame time (worst 1%) is more than 15% above main. - **Time:** about 41 min of game runs per tester (6 game starts), plus the two builds. </details> <details><summary>Measurements on `windows+amd+window`, for the PR description</summary> **Verdict:** queued on windows+amd+window (1 report). Hardware: 1: windows+amd+amd-proprietary+dgpu+xess `AMD Radeon RX 6700 XT, 2.0.353` `AMD Ryzen 7 2700X Eight-Core Processor, 16 GB RAM` Scene: market-and-kokiri, from the repository's save market-entrance (vsync=1, amd_anti-lag_2=1, frame_generation=0, RX_VK_ANTILAG=1); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-and-kokiri: 3 game starts a side, market-fifo 20 s after 5 s warm-up, market-auto 20 s after 10 s warm-up, kokiri-auto-fg 20 s after 10 s warm-up; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. **Flags and settings** None: the plan varied no setting, switch or build option. As Markdown for the PR description: ```markdown ## Measurements **Verdict:** queued on windows+amd+window (1 report). Hardware: 1: windows+amd+amd-proprietary+dgpu+xess `AMD Radeon RX 6700 XT, 2.0.353` `AMD Ryzen 7 2700X Eight-Core Processor, 16 GB RAM` Scene: market-and-kokiri, from the repository's save market-entrance (vsync=1, amd_anti-lag_2=1, frame_generation=0, RX_VK_ANTILAG=1); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-and-kokiri: 3 game starts a side, market-fifo 20 s after 5 s warm-up, market-auto 20 s after 10 s warm-up, kokiri-auto-fg 20 s after 10 s warm-up; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. **Flags and settings** None: the plan varied no setting, switch or build option. ``` </details> <details><summary>The testers' hardware</summary> | Target | Report | Ran on | | --- | --- | --- | | `windows+amd+window` | [1](https://beanstalk.magicbean.dev/reports/rp_d4e3d6b8cb2e0248) | windows+amd+amd-proprietary+dgpu+xess `AMD Radeon RX 6700 XT, 2.0.353` `AMD Ryzen 7 2700X Eight-Core Processor, 16 GB RAM` | </details> </details>
BeanBot left a comment

Recommendation: Request changes. The new presenter-thread call reads the menu setting without synchronization, and an Off call can overtake a later On call. The reported performance gain is promising, but it was measured on an earlier commit and the affected Tier 1 systems remain untested.

Moves the Anti-Lag present marker closer to presentation and lets driver calls overlap, reducing the reported Market FIFO stutter on one AMD iGPU. The added concurrency needs safe setting access and ordered mode transitions.

Blocking (1): must change before merging.

  1. L1 gpu/vk/vk_replay.cpp:6981: The new presenter-thread call reads the menu's plain integer setting without the lock used by its writer. (more on the line) Do: Publish the selected Anti-Lag value through an atomic or synchronize all its readers and writers with the same lock, and cover concurrent menu changes in the test.

Should fix (2): not blocking, but worth doing before merging.

  • L2 gpu/vk/vk_antilag.cpp:74: Claiming an Off transition does not prevent a later On call from overtaking it. (more on the line) Do: Order Off against subsequent On calls as well as earlier in-flight calls, without holding the state mutex across a blocking INPUT. Add a test that pauses the claimed Off while another thread turns the setting back on.
  • L3: The standalone test command in Testing omits a required argument. When: tests/test_antilag.py requires --headers, so the stated command exits in argument parsing rather than running the checks. Do: Give the actual command including the Vulkan headers path, or give the run_all.py invocation that supplies it.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L4 gpu/vk/vk_antilag.cpp:182: The final concurrency implementation and its effect on pacing and latency need runs on affected AMD systems. (more on the line) Do: Run interleaved base and final-head Market FIFO and Immediate and Auto FG comparisons on the 860M and representative discrete AMD Windows and RADV systems; report FPS, 1% lows, frame times and latency or marker timing, including run spreads.
  • L5 gpu/vk/vk_replay.cpp:6800: The changed presenter path still needs the requested Tier 1 no-extension smoke runs. (more on the line) Do: Smoke-test presentation and frame generation on NVIDIA and Steam Deck and compare pacing with the base. (@fix does its part first: Skip the state-locking snapshot when the extension is unavailable.)

@fix can do L1, L2, L3 and L5.

Checks: Still running: 10 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven on the final head. The PR reports three-round interleaved medians on Windows Radeon 860M: Market FIFO 1% low rose from 26.49 to 29.52 FPS and Kokiri Auto FG GPU wait fell from 0.88 to 0.66 ms, but those runs used ad617253, before the final concurrency guard. Kokiri 1% low fell from 14.18 to 13.31 FPS within the reported spread.

Other systems: The presenter path runs on all GPUs; systems without the extension still take the Anti-Lag state lock. AMD driver calls and marker timing also affect frame generation and both Windows and Linux. Discrete AMD, NVIDIA and Steam Deck runs are still requested and no results are supplied.

Switches: None added, changed or removed. The existing RX_VK_ANTILAG overrides the menu setting, which defaults to off.

Reviewed: 62e78b2261 against 86b3b9e4f0: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the full Anti-Lag implementation and test, and the changed presenter paths and their callers. Reviewed the full diffs for all six files and the relevant menu and frame-generation paths; skimmed the rest of the large replay and test files. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).

Checked and fine:

  • Both commits record AI assistance.
  • The diff adds no game-derived files, generated files, API changes or switches.
  • The presenter job copies its Anti-Lag ID while holding presenter.mu.
  • The added fixture exercises overlapping driver calls and deferred Off after an in-flight On call.

Testing: Read-only review; no code, scripts, builds or tests were run. The author reports game-free checks and Windows 860M runs; CI is still running.

Overlaps and merge order: Not checked; network closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The new presenter-thread call reads the menu setting without synchronization, and an Off call can overtake a later On call. The reported performance gain is promising, but it was measured on an earlier commit and the affected Tier 1 systems remain untested. Moves the Anti-Lag present marker closer to presentation and lets driver calls overlap, reducing the reported Market FIFO stutter on one AMD iGPU. The added concurrency needs safe setting access and ordered mode transitions. **Blocking (1)**: must change before merging. 1. **L1** `gpu/vk/vk_replay.cpp:6981`: The new presenter-thread call reads the menu's plain integer setting without the lock used by its writer. (more on the line) **Do:** Publish the selected Anti-Lag value through an atomic or synchronize all its readers and writers with the same lock, and cover concurrent menu changes in the test. **Should fix (2)**: not blocking, but worth doing before merging. - **L2** `gpu/vk/vk_antilag.cpp:74`: Claiming an Off transition does not prevent a later On call from overtaking it. (more on the line) **Do:** Order Off against subsequent On calls as well as earlier in-flight calls, without holding the state mutex across a blocking INPUT. Add a test that pauses the claimed Off while another thread turns the setting back on. - **L3**: The standalone test command in Testing omits a required argument. *When:* tests/test_antilag.py requires --headers, so the stated command exits in argument parsing rather than running the checks. **Do:** Give the actual command including the Vulkan headers path, or give the run_all.py invocation that supplies it. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L4** `gpu/vk/vk_antilag.cpp:182`: The final concurrency implementation and its effect on pacing and latency need runs on affected AMD systems. (more on the line) **Do:** Run interleaved base and final-head Market FIFO and Immediate and Auto FG comparisons on the 860M and representative discrete AMD Windows and RADV systems; report FPS, 1% lows, frame times and latency or marker timing, including run spreads. - **L5** `gpu/vk/vk_replay.cpp:6800`: The changed presenter path still needs the requested Tier 1 no-extension smoke runs. (more on the line) **Do:** Smoke-test presentation and frame generation on NVIDIA and Steam Deck and compare pacing with the base. *(`@fix` does its part first: Skip the state-locking snapshot when the extension is unavailable.)* `@fix` can do L1, L2, L3 and L5. **Checks:** Still running: 10 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven on the final head. The PR reports three-round interleaved medians on Windows Radeon 860M: Market FIFO 1% low rose from 26.49 to 29.52 FPS and Kokiri Auto FG GPU wait fell from 0.88 to 0.66 ms, but those runs used ad617253, before the final concurrency guard. Kokiri 1% low fell from 14.18 to 13.31 FPS within the reported spread. **Other systems:** The presenter path runs on all GPUs; systems without the extension still take the Anti-Lag state lock. AMD driver calls and marker timing also affect frame generation and both Windows and Linux. Discrete AMD, NVIDIA and Steam Deck runs are still requested and no results are supplied. **Switches:** None added, changed or removed. The existing RX_VK_ANTILAG overrides the menu setting, which defaults to off. **Reviewed:** 62e78b2261bc against 86b3b9e4f0e1: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, the full Anti-Lag implementation and test, and the changed presenter paths and their callers. Reviewed the full diffs for all six files and the relevant menu and frame-generation paths; skimmed the rest of the large replay and test files. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review). **Checked and fine:** - Both commits record AI assistance. - The diff adds no game-derived files, generated files, API changes or switches. - The presenter job copies its Anti-Lag ID while holding presenter.mu. - The added fixture exercises overlapping driver calls and deferred Off after an in-flight On call. **Testing:** Read-only review; no code, scripts, builds or tests were run. The author reports game-free checks and Windows 860M runs; CI is still running. **Overlaps and merge order:** Not checked; network closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -69,1 +71,4 @@
/// With a.mu held: claims the single Off driver call once no Mode-On stage call is in flight
bool take_off() {
AntiLag& a = al();
Member

L2 (should fix): Claiming an Off transition does not prevent a later On call from overtaking it.

When: One thread claims Off with in_flight zero and releases a.mu before update(false); another observes the row turned on and issues an INPUT with MODE_ON. The first thread can then issue or finish MODE_OFF after that On, leaving the driver off despite the current on setting until a later On update.

Do: Order Off against subsequent On calls as well as earlier in-flight calls, without holding the state mutex across a blocking INPUT. Add a test that pauses the claimed Off while another thread turns the setting back on.

**L2** (should fix): Claiming an Off transition does not prevent a later On call from overtaking it. *When:* One thread claims Off with in_flight zero and releases a.mu before update(false); another observes the row turned on and issues an INPUT with MODE_ON. The first thread can then issue or finish MODE_OFF after that On, leaving the driver off despite the current on setting until a later On update. **Do:** Order Off against subsequent On calls as well as earlier in-flight calls, without holding the state mutex across a blocking INPUT. Add a test that pauses the claimed Off while another thread turns the setting back on.
@ -136,0 +179,4 @@
return;
}
if (!f) return;
stage(VK_ANTI_LAG_STAGE_INPUT_AMD, f); // (the driver's wait, when it wants one; a.mu dropped so presents never wait on it)
Member

L4 (should fix): The final concurrency implementation and its effect on pacing and latency need runs on affected AMD systems.

When: The reported runs precede the final guard, and moving PRESENT after the copy fence changes its timing relative to INPUT and presentation. The supplied results do not establish the final head's gain or latency on discrete AMD Windows and Linux drivers.

Do: Run interleaved base and final-head Market FIFO and Immediate and Auto FG comparisons on the 860M and representative discrete AMD Windows and RADV systems; report FPS, 1% lows, frame times and latency or marker timing, including run spreads.

**L4** (should fix): The final concurrency implementation and its effect on pacing and latency need runs on affected AMD systems. *When:* The reported runs precede the final guard, and moving PRESENT after the copy fence changes its timing relative to INPUT and presentation. The supplied results do not establish the final head's gain or latency on discrete AMD Windows and Linux drivers. **Do:** Run interleaved base and final-head Market FIFO and Immediate and Auto FG comparisons on the 860M and representative discrete AMD Windows and RADV systems; report FPS, 1% lows, frame times and latency or marker timing, including run spreads.
@ -6798,2 +6798,3 @@
if (reflex_id) reflex_present_handed_off();
antilag_present(); // (AMD Anti-Lag 2: the frame's present stage)
// (AMD Anti-Lag 2: snapshot the frame index now before the next input stage advances it; presenter_loop fires PRESENT right before vkQueuePresentKHR)
const uint64_t antilag_id = antilag_present_frame == kAntiLagThisFrame ? antilag_frame() : antilag_present_frame;
Member

L5 (should fix): The changed presenter path still needs the requested Tier 1 no-extension smoke runs.

When: NVIDIA and Steam Deck also execute the new hand-off snapshot, but no game run on either system is reported.

Do: Smoke-test presentation and frame generation on NVIDIA and Steam Deck and compare pacing with the base.

**L5** (should fix): The changed presenter path still needs the requested Tier 1 no-extension smoke runs. *When:* NVIDIA and Steam Deck also execute the new hand-off snapshot, but no game run on either system is reported. **Do:** Smoke-test presentation and frame generation on NVIDIA and Steam Deck and compare pacing with the base.
@ -6975,1 +6978,4 @@
pi.pImageIndices = &index;
if (antilag_id) {
antilag_present_frame = antilag_id;
antilag_present();
Member

L1 (blocking): The new presenter-thread call reads the menu's plain integer setting without the lock used by its writer.

When: With the extension available and no RX_VK_ANTILAG override, the presenter calls antilag_present(), which reads opts.antilag through wanted(), while menu_tick can write that same value under menu_mu. The Anti-Lag mutex does not protect the menu write, so changing the row while a present is in flight is a C++ data race.

Do: Publish the selected Anti-Lag value through an atomic or synchronize all its readers and writers with the same lock, and cover concurrent menu changes in the test.

**L1** (blocking): The new presenter-thread call reads the menu's plain integer setting without the lock used by its writer. *When:* With the extension available and no RX_VK_ANTILAG override, the presenter calls antilag_present(), which reads opts.antilag through wanted(), while menu_tick can write that same value under menu_mu. The Anti-Lag mutex does not protect the menu write, so changing the row while a present is in flight is a C++ data race. **Do:** Publish the selected Anti-Lag value through an atomic or synchronize all its readers and writers with the same lock, and cover concurrent menu changes in the test.
fix(vk): publish Anti-Lag 2 option atomically, order Off against On, and skip lock when unavailable
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 32s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
beanstalk/approval not approved yet
0a068733cf
Assisted-by: Antigravity
Member

Beanstalk test farm

Commit 0a06873 · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `0a06873` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/2704) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
Author
Contributor

Addressed BeanBot review items L1, L2, and L5 in commit 0a068733:

  • L1 (Blocking): Added live_antilag std::atomic<int> (menu_antilag_changed(int) / menu_antilag()) synced in menu_init(), menu_tick(), and .on_change on amd_anti-lag_2, read via menu_antilag() in wanted(). Added static wiring checks and a multi-threaded concurrent toggle stress test (Concurrency 7) in tests/test_antilag.py.
  • L2 (Should fix): Added off_in_flight + send_off() in gpu/vk/vk_antilag.cpp so MODE_OFF_AMD and MODE_ON_AMD are mutually excluded in both directions without holding a.mu across blocking INPUT calls. Added paused-Off + concurrent want=1 test (Concurrency 6) in tests/test_antilag.py.
  • L5 (Should fix): Made AntiLag::ready std::atomic<bool> with lock-free !ready early returns in antilag_frame()/antilag_present()/antilag_input() plus !antilag_available() guard at hand_off (gpu/vk/vk_replay.cpp:6800), verified with a mutex-held runtime test.

Checks: tests/test_antilag.py --strict passes on both clang++ and g++; tests/run_all.py --changed forge/main passes (211/211 non-skipped); longshot_vk.dll rebuilt cleanly.

Addressed BeanBot review items **L1**, **L2**, and **L5** in commit `0a068733`: - **L1 (Blocking):** Added `live_antilag` `std::atomic<int>` (`menu_antilag_changed(int)` / `menu_antilag()`) synced in `menu_init()`, `menu_tick()`, and `.on_change` on `amd_anti-lag_2`, read via `menu_antilag()` in `wanted()`. Added static wiring checks and a multi-threaded concurrent toggle stress test (`Concurrency 7`) in `tests/test_antilag.py`. - **L2 (Should fix):** Added `off_in_flight` + `send_off()` in `gpu/vk/vk_antilag.cpp` so `MODE_OFF_AMD` and `MODE_ON_AMD` are mutually excluded in both directions without holding `a.mu` across blocking `INPUT` calls. Added paused-`Off` + concurrent `want=1` test (`Concurrency 6`) in `tests/test_antilag.py`. - **L5 (Should fix):** Made `AntiLag::ready` `std::atomic<bool>` with lock-free `!ready` early returns in `antilag_frame()`/`antilag_present()`/`antilag_input()` plus `!antilag_available()` guard at `hand_off` (`gpu/vk/vk_replay.cpp:6800`), verified with a mutex-held runtime test. Checks: `tests/test_antilag.py --strict` passes on both `clang++` and `g++`; `tests/run_all.py --changed forge/main` passes (`211/211` non-skipped); `longshot_vk.dll` rebuilt cleanly.
Owner
@review
BeanBot left a comment

Recommendation: Approve. The atomic setting and Off/On ordering fixes address the code issues, and the unavailable-extension path avoids the added lock. The final implementation still needs the requested AMD pacing and latency runs and Tier 1 no-extension smoke runs. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

The change moves Anti-Lag driver calls outside the state mutex and sends the present marker closer to presentation. It adds concurrency state and atomic setting publication to preserve ordering while reducing stalls.

Should fix (1): not blocking, but worth doing before merging.

  • L3: The standalone test command in Testing omits a required argument. When: tests/test_antilag.py requires --headers, so the stated command exits in argument parsing rather than running the checks. Do: Give the actual command including the Vulkan headers path, or give the run_all.py invocation that supplies it.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L4 gpu/vk/vk_antilag.cpp:182: The final concurrency implementation and its effect on pacing and latency need runs on affected AMD systems. When: The reported runs precede the final guard, and moving PRESENT after the copy fence changes its timing relative to INPUT and presentation. The supplied results do not establish the final head's gain or latency on discrete AMD Windows and Linux drivers. Do: Run interleaved base and final-head Market FIFO and Immediate and Auto FG comparisons on the 860M and representative discrete AMD Windows and RADV systems; report FPS, 1% lows, frame times and latency or marker timing, including run spreads.
  • L5 gpu/vk/vk_replay.cpp:6800: The changed presenter path still needs the requested Tier 1 no-extension smoke runs. When: NVIDIA and Steam Deck also execute the new hand-off snapshot, but no game run on either system is reported. Do: Smoke-test presentation and frame generation on NVIDIA and Steam Deck and compare pacing with the base. (@fix does its part first: Skip the state-locking snapshot when the extension is unavailable.)

@fix can do L3 and L5.

Since the last review (on 62e78b2261)
Resolved: L1 (The new presenter-thread call reads the menu's plain integer setting without the lock used…); L2 (Claiming an Off transition does not prevent a later On call from overtaking it.)
Still open: L3 (The standalone test command in Testing omits a required argument.); L4 (The final concurrency implementation and its effect on pacing and latency need runs on aff…); L5 (The changed presenter path still needs the requested Tier 1 no-extension smoke runs.)

Checks: Still running: 10 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven for the final implementation. On the earlier benchmarked commit, the author reports Market FIFO 1% lows rising from 26.49 to 29.52 FPS and Kokiri Auto FG host GPU resource wait falling from 0.88 to 0.66 ms on a Windows Radeon 860M; the final concurrency changes have not been measured.

Other systems: AMD Windows and Linux drivers can see different timing and concurrent driver calls; the requested discrete AMD runs remain outstanding. NVIDIA and Steam Deck lack the extension and now skip the state lock, but their requested smoke runs remain outstanding.

Switches: No switches added, changed or removed. RX_VK_ANTILAG continues to override the menu setting.

Reviewed: 0a068733cf against 86b3b9e4f0: Read AGENTS.md, CONTRIBUTING.md, the pull request template, gpu/vk/vk_antilag.cpp and the changes since the ledger head; inspected the relevant menu and presenter diffs and test changes. The remaining changed files and surrounding code were not read in full; recorded runs were read from the pull request and comments.; nothing run (a code review).

Checked and fine:

  • The unavailable-extension fast path returns before acquiring the Anti-Lag mutex.
  • The fix preserves the deferred presenter marker and unlocked driver calls.

Testing: No commands from the project were run. The author reports the Anti-Lag test passing on clang++ and g++, changed tests passing, and a Windows renderer rebuild; CI is still running.

Overlaps and merge order: Not checked; network access is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The atomic setting and Off/On ordering fixes address the code issues, and the unavailable-extension path avoids the added lock. The final implementation still needs the requested AMD pacing and latency runs and Tier 1 no-extension smoke runs. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. The change moves Anti-Lag driver calls outside the state mutex and sends the present marker closer to presentation. It adds concurrency state and atomic setting publication to preserve ordering while reducing stalls. **Should fix (1)**: not blocking, but worth doing before merging. - **L3**: The standalone test command in Testing omits a required argument. *When:* tests/test_antilag.py requires --headers, so the stated command exits in argument parsing rather than running the checks. **Do:** Give the actual command including the Vulkan headers path, or give the run_all.py invocation that supplies it. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L4** `gpu/vk/vk_antilag.cpp:182`: The final concurrency implementation and its effect on pacing and latency need runs on affected AMD systems. *When:* The reported runs precede the final guard, and moving PRESENT after the copy fence changes its timing relative to INPUT and presentation. The supplied results do not establish the final head's gain or latency on discrete AMD Windows and Linux drivers. **Do:** Run interleaved base and final-head Market FIFO and Immediate and Auto FG comparisons on the 860M and representative discrete AMD Windows and RADV systems; report FPS, 1% lows, frame times and latency or marker timing, including run spreads. - **L5** `gpu/vk/vk_replay.cpp:6800`: The changed presenter path still needs the requested Tier 1 no-extension smoke runs. *When:* NVIDIA and Steam Deck also execute the new hand-off snapshot, but no game run on either system is reported. **Do:** Smoke-test presentation and frame generation on NVIDIA and Steam Deck and compare pacing with the base. *(`@fix` does its part first: Skip the state-locking snapshot when the extension is unavailable.)* `@fix` can do L3 and L5. **Since the last review** (on 62e78b2261bc) Resolved: L1 (The new presenter-thread call reads the menu's plain integer setting without the lock used…); L2 (Claiming an Off transition does not prevent a later On call from overtaking it.) Still open: L3 (The standalone test command in Testing omits a required argument.); L4 (The final concurrency implementation and its effect on pacing and latency need runs on aff…); L5 (The changed presenter path still needs the requested Tier 1 no-extension smoke runs.) **Checks:** Still running: 10 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven for the final implementation. On the earlier benchmarked commit, the author reports Market FIFO 1% lows rising from 26.49 to 29.52 FPS and Kokiri Auto FG host GPU resource wait falling from 0.88 to 0.66 ms on a Windows Radeon 860M; the final concurrency changes have not been measured. **Other systems:** AMD Windows and Linux drivers can see different timing and concurrent driver calls; the requested discrete AMD runs remain outstanding. NVIDIA and Steam Deck lack the extension and now skip the state lock, but their requested smoke runs remain outstanding. **Switches:** No switches added, changed or removed. RX_VK_ANTILAG continues to override the menu setting. **Reviewed:** 0a068733cf2c against 86b3b9e4f0e1: Read AGENTS.md, CONTRIBUTING.md, the pull request template, gpu/vk/vk_antilag.cpp and the changes since the ledger head; inspected the relevant menu and presenter diffs and test changes. The remaining changed files and surrounding code were not read in full; recorded runs were read from the pull request and comments.; nothing run (a code review). **Checked and fine:** - The unavailable-extension fast path returns before acquiring the Anti-Lag mutex. - The fix preserves the deferred presenter marker and unlocked driver calls. **Testing:** No commands from the project were run. The author reports the Anti-Lag test passing on clang++ and g++, changed tests passing, and a Windows renderer rebuild; CI is still running. **Overlaps and merge order:** Not checked; network access is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch fix/vk-antilag2-mutex-present 2026-11-28 01:24:54 +00:00
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 32s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
beanstalk/approval not approved yet
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
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
MagicBeanDev/Longshot!2704
No description provided.