pull: the card's copies only where the processor reads its memory slowly #173

Closed
github-bot wants to merge 1 commit from github-bot/gh-173 into main AGit
Owner

@⁠EdouardSence on GitHub · 2026-12-02 09:06 UTC · original
EdouardSence:pull-auto-fast-bar → main · +38 −6 · 4 files · 1 commits · closed without merging

Follow-up to #93: the card-side reads are turned on only where the CPU reads the card's memory slowly.

Why

#93's GPU copies fix the slow-readback case: CPU reads through the BAR at ~100 MB/s (RX 7900 XTX + i7-13700K; the 9060 XT + 14600KF report in #93 shows the same gain). On systems where the CPU reads the card's memory at bus-like speed, they cost more than they save. Reports in #93 from an RX 7800 XT + 5800X3D and an RX 9070 XT + 7950X3D say the same.

On my RX 9070 XT + Ryzen 7 7800X3D with resizable BAR, um::calibrate_reads already measures this at startup:

unified memory: the CPU reads the card's memory by streaming loads rep_movsb_mb_s=143 streaming_mb_s=2409

That is about 25x the 7900 XTX figure in pull.rs.

Change

  • calibrate_reads stores the faster of its two speeds in pull::CARD_READ_MB_S.
  • pull::on():
    • VICTORY_CARD_PULL=0: never use the copies, as before.
    • =1: always use them.
    • Unset: use them only when the measured speed is under 1000 MB/s, or when nothing was measured. That keeps #93's behaviour on slow-BAR systems and without a BAR.
  • The choice is logged once: title memory on the card is read by ....
  • README and run.conf.default describe the three states.

Measured

RX 9070 XT 16 GB, Ryzen 7 7800X3D, 32 GB, CachyOS 7.3.5, Proton-CachyOS, setup.sh's Mesa 26.3.1. Diag builds, Series X, 1706x960 -> 2560x1440, RT on. Each run restored the same frozen save first and was 6 minutes long with scripted input. Screenshots confirm the same place in all three.

Per-frame numbers. Every frame time was logged by a one-line local probe in the panel's frame-time push, which is not part of this PR. About 7,500 frames in the world per run. The lows are computed the way the panel computes its "1% low" (99th-percentile frame time):

