feat(vk): measure the PCIe link at start and log it #3161

Merged
HumanBean merged 6 commits from neotoxic/Longshot:perf/pcie-probe into main 2026-12-04 18:23:03 +00:00
Contributor

Summary

When a player reports stutter or low fps, nothing in the log says what their GPU sits behind: a full x16 slot, a laptop's x8, a x4 slot, or an eGPU over Thunderbolt. Every submission sends the pages the CPU wrote to VRAM (the mirrors) and brings the GPU's writes back, and that traffic costs a lot more on a narrow link.

This adds one line to the log at start, on a discrete GPU only. It gives the link speed measured each way and the link the OS says was negotiated, from the GPU up to its root port. The measurement is a 32 MB copy each way, best of 6 rounds, timed with GPU timestamps. The OS's link comes from sysfs on Linux and from the PCI bus driver's properties on Windows. Nothing else changes: the line only tells what the link is.

vk: pcie link: measured 26.8 GB/s host to device, 26.4 device to host (32 MB, best of 6 rounds, 19 ms); the OS's link over 1 hops: narrowest now 16 GT/s x16 (31.5 GB/s, the GPU), at most 32 GT/s x16 (63.0 GB/s, the GPU); the GPU's own now 16 GT/s x16 (31.5 GB/s, the GPU), at most 32 GT/s x16 (63.0 GB/s, the GPU)

RX_VK_PCIE_PROBE=0 leaves the probe out, in case a driver mishandles it. The line then reads vk: pcie link: not probed (RX_VK_PCIE_PROBE=0).

A mode for slow links was built and measured on top of this probe, and it is not part of this PR. That mode made mirror syncs copy only the 256-byte blocks that changed since a page's last sync. It was correct: RX_VK_MEM_CHECK read every diffed page back on Windows and Linux, and 0 pages differed. It also sent 59 % fewer upload bytes. But it gained nothing on an x16 desktop and lost 3 % fps on a PCIe 3.0 x8 laptop, where the hashing cost more than the link saved. The probe stays because the log line is useful for diagnosing reports.

The idea of a measured link probe comes from HeyListen (Sacrappy) and ProjectReLink. No code was taken from either; the code is Longshot's own.

Read first: gpu/vk/vk_pcie_link.cpp pcie_link_probe (the probe and the line), then gpu/vk/pcie_link.h (the parsing rules, tested without a GPU).

Testing