37bb30f d044248 (main, with #93) this branch
reads by CPU card copies CPU (picked automatically)
mean copy_ms 2.2 10.9 2.0
avg fps 30.8 30.0 31.3
median fps 30.9 30.9 32.4
1% low 16.0 17.2 17.1
0.1% low 8.4 11.8 12.9
frames over 50 ms 189 394 138
frames over 100 ms 11 4 2
worst frame 1358 ms 194 ms 220 ms

Against current main, the copy time goes back to the CPU's ~2 ms and the frames over 50 ms drop by about two thirds (394 to 138). The 1% low stays the same, and the 0.1% low is a little better. The averages are within run-to-run noise. A first round of 5-second samples gave the same copy_ms pattern (2.5 / 14.2 / 2.0).

Note on the per-frame table: the title spawns the player at a slightly different spot of the same checkpoint on each load (the deck, the house seen from outside, by the railing). These three runs did not all start at the same spot, so take the fps and lows columns with that in mind. The copy_ms gap (about 11 vs 2 ms) is the same in every run I made, including the 5-second-sample round, whose screenshots show the same spot in all three.

The 1000 MB/s threshold sits between the two measured groups: ~100 MB/s where the copies help and ~2,300 MB/s where they hurt. Anyone with a card in between can force either way with VICTORY_CARD_PULL=0/1.

Builds clean with PROFILE=diag ./build.sh. Not run: the #[ignore] card tests.

**@⁠EdouardSence** on GitHub · 2026-12-02 09:06 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/173) `EdouardSence:pull-auto-fast-bar` → `main` · +38 −6 · 4 files · 1 commits · closed without merging Follow-up to #93: the card-side reads are turned on only where the CPU reads the card's memory slowly. ## Why #93's GPU copies fix the slow-readback case: CPU reads through the BAR at ~100 MB/s (RX 7900 XTX + i7-13700K; the 9060 XT + 14600KF report in #93 shows the same gain). On systems where the CPU reads the card's memory at bus-like speed, they cost more than they save. Reports in #93 from an RX 7800 XT + 5800X3D and an RX 9070 XT + 7950X3D say the same. On my RX 9070 XT + Ryzen 7 7800X3D with resizable BAR, `um::calibrate_reads` already measures this at startup: ``` unified memory: the CPU reads the card's memory by streaming loads rep_movsb_mb_s=143 streaming_mb_s=2409 ``` That is about 25x the 7900 XTX figure in `pull.rs`. ## Change - `calibrate_reads` stores the faster of its two speeds in `pull::CARD_READ_MB_S`. - `pull::on()`: - `VICTORY_CARD_PULL=0`: never use the copies, as before. - `=1`: always use them. - Unset: use them only when the measured speed is under 1000 MB/s, or when nothing was measured. That keeps #93's behaviour on slow-BAR systems and without a BAR. - The choice is logged once: `title memory on the card is read by ...`. - README and `run.conf.default` describe the three states. ## Measured RX 9070 XT 16 GB, Ryzen 7 7800X3D, 32 GB, CachyOS 7.3.5, Proton-CachyOS, `setup.sh`'s Mesa 26.3.1. Diag builds, Series X, 1706x960 -> 2560x1440, RT on. Each run restored the same frozen save first and was 6 minutes long with scripted input. Screenshots confirm the same place in all three. **Per-frame numbers.** Every frame time was logged by a one-line local probe in the panel's frame-time push, which is not part of this PR. About 7,500 frames in the world per run. The lows are computed the way the panel computes its "1% low" (99th-percentile frame time): | | `37bb30f` | `d044248` (main, with #93) | this branch | |---|---|---|---| | reads by | CPU | card copies | CPU (picked automatically) | | mean `copy_ms` | 2.2 | **10.9** | **2.0** | | avg fps | 30.8 | 30.0 | 31.3 | | median fps | 30.9 | 30.9 | 32.4 | | 1% low | 16.0 | 17.2 | 17.1 | | 0.1% low | 8.4 | 11.8 | 12.9 | | frames over 50 ms | 189 | **394** | **138** | | frames over 100 ms | 11 | 4 | 2 | | worst frame | 1358 ms | 194 ms | 220 ms | Against current main, the copy time goes back to the CPU's ~2 ms and the frames over 50 ms drop by about two thirds (394 to 138). The 1% low stays the same, and the 0.1% low is a little better. The averages are within run-to-run noise. A first round of 5-second samples gave the same `copy_ms` pattern (2.5 / 14.2 / 2.0). Note on the per-frame table: the title spawns the player at a slightly different spot of the same checkpoint on each load (the deck, the house seen from outside, by the railing). These three runs did not all start at the same spot, so take the fps and lows columns with that in mind. The `copy_ms` gap (about 11 vs 2 ms) is the same in every run I made, including the 5-second-sample round, whose screenshots show the same spot in all three. The 1000 MB/s threshold sits between the two measured groups: ~100 MB/s where the copies help and ~2,300 MB/s where they hurt. Anyone with a card in between can force either way with `VICTORY_CARD_PULL=0/1`. Builds clean with `PROFILE=diag ./build.sh`. Not run: the `#[ignore]` card tests.
The card-side reads of #93 help where the processor reads the card's
memory through the BAR at ~100 MB/s (RX 7900 XTX + i7-13700K). Where it
reads it at bus-like speed they cost more than they save: on an RX 9070 XT
with a Ryzen 7 7800X3D and resizable BAR, um's calibrate_reads measures
streaming loads at 2,266-2,409 MB/s, and copy_ms went from 2.0 to 14.2 a
frame with the card's copies (same save and place, 6 minutes each).

calibrate_reads now keeps the faster of its two speeds in
pull::CARD_READ_MB_S. Unset, VICTORY_CARD_PULL turns the card's copies on
only below 1000 MB/s (or when nothing was measured, as before); 0 is never,
1 is always. The choice is logged once.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 09:10:43 +00:00
Author
Owner

@⁠DecayingEagle on GitHub · 2026-12-02 11:15 UTC · original

Additional RX 7900 XT / Ryzen 9 9900X / 32 GB Linux result on d044248 (Wine 11.22, private Mesa 26.3.1 RADV, diag build): the automatic choice correctly selects CPU reads after calibrating streaming reads at 3,437 MB/s (read_mb_s=3436).