Tested:

  • Windows 11, RTX 5080 at PCIe x16, ran dev.py ab --env RX_VK_PCIE_PROBE=0 --runs 1 in Hyrule Field on c9a29ba7. With the switch unset, the log has the line above: 26.8 / 26.4 GB/s, measured in 19 ms. With RX_VK_PCIE_PROBE=0, the log says "not probed". Both runs played normally and the logs have no FATAL line.
  • CachyOS, RTX 3060 Laptop with its display wired straight to the dGPU (MUX), on 181ae977 (the same probe, which also set a policy flag removed since). The line read 6.7 GB/s host to device and 6.6 device to host, measured in 74 ms, and the OS's link was 8 GT/s x8 over 2 hops. The Linux code built and ran.
  • The same laptop at c9a29ba7: built on Linux, the line read 6.7 / 6.6 GB/s in 75 ms, and dev.py ab --runs 3 in Hyrule Field against main @ ee9e1ed7 gave the same fps (Measurements).
  • Checks on c9a29ba7: tests/test_pcie_link.py (the parsing rules compiled and run on made-up values, plus the source: the probe after the device is made, the kill switch read before anything is measured, no slow-link switch left), tests/test_switch_table.py, tests/test_device_policy.py, tests/test_recorder_sync.py (source part: the probe's own command buffer is listed as direct). run_all.py --changed origin/main gives 116 passed, 3 failed, 14 skipped. The 3 that fail, test_tex_desc_memo, test_recorder_sync (runtime part) and test_prepare_stall, fail the same way on main ee9e1ed7 on this PC.

Still to test:

  • An AMD GPU (Windows and Linux): start the game and read the vk: pcie link: line, expecting measured GB/s close to the link's and the OS's link read, with no crash or driver error at start (@Beanstalk run any scene on an AMD runner and post the vk: pcie link line)
  • An Intel Arc GPU (Windows): the same, expecting the same (@Beanstalk run any scene on an Intel Arc runner and post the vk: pcie link line)
  • A hybrid (Optimus) laptop with its display on the iGPU: start the game on the dGPU and read the line, expecting the dGPU's link measured, or "not measured" with a reason, and the game starting normally (by hand)

Measurements

Verdict: nothing measurable: the probe runs once at start (19 ms on x16, 75 ms on PCIe 3.0 x8) and nothing in a frame changes.

Setup: an RTX 3060 Laptop on CachyOS with its display wired to the dGPU, PCIe 3.0 x8. Hyrule Field, dev.py ab --runs 3, interleaved A1 B1 A2 B2 A3 B3, 60 s a run, no fps cap, at c9a29ba7.

RTX 3060 Laptop (runs 1 / 2 / 3) Before: main @ ee9e1ed7 After: c9a29ba7
fps 72.8 / 72.3 / 72.8 72.6 / 72.3 / 72.6
1% low 55.5 / 50.5 / 53.6 fps 52.8 / 53.2 / 55.0 fps
median frame time 13.77 / 13.83 / 13.76 ms 13.83 / 13.86 / 13.89 ms
p99 frame time 18.01 / 19.80 / 18.65 ms 18.94 / 18.81 / 18.18 ms
probe at start none 75 ms (6.7 GB/s host to device, 6.6 back)

On this PC (RTX 5080, x16, Windows 11), the same build with the probe against RX_VK_PCIE_PROBE=0, one run each, gave 172.2 against 173.6 fps. The probe took 19 ms at start.

Risks

  • A driver could mishandle the probe's copies or timestamps at start. RX_VK_PCIE_PROBE=0 turns it off, and a revert is enough otherwise.
  • It costs 19 to 74 ms once at start on a discrete GPU, and 64 MB of memory that is freed right after.
  • On Windows it loads cfgmgr32 to read the OS's link. If that fails, the line says the OS's link was not read.
  • A player notices nothing after updating except the new log line. Saves, settings and caches are untouched.

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 (any failure that also fails on main is named). python -I -B tests/run_all.py --strict on Windows, on c9a29ba7: 688 passed, 160 failed, 51 skipped; on main @ ee9e1ed7: 687, 160, 51, the same 160 failing checks and none new (Windows ones: missing Linux tools, paths, file locking). Linux CI runs the lot.
  • Measured against main, or Measurements says why there is nothing to measure (three runs a side on the laptop, at c9a29ba7).
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • 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. Windows (this PC) and Linux (the laptop, CachyOS) both built and ran c9a29ba7.
  • 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.

🤖 Generated with Claude Code

## Summary When a player reports stutter or low fps, nothing in the log says what their GPU sits behind: a full x16 slot, a laptop's x8, a x4 slot, or an eGPU over Thunderbolt. Every submission sends the pages the CPU wrote to VRAM (the mirrors) and brings the GPU's writes back, and that traffic costs a lot more on a narrow link. This adds one line to the log at start, on a discrete GPU only. It gives the link speed measured each way and the link the OS says was negotiated, from the GPU up to its root port. The measurement is a 32 MB copy each way, best of 6 rounds, timed with GPU timestamps. The OS's link comes from sysfs on Linux and from the PCI bus driver's properties on Windows. Nothing else changes: the line only tells what the link is. ``` vk: pcie link: measured 26.8 GB/s host to device, 26.4 device to host (32 MB, best of 6 rounds, 19 ms); the OS's link over 1 hops: narrowest now 16 GT/s x16 (31.5 GB/s, the GPU), at most 32 GT/s x16 (63.0 GB/s, the GPU); the GPU's own now 16 GT/s x16 (31.5 GB/s, the GPU), at most 32 GT/s x16 (63.0 GB/s, the GPU) ``` `RX_VK_PCIE_PROBE=0` leaves the probe out, in case a driver mishandles it. The line then reads `vk: pcie link: not probed (RX_VK_PCIE_PROBE=0)`. A mode for slow links was built and measured on top of this probe, and it is not part of this PR. That mode made mirror syncs copy only the 256-byte blocks that changed since a page's last sync. It was correct: RX_VK_MEM_CHECK read every diffed page back on Windows and Linux, and 0 pages differed. It also sent 59 % fewer upload bytes. But it gained nothing on an x16 desktop and lost 3 % fps on a PCIe 3.0 x8 laptop, where the hashing cost more than the link saved. The probe stays because the log line is useful for diagnosing reports. The idea of a measured link probe comes from HeyListen (Sacrappy) and ProjectReLink. No code was taken from either; the code is Longshot's own. Read first: `gpu/vk/vk_pcie_link.cpp` `pcie_link_probe` (the probe and the line), then `gpu/vk/pcie_link.h` (the parsing rules, tested without a GPU). ## Testing **Tested:** - Windows 11, RTX 5080 at PCIe x16, ran `dev.py ab --env RX_VK_PCIE_PROBE=0 --runs 1` in Hyrule Field on c9a29ba7. With the switch unset, the log has the line above: 26.8 / 26.4 GB/s, measured in 19 ms. With `RX_VK_PCIE_PROBE=0`, the log says "not probed". Both runs played normally and the logs have no FATAL line. - CachyOS, RTX 3060 Laptop with its display wired straight to the dGPU (MUX), on 181ae977 (the same probe, which also set a policy flag removed since). The line read 6.7 GB/s host to device and 6.6 device to host, measured in 74 ms, and the OS's link was 8 GT/s x8 over 2 hops. The Linux code built and ran. - The same laptop at c9a29ba7: built on Linux, the line read 6.7 / 6.6 GB/s in 75 ms, and `dev.py ab --runs 3` in Hyrule Field against `main` @ ee9e1ed7 gave the same fps (Measurements). - Checks on c9a29ba7: `tests/test_pcie_link.py` (the parsing rules compiled and run on made-up values, plus the source: the probe after the device is made, the kill switch read before anything is measured, no slow-link switch left), `tests/test_switch_table.py`, `tests/test_device_policy.py`, `tests/test_recorder_sync.py` (source part: the probe's own command buffer is listed as direct). `run_all.py --changed origin/main` gives 116 passed, 3 failed, 14 skipped. The 3 that fail, test_tex_desc_memo, test_recorder_sync (runtime part) and test_prepare_stall, fail the same way on `main` ee9e1ed7 on this PC. **Still to test:** - An AMD GPU (Windows and Linux): start the game and read the `vk: pcie link:` line, expecting measured GB/s close to the link's and the OS's link read, with no crash or driver error at start (@Beanstalk run any scene on an AMD runner and post the vk: pcie link line) - An Intel Arc GPU (Windows): the same, expecting the same (@Beanstalk run any scene on an Intel Arc runner and post the vk: pcie link line) - A hybrid (Optimus) laptop with its display on the iGPU: start the game on the dGPU and read the line, expecting the dGPU's link measured, or "not measured" with a reason, and the game starting normally (by hand) ## Measurements **Verdict:** nothing measurable: the probe runs once at start (19 ms on x16, 75 ms on PCIe 3.0 x8) and nothing in a frame changes. Setup: an RTX 3060 Laptop on CachyOS with its display wired to the dGPU, PCIe 3.0 x8. Hyrule Field, `dev.py ab --runs 3`, interleaved A1 B1 A2 B2 A3 B3, 60 s a run, no fps cap, at c9a29ba7. | RTX 3060 Laptop (runs 1 / 2 / 3) | Before: main @ ee9e1ed7 | After: c9a29ba7 | |---|---|---| | fps | 72.8 / 72.3 / 72.8 | 72.6 / 72.3 / 72.6 | | 1% low | 55.5 / 50.5 / 53.6 fps | 52.8 / 53.2 / 55.0 fps | | median frame time | 13.77 / 13.83 / 13.76 ms | 13.83 / 13.86 / 13.89 ms | | p99 frame time | 18.01 / 19.80 / 18.65 ms | 18.94 / 18.81 / 18.18 ms | | probe at start | none | 75 ms (6.7 GB/s host to device, 6.6 back) | On this PC (RTX 5080, x16, Windows 11), the same build with the probe against `RX_VK_PCIE_PROBE=0`, one run each, gave 172.2 against 173.6 fps. The probe took 19 ms at start. ## Risks - A driver could mishandle the probe's copies or timestamps at start. `RX_VK_PCIE_PROBE=0` turns it off, and a revert is enough otherwise. - It costs 19 to 74 ms once at start on a discrete GPU, and 64 MB of memory that is freed right after. - On Windows it loads cfgmgr32 to read the OS's link. If that fails, the line says the OS's link was not read. - A player notices nothing after updating except the new log line. Saves, settings and caches are untouched. ## 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. - [ ] `mise run test` passes (any failure that also fails on `main` is named). `python -I -B tests/run_all.py --strict` on Windows, on c9a29ba7: 688 passed, 160 failed, 51 skipped; on `main` @ ee9e1ed7: 687, 160, 51, the same 160 failing checks and none new (Windows ones: missing Linux tools, paths, file locking). Linux CI runs the lot. - [ ] Measured against `main`, or Measurements says why there is nothing to measure (three runs a side on the laptop, at c9a29ba7). - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] 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. Windows (this PC) and Linux (the laptop, CachyOS) both built and ran c9a29ba7. - [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. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On a discrete GPU behind a narrow PCIe link (a laptop's x8, a x4 slot, an
eGPU) the per-frame traffic between guest memory and the VRAM mirrors (the
mirror syncs host to device, the write-backs device to host) costs much more
than on a x16 card. A mode that copies only the changed 256-byte blocks wins
there and loses on x16 (HeyListen's measurements, idea credited to Sacrappy;
no code taken), so it must follow the link. This is its first phase: know the
link.

Once the device is made, create_device calls pcie_link_probe
(vk_pcie_link.cpp): on a discrete GPU, 32 MB copied each way six times in one
command buffer between timestamps, the fastest round kept (a GPU at rest
raises its link speed only once it has work), about 20 ms; then the OS's
negotiated link by the device's PCI address (VK_EXT_pci_bus_info): Linux's
sysfs current_/max_link_speed and _width from the GPU up to its root port,
Windows' DEVPKEY_PciDevice_ link properties of the GPU's device node and its
parents (cfgmgr32 loaded at run time). One "vk: pcie link:" line says it all,
and dev.policy.slow_link is set: measured host to device under
RX_VK_SLOW_LINK_GBPS (9 GB/s), or forced by RX_VK_SLOW_LINK=1/0 for an A/B.
The policy block's "can and measured" line shows slow_link too. Nothing
reads it yet: behaviour is unchanged.

The rules (speed strings and codes, GB/s by line code, the narrowest hop,
the threshold, the force, the slow rule) are plain code in pcie_link.h,
run by tests/test_pcie_link.py. test_device_policy knows the new field;
test_recorder_sync lists the probe beside coopmat's as its own direct
submit before any replay.

Seen on an RTX 5080 (Windows): 26.8 GB/s host to device, 26.4 device to
host; the GPU's own link 16 GT/s x16 (at most 32 GT/s x16); slow: no.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
refactor(vk): keep the PCIe probe as a log line only, with a kill switch
Some checks failed
PR description / Title and description (pull_request_target) Successful in 8s
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
c9a29ba77f
The probe from the previous commit measures the link each way at start and
reads the OS's negotiated link, so a player's log says what the GPU sits
behind (a laptop's x8, a x4 slot, an eGPU). It also set a slow_link policy
flag, forced by RX_VK_SLOW_LINK and RX_VK_SLOW_LINK_GBPS, for a mode that was
to follow.

That mode (mirror syncs copying only the 256-byte blocks that changed since
a page's last sync) was built and measured, and it loses: 59% fewer upload
bytes and correct (RX_VK_MEM_CHECK read every diffed page back: 0 differed),
but +0 fps on an x16 desktop and -3% on an RTX 3060 Laptop at PCIe 3.0 x8
with its display wired to the dGPU, where the hashing costs more than the
link saves. It is left out, so the flag and both switches read nothing:
removed. The "vk: pcie link:" line keeps the measured GB/s each way and the
OS's link, without a slow verdict.

RX_VK_PCIE_PROBE=0 leaves the probe out, in case a driver mishandles it;
the line then says "not probed".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: yes, on Windows 11 (RTX 5080, PCIe x16) and CachyOS (RTX 3060 Laptop, PCIe 3.0 x8): the vk: pcie link line read in both logs, and RX_VK_PCIE_PROBE=0 skips the probe.

Tested in game: yes, on Windows 11 (RTX 5080, PCIe x16) and CachyOS (RTX 3060 Laptop, PCIe 3.0 x8): the vk: pcie link line read in both logs, and RX_VK_PCIE_PROBE=0 skips the probe.
neotoxic changed title from WIP: feat(vk): measure the PCIe link at start and log it to feat(vk): measure the PCIe link at start and log it 2026-12-04 09:00:55 +00:00
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merge main (e345b3cab) into perf/pcie-probe
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
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
92b13c0f7d
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Brought up to current main (e345b3ca) by a merge, nothing rewritten. Its tests ran in #3162, which carries this branch.

Brought up to current `main` (e345b3ca) by a merge, nothing rewritten. Its tests ran in #3162, which carries this branch.
Owner
@review
BeanBot left a comment

Recommendation: Request changes. The probe can submit an invalid command buffer after a recording failure, turning an optional diagnostic into a startup failure. Its default also needs the outstanding hardware runs before it is ready to merge.

Adds a discrete-GPU startup log with measured transfer rates and the OS-reported PCIe links. It helps diagnose slow-link reports, at the cost of a measured 19–75 ms startup probe and temporary allocations.

Blocking (1): must change before merging.

  1. L1 gpu/vk/vk_pcie_link.cpp:129: The probe ignores failures from beginning and ending its command buffer and proceeds to record and submit it. (more on the line) Do: Check both results, skip recording or submission on failure, report that the probe was not measured, and release the resources that are safe to destroy.

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

  • L2 gpu/vk/pcie_link.h:77: The first hop with readable data is treated as the GPU's own link even when the GPU's link was not readable. (more on the line) Do: Track the GPU entry independently of the count of readable hops, leaving its own link unknown when its attributes cannot be read. Add a case with an unreadable GPU and a readable parent.
  • L3 tests/test_pcie_link.py:107: The standalone test defaults to g++ and ignores CXX. (more on the line) Do: Use the configured CXX or the repository's compiler discovery for the default while retaining the explicit --cxx override.

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

  • L4 gpu/vk/vk_main.cpp:1109: The default-on probe has not been exercised on the affected AMD drivers. (more on the line) Do: Run the game on AMD discrete GPUs on Windows and Linux and record the probe line and whether startup succeeds without driver errors.
  • L5 gpu/vk/vk_main.cpp:1109: The probe has not been exercised on Intel Arc or on a hybrid laptop displaying through its iGPU. (more on the line) Do: Run on Windows Intel Arc and on a hybrid laptop with the game on the dGPU; record the line and confirm normal startup or an explained not-measured result.

@fix can do L1, L2 and L3.

Checks: Still running: 11 checks.

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

Does it help: Yes: the reported Windows and Linux NVIDIA runs produced plausible link readings. The laptop comparison showed no clear frame-rate change across three runs per side; the feature has not yet been verified on AMD, Intel Arc or a hybrid laptop.

Other systems: The probe submits Vulkan copies on the replay queue before gameplay, so discrete GPUs and their drivers on Windows and Linux are affected. Integrated GPUs, including the Steam Deck's GPU, skip it. AMD, Intel Arc and a display-on-iGPU hybrid setup remain untested; the reported NVIDIA runs do not establish their behavior.

Switches: RX_VK_PCIE_PROBE is added as a kill switch, on by default for discrete GPUs; 0 skips both measurement and OS lookup. The row is present in switches.def. The default works on the two reported NVIDIA systems but needs the outstanding hardware coverage.

Reviewed: 92b13c0f7d against e345b3cab4: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the relevant standards, the full new probe, parsing header and test, the changed lines in vk_main.cpp and test_recorder_sync.py, and the surrounding device creation and build source selection. Skimmed the remainder of the large existing vk_main.cpp and test_recorder_sync.py, the commit history, and the reported runs. docs/review-checklist.md and the adjacent Tooling checkout were absent. No generated files or translations changed.; nothing run (a code review).

Checked and fine:

  • The renderer build discovers the new .cpp file.
  • The probe is called after device and queue creation, and the switch is read before measurement.
  • The commits record AI assistance; no game-derived files or generated outputs appear in the diff.
  • The existing recorder source check accounts for the probe's direct command buffer.

Testing: Read-only review; no code or tests were run. The author reports in-game NVIDIA runs on Windows and Linux. CI was still running on this head.

Overlaps and merge order: #3162 is reported to carry this branch; its relationship and merge order could not be checked from the supplied information.


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

**Recommendation: Request changes.** The probe can submit an invalid command buffer after a recording failure, turning an optional diagnostic into a startup failure. Its default also needs the outstanding hardware runs before it is ready to merge. Adds a discrete-GPU startup log with measured transfer rates and the OS-reported PCIe links. It helps diagnose slow-link reports, at the cost of a measured 19–75 ms startup probe and temporary allocations. **Blocking (1)**: must change before merging. 1. **L1** `gpu/vk/vk_pcie_link.cpp:129`: The probe ignores failures from beginning and ending its command buffer and proceeds to record and submit it. (more on the line) **Do:** Check both results, skip recording or submission on failure, report that the probe was not measured, and release the resources that are safe to destroy. **Should fix (2)**: not blocking, but worth doing before merging. - **L2** `gpu/vk/pcie_link.h:77`: The first hop with readable data is treated as the GPU's own link even when the GPU's link was not readable. (more on the line) **Do:** Track the GPU entry independently of the count of readable hops, leaving its own link unknown when its attributes cannot be read. Add a case with an unreadable GPU and a readable parent. - **L3** `tests/test_pcie_link.py:107`: The standalone test defaults to g++ and ignores CXX. (more on the line) **Do:** Use the configured CXX or the repository's compiler discovery for the default while retaining the explicit --cxx override. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L4** `gpu/vk/vk_main.cpp:1109`: The default-on probe has not been exercised on the affected AMD drivers. (more on the line) **Do:** Run the game on AMD discrete GPUs on Windows and Linux and record the probe line and whether startup succeeds without driver errors. - **L5** `gpu/vk/vk_main.cpp:1109`: The probe has not been exercised on Intel Arc or on a hybrid laptop displaying through its iGPU. (more on the line) **Do:** Run on Windows Intel Arc and on a hybrid laptop with the game on the dGPU; record the line and confirm normal startup or an explained not-measured result. `@fix` can do L1, L2 and L3. **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the reported Windows and Linux NVIDIA runs produced plausible link readings. The laptop comparison showed no clear frame-rate change across three runs per side; the feature has not yet been verified on AMD, Intel Arc or a hybrid laptop. **Other systems:** The probe submits Vulkan copies on the replay queue before gameplay, so discrete GPUs and their drivers on Windows and Linux are affected. Integrated GPUs, including the Steam Deck's GPU, skip it. AMD, Intel Arc and a display-on-iGPU hybrid setup remain untested; the reported NVIDIA runs do not establish their behavior. **Switches:** RX_VK_PCIE_PROBE is added as a kill switch, on by default for discrete GPUs; 0 skips both measurement and OS lookup. The row is present in switches.def. The default works on the two reported NVIDIA systems but needs the outstanding hardware coverage. **Reviewed:** 92b13c0f7d45 against e345b3cab4ee: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the relevant standards, the full new probe, parsing header and test, the changed lines in vk_main.cpp and test_recorder_sync.py, and the surrounding device creation and build source selection. Skimmed the remainder of the large existing vk_main.cpp and test_recorder_sync.py, the commit history, and the reported runs. docs/review-checklist.md and the adjacent Tooling checkout were absent. No generated files or translations changed.; nothing run (a code review). **Checked and fine:** - The renderer build discovers the new .cpp file. - The probe is called after device and queue creation, and the switch is read before measurement. - The commits record AI assistance; no game-derived files or generated outputs appear in the diff. - The existing recorder source check accounts for the probe's direct command buffer. **Testing:** Read-only review; no code or tests were run. The author reports in-game NVIDIA runs on Windows and Linux. CI was still running on this head. **Overlaps and merge order:** #3162 is reported to carry this branch; its relationship and merge order could not be checked from the supplied information. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -0,0 +74,4 @@
const auto keep = [&](Hop& h, double gts, unsigned width) {
const double g = link_gbps(gts, width);
if (g > 0 && (!(h.gbps() > 0) || g < h.gbps())) {
h.gts = gts, h.width = width;
Member

L2 (should fix): The first hop with readable data is treated as the GPU's own link even when the GPU's link was not readable.

When: On Linux, if the GPU's sysfs link attributes are unavailable but its parent bridge exposes them, the GPU entry is skipped and the bridge becomes own_now and own_most. The log then labels the bridge's speed and width as the GPU's own.

Do: Track the GPU entry independently of the count of readable hops, leaving its own link unknown when its attributes cannot be read. Add a case with an unreadable GPU and a readable parent.

**L2** (should fix): The first hop with readable data is treated as the GPU's own link even when the GPU's link was not readable. *When:* On Linux, if the GPU's sysfs link attributes are unavailable but its parent bridge exposes them, the GPU entry is skipped and the bridge becomes own_now and own_most. The log then labels the bridge's speed and width as the GPU's own. **Do:** Track the GPU entry independently of the count of readable hops, leaving its own link unknown when its attributes cannot be read. Add a case with an unreadable GPU and a readable parent.
@ -1105,1 +1106,4 @@
gpu_clock_device_created(has_extension(exts, VK_EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME));
// (longshot: the PCIe link measured and read once, and logged: pcie_link.h; the PCI address from VK_EXT_pci_bus_info,
// which needs no enabling to be asked either)
pcie_link_probe(has_extension(exts, VK_EXT_PCI_BUS_INFO_EXTENSION_NAME));
Member

L4 (should fix): The default-on probe has not been exercised on the affected AMD drivers.

When: AMD discrete GPUs run the new allocation, transfer and timestamp path at startup on both Windows and Linux, but the supplied runs cover NVIDIA only.

Do: Run the game on AMD discrete GPUs on Windows and Linux and record the probe line and whether startup succeeds without driver errors.

**L4** (should fix): The default-on probe has not been exercised on the affected AMD drivers. *When:* AMD discrete GPUs run the new allocation, transfer and timestamp path at startup on both Windows and Linux, but the supplied runs cover NVIDIA only. **Do:** Run the game on AMD discrete GPUs on Windows and Linux and record the probe line and whether startup succeeds without driver errors.
Member

L5 (should fix): The probe has not been exercised on Intel Arc or on a hybrid laptop displaying through its iGPU.

When: Both setups can select a discrete GPU and execute this new path, but neither the measured rates nor the selected device's OS link has been checked there.

Do: Run on Windows Intel Arc and on a hybrid laptop with the game on the dGPU; record the line and confirm normal startup or an explained not-measured result.

**L5** (should fix): The probe has not been exercised on Intel Arc or on a hybrid laptop displaying through its iGPU. *When:* Both setups can select a discrete GPU and execute this new path, but neither the measured rates nor the selected device's OS link has been checked there. **Do:** Run on Windows Intel Arc and on a hybrid laptop with the game on the dGPU; record the line and confirm normal startup or an explained not-measured result.
@ -0,0 +126,4 @@
else {
VkCommandBufferBeginInfo cbb{VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO};
cbb.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
vkBeginCommandBuffer(cmd, &cbb);
Member

L1 (blocking): The probe ignores failures from beginning and ending its command buffer and proceeds to record and submit it.

When: If vkBeginCommandBuffer fails, for example under memory pressure, the following vkCmd calls target a command buffer that is not recording. If vkEndCommandBuffer fails, the code submits a buffer that is not executable; either path violates Vulkan requirements during game startup.

Do: Check both results, skip recording or submission on failure, report that the probe was not measured, and release the resources that are safe to destroy.

**L1** (blocking): The probe ignores failures from beginning and ending its command buffer and proceeds to record and submit it. *When:* If vkBeginCommandBuffer fails, for example under memory pressure, the following vkCmd calls target a command buffer that is not recording. If vkEndCommandBuffer fails, the code submits a buffer that is not executable; either path violates Vulkan requirements during game startup. **Do:** Check both results, skip recording or submission on failure, report that the probe was not measured, and release the resources that are safe to destroy.
@ -0,0 +104,4 @@
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--cxx", default="g++")
Member

L3 (should fix): The standalone test defaults to g++ and ignores CXX.

When: A Windows or Linux developer with CXX set to an installed clang++ but no g++ on PATH gets a compiler-not-found failure when running the documented test command, even though the configured compiler can run the test.

Do: Use the configured CXX or the repository's compiler discovery for the default while retaining the explicit --cxx override.

**L3** (should fix): The standalone test defaults to g++ and ignores CXX. *When:* A Windows or Linux developer with CXX set to an installed clang++ but no g++ on PATH gets a compiler-not-found failure when running the documented test command, even though the configured compiler can run the test. **Do:** Use the configured CXX or the repository's compiler discovery for the default while retaining the explicit --cxx override.
Owner
@fix
fix(vk): handle PCIe probe and link reporting failures
Some checks failed
PR description / Title and description (pull_request_target) Failing after 6s
CI / What the change needs (pull_request) Successful in 8s
CI / Third-party parts and guide screenshots (pull_request) Successful in 12s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 15s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m31s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 11m30s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 10m11s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 13m6s
CI / Website build and checks (pull_request) Failing after 36s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 13m32s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 44m0s
b616795bfb
As the review on #3161 asked.
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The probe reports useful link information and has worked on two NVIDIA systems, but the requested AMD, Intel Arc and hybrid-laptop runs remain outstanding. CI has also not yet run on this head. Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is b616795bfb. I merged main (921e6cbea8) into it, as it has merge commits. I edited its description to match the change.

Changed

  • Command buffer failures in gpu/vk/vk_pcie_link.cpp:129: Check begin and end results, report the failure, and release resources without recording or submitting an invalid buffer.
  • GPU link identity in gpu/vk/pcie_link.h:69: Track the first entry independently of readable hops and add a case for an unreadable GPU with a readable parent in tests/test_pcie_link.py:69.
  • Compiler selection in tests/test_pcie_link.py:115: Use CXX as the default when set, while retaining the --cxx override.

Nothing was built or run: the checks run again on the new head.

The change adds a startup log line measuring discrete-GPU transfer bandwidth and reporting the OS PCIe link. It adds a short startup cost and temporary buffers, with no intended per-frame work.

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

  • L4 gpu/vk/vk_main.cpp:1109: The default-on probe has not been exercised on the affected AMD drivers. When: AMD discrete GPUs run the new allocation, transfer and timestamp path at startup on both Windows and Linux, but the supplied runs cover NVIDIA only. Do: Run the game on AMD discrete GPUs on Windows and Linux and record the probe line and whether startup succeeds without driver errors.
  • L5 gpu/vk/vk_main.cpp:1109: The probe has not been exercised on Intel Arc or on a hybrid laptop displaying through its iGPU. When: Both setups can select a discrete GPU and execute this new path, but neither the measured rates nor the selected device's OS link has been checked there. Do: Run on Windows Intel Arc and on a hybrid laptop with the game on the dGPU; record the line and confirm normal startup or an explained not-measured result.

Checks: they run again on this head; a failure shows on the pull request.

Also noticed (1; not asked for, not blocking)
  • The reported measurements and builds predate the command-buffer and link-reporting fixes.
More: does it help, other systems, switches, what was read

Does it help: Yes for the diagnostic feature on the reported NVIDIA systems: the Windows RTX 5080 reported 26.8/26.4 GB/s in 19 ms, and the Linux RTX 3060 laptop reported 6.7/6.6 GB/s in 75 ms. The laptop's three interleaved runs per side showed no clear frame-rate change; the hardware coverage is incomplete.

Other systems: The probe runs on discrete GPUs on Windows and Linux. AMD drivers on both systems, Windows Intel Arc, and a hybrid laptop displaying through its integrated GPU still need the recorded startup checks.

Switches: RX_VK_PCIE_PROBE is added, default 1; setting it to 0 skips the probe. The default works on the reported NVIDIA systems, but its coverage on the other affected drivers remains unverified.

Reviewed: b616795bfb against 921e6cbea8: Read the fix diff, PCIe probe, parsing rules and PCIe test; inspected the repository rules and pull request template. The broader base diff includes merged changes beyond the listed PCIe files; those files and their surrounding code were not all read in full.; nothing run (a code review).

Checked and fine:

  • The command-buffer begin and end failures avoid recording or submitting an invalid buffer and reach resource cleanup.
  • An unreadable GPU entry no longer assigns a readable parent's link to the GPU's own link.
  • The PCIe test uses CXX when set and retains the --cxx override.
  • The fix retains the startup probe and its log line.

Testing: No commands from the project were run. The author reports successful NVIDIA game runs on Windows and Linux; CI has not run on this head.

Overlaps and merge order: The author says #3162 carries this branch; its merge order was not established.


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

**Recommendation: Approve.** The code is ready: only testing is left. The probe reports useful link information and has worked on two NVIDIA systems, but the requested AMD, Intel Arc and hybrid-laptop runs remain outstanding. CI has also not yet run on this head. Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is b616795bfba3. I merged `main` (921e6cbea831) into it, as it has merge commits. I edited its description to match the change. **Changed** - **Command buffer failures in gpu/vk/vk_pcie_link.cpp:129**: Check begin and end results, report the failure, and release resources without recording or submitting an invalid buffer. - **GPU link identity in gpu/vk/pcie_link.h:69**: Track the first entry independently of readable hops and add a case for an unreadable GPU with a readable parent in tests/test_pcie_link.py:69. - **Compiler selection in tests/test_pcie_link.py:115**: Use CXX as the default when set, while retaining the --cxx override. Nothing was built or run: the checks run again on the new head. The change adds a startup log line measuring discrete-GPU transfer bandwidth and reporting the OS PCIe link. It adds a short startup cost and temporary buffers, with no intended per-frame work. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L4** `gpu/vk/vk_main.cpp:1109`: The default-on probe has not been exercised on the affected AMD drivers. *When:* AMD discrete GPUs run the new allocation, transfer and timestamp path at startup on both Windows and Linux, but the supplied runs cover NVIDIA only. **Do:** Run the game on AMD discrete GPUs on Windows and Linux and record the probe line and whether startup succeeds without driver errors. - **L5** `gpu/vk/vk_main.cpp:1109`: The probe has not been exercised on Intel Arc or on a hybrid laptop displaying through its iGPU. *When:* Both setups can select a discrete GPU and execute this new path, but neither the measured rates nor the selected device's OS link has been checked there. **Do:** Run on Windows Intel Arc and on a hybrid laptop with the game on the dGPU; record the line and confirm normal startup or an explained not-measured result. **Checks:** they run again on this head; a failure shows on the pull request. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The reported measurements and builds predate the command-buffer and link-reporting fixes. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for the diagnostic feature on the reported NVIDIA systems: the Windows RTX 5080 reported 26.8/26.4 GB/s in 19 ms, and the Linux RTX 3060 laptop reported 6.7/6.6 GB/s in 75 ms. The laptop's three interleaved runs per side showed no clear frame-rate change; the hardware coverage is incomplete. **Other systems:** The probe runs on discrete GPUs on Windows and Linux. AMD drivers on both systems, Windows Intel Arc, and a hybrid laptop displaying through its integrated GPU still need the recorded startup checks. **Switches:** RX_VK_PCIE_PROBE is added, default 1; setting it to 0 skips the probe. The default works on the reported NVIDIA systems, but its coverage on the other affected drivers remains unverified. **Reviewed:** b616795bfba3 against 921e6cbea831: Read the fix diff, PCIe probe, parsing rules and PCIe test; inspected the repository rules and pull request template. The broader base diff includes merged changes beyond the listed PCIe files; those files and their surrounding code were not all read in full.; nothing run (a code review). **Checked and fine:** - The command-buffer begin and end failures avoid recording or submitting an invalid buffer and reach resource cleanup. - An unreadable GPU entry no longer assigns a readable parent's link to the GPU's own link. - The PCIe test uses CXX when set and retains the --cxx override. - The fix retains the startup probe and its log line. **Testing:** No commands from the project were run. The author reports successful NVIDIA game runs on Windows and Linux; CI has not run on this head. **Overlaps and merge order:** The author says #3162 carries this branch; its merge order was not established. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch perf/pcie-probe 2026-12-04 18:23:03 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!3161
No description provided.