Matched frozen-save balcony scene, Series X, 2560×1440 render and output, FSR 4 Native AA, RT/FG off, pages off. Each run used its own copy of the same frozen save. Screenshots confirm the same view during the 90-second measurement after 60 seconds of settling. Medians of 18 five-second stats: frame intervals (not per-frame percentile measurements):

Main GPU-copy path Auto CPU path
FPS 29.11 29.06
copy_ms 20.69 0.67
preparing_ms 22.48 2.73
gpu_wait_ms 5.67 20.30
draws/frame 5,893 5,973

This confirms a large CPU preparation saving, with no FPS gain in this GPU-limited native-1440p scene. The candidate also included #163 and #164, so this is a combined-build check rather than a claim that the entire difference belongs to this PR alone. Both runs included the same Native AA patch, now #178.

The candidate then completed a 20-minute monitored session containing balcony/ground traversal, menus and virtual-controller reconnection. No runtime exception, device loss, kernel GPU reset/timeout, or 60-second frame-stat stall was recorded; physical VRAM peaked at 18,396 MiB. It did not reach vehicle driving, so this is not a driving-stress result. Settings-label overlap remains, and the missing-terrain/void issue was not reproduced on this limited route.

AI assistance: Codex ran the tests, inspected screenshots/logs and wrote this report on the hardware above.

**@⁠DecayingEagle** on GitHub · 2026-12-02 11:15 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/173#issuecomment-7343645328) Additional RX 7900 XT / Ryzen 9 9900X / 32 GB Linux result on `d044248` (Wine 11.22, private Mesa 26.3.1 RADV, diag build): the automatic choice correctly selects CPU reads after calibrating streaming reads at 3,437 MB/s (`read_mb_s=3436`). Matched frozen-save balcony scene, Series X, 2560×1440 render and output, FSR 4 Native AA, RT/FG off, pages off. Each run used its own copy of the same frozen save. Screenshots confirm the same view during the 90-second measurement after 60 seconds of settling. Medians of 18 five-second `stats: frame` intervals (not per-frame percentile measurements): | | Main GPU-copy path | Auto CPU path | |---|---:|---:| | FPS | 29.11 | 29.06 | | copy_ms | 20.69 | 0.67 | | preparing_ms | 22.48 | 2.73 | | gpu_wait_ms | 5.67 | 20.30 | | draws/frame | 5,893 | 5,973 | This confirms a large CPU preparation saving, with **no FPS gain in this GPU-limited native-1440p scene**. The candidate also included #163 and #164, so this is a combined-build check rather than a claim that the entire difference belongs to this PR alone. Both runs included the same Native AA patch, now #178. The candidate then completed a 20-minute monitored session containing balcony/ground traversal, menus and virtual-controller reconnection. No runtime exception, device loss, kernel GPU reset/timeout, or 60-second frame-stat stall was recorded; physical VRAM peaked at 18,396 MiB. It did not reach vehicle driving, so this is not a driving-stress result. Settings-label overlap remains, and the missing-terrain/void issue was not reproduced on this limited route. AI assistance: Codex ran the tests, inspected screenshots/logs and wrote this report on the hardware above.
Author
Owner

@⁠GreemSC on GitHub · 2026-12-02 11:21 UTC · original

A data point for the threshold, from the slow side: RX 7900 XT 20 GB (RDNA 3) + i7-12700K, resizable BAR on, 24 GB RAM, CachyOS kernel 7.3.6, d044248.

  • um::calibrate_reads under Wine: rep_movsb_mb_s=51 streaming_mb_s=2 (same in every run).
  • A native Vulkan test outside Wine and outside the game (allocate DEVICE_LOCAL|HOST_VISIBLE, map, read 8 MB with rep movsb and with movntdqa lines, 1 and 4 threads): 65 MB/s rep movsb, 35 MB/s streaming; the same code reads GTT write-combined memory at 7–18 GB/s. The VRAM mapping is already write-combining in the PAT, so this is the platform, not the mapping.

So the same card reads its BAR at ~3.4 GB/s on a Ryzen 9 9900X (@⁠DecayingEagle above) and at ~0.05 GB/s on this Intel 12th-gen desktop: the auto choice really has to be measured per machine, as this PR does, and it should keep the card's copies here. With #163 + #164 + #166 on top of d044248, copy_ms already falls from 15.0 to 0.8 ms with the pull still on (details in #163).

AI assistance: Claude Code (Claude Opus 5.5) wrote and ran the test and this report on the hardware above.

**@⁠GreemSC** on GitHub · 2026-12-02 11:21 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/173#issuecomment-7343818142) A data point for the threshold, from the slow side: RX 7900 XT 20 GB (RDNA 3) + **i7-12700K**, resizable BAR on, 24 GB RAM, CachyOS kernel 7.3.6, `d044248`. - `um::calibrate_reads` under Wine: `rep_movsb_mb_s=51 streaming_mb_s=2` (same in every run). - A native Vulkan test outside Wine and outside the game (allocate `DEVICE_LOCAL|HOST_VISIBLE`, map, read 8 MB with `rep movsb` and with `movntdqa` lines, 1 and 4 threads): **65 MB/s rep movsb, 35 MB/s streaming**; the same code reads GTT write-combined memory at 7–18 GB/s. The VRAM mapping is already write-combining in the PAT, so this is the platform, not the mapping. So the same card reads its BAR at ~3.4 GB/s on a Ryzen 9 9900X (@⁠DecayingEagle above) and at ~0.05 GB/s on this Intel 12th-gen desktop: the auto choice really has to be measured per machine, as this PR does, and it should keep the card's copies here. With #163 + #164 + #166 on top of `d044248`, `copy_ms` already falls from 15.0 to 0.8 ms with the pull still on (details in #163). AI assistance: Claude Code (Claude Opus 5.5) wrote and ran the test and this report on the hardware above.
Author
Owner

@⁠TreXito on GitHub · 2026-12-02 13:04 UTC · original

A data point from the slow side, on the same GPU class as the 7800 XT report in #93: RX 7800 XT 16 GB (RDNA 3) + i5-13600KF, 32 GB, Nobara kernel 7.3.4, Mesa 26.3.1 RADV from setup.sh, run.sh's default RADV_PERFTEST=nosam, diag build of current main. The GPU link runs at PCIe 4.0 x8 here.

um::calibrate_reads: rep_movsb_mb_s=102-106 streaming_mb_s=35-85 (two play sessions), so the automatic choice in this PR keeps the card's copies on. That matches what I measured:

Headless gamescope 2560x1440, scripted new-game intro, 300 s, ~7,000 frames in the world per run, VICTORY_PAGES=0, alternating runs:

avg fps 1% low
copies on (default), run 1 32.6 13.9
copies on (default), run 2 33.4 14.9
VICTORY_CARD_PULL=0, run 1 33.1 12.3
VICTORY_CARD_PULL=0, run 2 33.6 13.4

Only 2 runs a side, so treat the average as flat; the lows were lower in both CPU-read runs.

A local counter around copy_mapped (not part of anything I'd PR) showed why the average does not move: with the copies on, the card-sourced reads (about 1-4 a frame, 4-64 KiB, ~0.1 MB a frame) cost 10-16 ms a frame of waiting on the copy queue's fence, and in heavy frames (~4,100 draws) preparing_ms was ~21 ms with gpu_wait_ms ~3.6. With VICTORY_CARD_PULL=0 those reads dropped to ~1.5 ms a frame and preparing_ms to ~7 ms, but gpu_wait_ms rose to ~11.5 and the frame stayed at ~39 ms: those frames are GPU-bound here, so the wait is hidden, while the BAR reads seem to cost the GPU side something.

So a measured threshold looks right to me rather than a per-GPU rule: the same GPU family lands on both sides depending on the platform.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WNCfbX5dPKJzSkgbf16GX4

**@⁠TreXito** on GitHub · 2026-12-02 13:04 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/173#issuecomment-7346322210) A data point from the slow side, on the same GPU class as the 7800 XT report in #93: **RX 7800 XT 16 GB (RDNA 3) + i5-13600KF**, 32 GB, Nobara kernel 7.3.4, Mesa 26.3.1 RADV from `setup.sh`, `run.sh`'s default `RADV_PERFTEST=nosam`, diag build of current main. The GPU link runs at PCIe 4.0 x8 here. `um::calibrate_reads`: `rep_movsb_mb_s=102-106 streaming_mb_s=35-85` (two play sessions), so the automatic choice in this PR keeps the card's copies on. That matches what I measured: Headless gamescope 2560x1440, scripted new-game intro, 300 s, ~7,000 frames in the world per run, `VICTORY_PAGES=0`, alternating runs: | | avg fps | 1% low | |---|---|---| | copies on (default), run 1 | 32.6 | 13.9 | | copies on (default), run 2 | 33.4 | 14.9 | | `VICTORY_CARD_PULL=0`, run 1 | 33.1 | 12.3 | | `VICTORY_CARD_PULL=0`, run 2 | 33.6 | 13.4 | Only 2 runs a side, so treat the average as flat; the lows were lower in both CPU-read runs. A local counter around `copy_mapped` (not part of anything I'd PR) showed why the average does not move: with the copies on, the card-sourced reads (about 1-4 a frame, 4-64 KiB, ~0.1 MB a frame) cost 10-16 ms a frame of waiting on the copy queue's fence, and in heavy frames (~4,100 draws) `preparing_ms` was ~21 ms with `gpu_wait_ms` ~3.6. With `VICTORY_CARD_PULL=0` those reads dropped to ~1.5 ms a frame and `preparing_ms` to ~7 ms, but `gpu_wait_ms` rose to ~11.5 and the frame stayed at ~39 ms: those frames are GPU-bound here, so the wait is hidden, while the BAR reads seem to cost the GPU side something. So a measured threshold looks right to me rather than a per-GPU rule: the same GPU family lands on both sides depending on the platform. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WNCfbX5dPKJzSkgbf16GX4
Author
Owner

@⁠Flamware on GitHub · 2026-12-02 16:41 UTC · original

An RDNA 2 data point for the threshold, from the fast side: RX 6950 XT 16 GB (RDNA 2) + Ryzen 5 7600X, 32 GB, PCIe 4.0 x16 (16 GT/s, checked in sysfs), resizable BAR on (16 GB BAR 0). Bazzite, kernel 7.3.5, system Wine 11.22 with the patched wineserver, Mesa 26.3.1 + mesa.patch.

um::calibrate_reads over 76 game starts (Dec 1–2, several builds):

min median max
rep_movsb_mb_s 48 165 201
streaming_mb_s 1,574 2,293 2,492

So the faster of the two is always well above 1 GB/s here, and this PR picks CPU reads. That matches what I have been running by hand since #93: VICTORY_CARD_PULL=0 for every session on this machine, including ~30 min on d044248 + this PR + #165 today with no hitch I could tie to readback. I have no matched A/B fps run yet, so this is only a calibration data point, not a measured gain.

Data gathered with Claude Code from my own run logs; the runs are real.

**@⁠Flamware** on GitHub · 2026-12-02 16:41 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/173#issuecomment-7352328567) An RDNA 2 data point for the threshold, from the fast side: **RX 6950 XT 16 GB (RDNA 2) + Ryzen 5 7600X**, 32 GB, PCIe 4.0 x16 (16 GT/s, checked in sysfs), resizable BAR on (16 GB BAR 0). Bazzite, kernel 7.3.5, system Wine 11.22 with the patched wineserver, Mesa 26.3.1 + `mesa.patch`. `um::calibrate_reads` over 76 game starts (Dec 1–2, several builds): | | min | median | max | |---|---:|---:|---:| | `rep_movsb_mb_s` | 48 | 165 | 201 | | `streaming_mb_s` | 1,574 | 2,293 | 2,492 | So the faster of the two is always well above 1 GB/s here, and this PR picks CPU reads. That matches what I have been running by hand since #93: `VICTORY_CARD_PULL=0` for every session on this machine, including ~30 min on `d044248` + this PR + #165 today with no hitch I could tie to readback. I have no matched A/B fps run yet, so this is only a calibration data point, not a measured gain. Data gathered with Claude Code from my own run logs; the runs are real.
github-bot closed this pull request 2026-12-02 19:22:13 +00:00
Author
Owner

@⁠goldfishdev on GitHub · 2026-12-02 19:15 UTC · original

superseded by #215

**@⁠goldfishdev** on GitHub · 2026-12-02 19:15 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/173#issuecomment-7355861977) superseded by #215

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.