texture queue: due slots from an index, not a walk of every slot #295

Manually merged
github merged 1 commit from github-bot/gh-295 into main 2026-12-03 16:31:13 +00:00 AGit
Owner

@⁠TreXito on GitHub · 2026-12-03 06:29 UTC · original
TreXito:texture-queue-due-index → main · +132 −27 · 1 files · 1 commits · merged 2026-12-03 16:26 UTC

What

TextureQueue::scan walked every slot of the queue each frame to find the due ones and to count the census (#188). The slots are a BTreeMap, and a standing scene keeps tens of thousands of them waiting, so the walk is pointer chasing over the whole map, under the queue lock, in the per-frame index pass that runs inline on whichever title thread binds first.

Measured here (RDNA3, release build, standing at the house of the first save, timed with the CPU's cycle counter in a local profiling build):

per frame
whole index pass (heap_textures) 5.7 ms
of it, scan 1.9 ms
slots in the queue ~27,000
slots due ~150

Change

  • TextureQueue keeps by_due, an ordered set of (due frame, slot) for every slot it holds, and kinds, the census counts (in part / recheck / away), updated where slots come and go or change: insert, take_out, edit_wait. same hands out &Waiting now, so nothing else edits a slot.
  • scan takes the due slots from the front of by_due and reads the counts. The due lists are put in slot order, as the walk gave them, so the result is the same (and in_order sorts by write anyway).
  • Waiting::kind names the census classes once, for both.

Tested

  • New the_due_index_matches_a_walk_of_every_slot: 4,000 frames of random writes, looks, holds, wakes, partial uploads, rechecks, changes and removals over 300 slots; after every frame scan must equal a walk of every slot (the old code), and the index must hold exactly the slots.
  • descriptor:: tests under Wine: 39 pass (38 before, plus the new one). views_die_with_their_resource aborts the test process here with or without this change, so it was skipped on both.
  • In game, same scene, release build with the change on top (profiling build): scan 1.9 ms → 1.5 µs a frame; the whole index pass 6.5 ms → 3.0 to 4.6 ms (per 20 s window).
  • Frame rate, same scene, release, alternating 5 minute runs: 25.8 / 25.5 fps before, 26.2 / 25.4 after. No change beyond noise here: in this scene the pass is not what the frame waits for. What it buys is 1.9 ms less CPU a frame on a title thread and that much less time holding the queue lock, which draws writing views also take.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WNCfbX5dPKJzSkgbf16GX4

**@⁠TreXito** on GitHub · 2026-12-03 06:29 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/295) `TreXito:texture-queue-due-index` → `main` · +132 −27 · 1 files · 1 commits · merged 2026-12-03 16:26 UTC ## What `TextureQueue::scan` walked every slot of the queue each frame to find the due ones and to count the census (#188). The slots are a `BTreeMap`, and a standing scene keeps tens of thousands of them waiting, so the walk is pointer chasing over the whole map, under the queue lock, in the per-frame index pass that runs inline on whichever title thread binds first. Measured here (RDNA3, release build, standing at the house of the first save, timed with the CPU's cycle counter in a local profiling build): | | per frame | |---|---| | whole index pass (`heap_textures`) | 5.7 ms | | of it, `scan` | 1.9 ms | | slots in the queue | ~27,000 | | slots due | ~150 | ## Change - `TextureQueue` keeps `by_due`, an ordered set of `(due frame, slot)` for every slot it holds, and `kinds`, the census counts (in part / recheck / away), updated where slots come and go or change: `insert`, `take_out`, `edit_wait`. `same` hands out `&Waiting` now, so nothing else edits a slot. - `scan` takes the due slots from the front of `by_due` and reads the counts. The due lists are put in slot order, as the walk gave them, so the result is the same (and `in_order` sorts by write anyway). - `Waiting::kind` names the census classes once, for both. ## Tested - New `the_due_index_matches_a_walk_of_every_slot`: 4,000 frames of random writes, looks, holds, wakes, partial uploads, rechecks, changes and removals over 300 slots; after every frame `scan` must equal a walk of every slot (the old code), and the index must hold exactly the slots. - `descriptor::` tests under Wine: 39 pass (38 before, plus the new one). `views_die_with_their_resource` aborts the test process here with or without this change, so it was skipped on both. - In game, same scene, release build with the change on top (profiling build): `scan` 1.9 ms → 1.5 µs a frame; the whole index pass 6.5 ms → 3.0 to 4.6 ms (per 20 s window). - Frame rate, same scene, release, alternating 5 minute runs: 25.8 / 25.5 fps before, 26.2 / 25.4 after. No change beyond noise here: in this scene the pass is not what the frame waits for. What it buys is 1.9 ms less CPU a frame on a title thread and that much less time holding the queue lock, which draws writing views also take. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WNCfbX5dPKJzSkgbf16GX4
TextureQueue::scan walked the whole BTreeMap of waiting slots each frame,
under the queue lock, inline in the index pass: 1.9 ms a frame with some
27,000 slots waiting and 150 due (standing scene, release build).

The queue now keeps every slot in an ordered set by its due frame and
counts the census classes as slots come, go and change (insert, take_out,
edit_wait), so scan reads the due front only: 1.5 us a frame. The result
is unchanged; a randomized test checks it against a walk of every slot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNCfbX5dPKJzSkgbf16GX4
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 06:32:42 +00:00
Author
Owner

@⁠EdouardSence on GitHub · 2026-12-03 11:46 UTC · original

In-game A/B on RDNA 4: RX 9070 XT 16 GB + Ryzen 7 7800X3D, 32 GB, CachyOS kernel 7.3.5, Proton-CachyOS, Mesa 26.3.1 + mesa.patch from setup.sh, resizable BAR on. Release builds of 842767a (main) and 842767a + this PR (00e353f), identical except for a one-line per-frame frame-time log in panel.rs and the scripted keys ungated for release.

Defaults (Series X profile, RT on, no frame cap), same frozen save restored before every run, warm pipeline cache, alternating runs of 6 min, stats per frame over the time in the world after the first 45 s (~6,200-6,700 frames each):

avg fps 1% low 0.1% low frames > 50 ms
main, run 2 30.0 16.1 10.9 142
main, run 4 30.3 16.5 11.3 152
main, run 6 30.4 17.1 12.3 128
this PR, run 1 29.2 16.2 9.6 137
this PR, run 3 30.2 16.9 11.4 133
this PR, run 5 30.3 16.8 11.9 129

The save spawns the player at a random spot, so I checked screenshots: PR run 5 and main run 6 landed on the same spot and view (30.3 / 16.8 / 129 vs 30.4 / 17.1 / 128). So no difference I can measure here, in either the average or the lows. It does no harm, and the scan time it removes may simply be hidden on this machine: the 1.9 ms you measured is on a title thread, and these frames are mostly bound elsewhere (per-frame p50 ~31 ms, slow frames dominated by the title's own work in earlier timelines). I did not time scan itself, so this does not contradict your CPU measurement; it only says the gain is not visible in frame times on a fast CPU.

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

**@⁠EdouardSence** on GitHub · 2026-12-03 11:46 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/295#issuecomment-7377163189) In-game A/B on RDNA 4: **RX 9070 XT 16 GB + Ryzen 7 7800X3D**, 32 GB, CachyOS kernel 7.3.5, Proton-CachyOS, Mesa 26.3.1 + `mesa.patch` from `setup.sh`, resizable BAR on. Release builds of `842767a` (main) and `842767a` + this PR (`00e353f`), identical except for a one-line per-frame frame-time log in `panel.rs` and the scripted keys ungated for release. Defaults (Series X profile, RT on, no frame cap), same frozen save restored before every run, warm pipeline cache, alternating runs of 6 min, stats per frame over the time in the world after the first 45 s (~6,200-6,700 frames each): | | avg fps | 1% low | 0.1% low | frames > 50 ms | |---|---:|---:|---:|---:| | main, run 2 | 30.0 | 16.1 | 10.9 | 142 | | main, run 4 | 30.3 | 16.5 | 11.3 | 152 | | main, run 6 | 30.4 | 17.1 | 12.3 | 128 | | this PR, run 1 | 29.2 | 16.2 | 9.6 | 137 | | this PR, run 3 | 30.2 | 16.9 | 11.4 | 133 | | this PR, run 5 | 30.3 | 16.8 | 11.9 | 129 | The save spawns the player at a random spot, so I checked screenshots: PR run 5 and main run 6 landed on the same spot and view (30.3 / 16.8 / 129 vs 30.4 / 17.1 / 128). So no difference I can measure here, in either the average or the lows. It does no harm, and the scan time it removes may simply be hidden on this machine: the 1.9 ms you measured is on a title thread, and these frames are mostly bound elsewhere (per-frame p50 ~31 ms, slow frames dominated by the title's own work in earlier timelines). I did not time `scan` itself, so this does not contradict your CPU measurement; it only says the gain is not visible in frame times on a fast CPU. AI assistance: Claude Code (Claude Opus 5.5) ran the builds and runs and wrote this report on the hardware above.
Author
Owner

@⁠lucamzanon on GitHub · 2026-12-03 13:23 UTC · original · edited 2026-12-03 13:25 UTC

Automated A/B/B/A Benchmark Feedback (RX 9070 XT / Linux RADV)

Test setup:

  • Hardware / OS: AMD Radeon RX 9070 XT 16 GB (RDNA4, RADV GFX1201), Ryzen 7 5700X, 46 GB RAM, Ubuntu 26.04.1 LTS (kernel 7.0.0-44-generic), repo-built Mesa 26.3.1 RADV + vkd3d-proton
  • Settings: VICTORY_BENCH=rt, VICTORY_BENCH_MINUTES=2 (first 60 s discarded, second 60 s measured), 2560x1440 → 4K FSR 4 Quality, no Frame Generation
  • Methodology: Interleaved A -> B -> B -> A (4 runs per scene), identical save restored before every run, shared warm pipeline cache (94,199 pipelines)
    • A (baseline): main (842767a)
    • B (candidate): PR #295 (00e353f)

Results:

Scene Baseline A (avg / 1% low) Candidate B (avg / 1% low) Delta Pair wins
Boat (2m x 4) 30.15 fps (30.4 / 29.9) / 10.30 30.45 fps (30.2 / 30.7) / 10.25 +1.00% avg / -0.49% 1% low 1/2
Prison (2m x 4) 21.00 fps (21.2 / 20.8) / 6.00 21.15 fps (21.2 / 21.1) / 6.25 +0.71% avg / +4.17% 1% low 1/2

Summary: Zero crashes or visual issues. Even though 4K RT on RX 9070 XT is heavily GPU-bound, both scenes came out slightly ahead on average FPS (+0.7%–+1.0%) and Prison saw a nice +4.17% 1% low improvement (6.25 vs 6.00 fps). Clean win!

Caveat: These runs used default VICTORY_BENCH=rt without scripted gameplay movement (VICTORY_KEYS / VICTORY_KEYS_WORLD), so they mostly measure stationary/cutscene frames. Updating our harness to inject scripted movement via diag + VICTORY_KEYS_WORLD and will follow up with moving-gameplay numbers.

**@⁠lucamzanon** on GitHub · 2026-12-03 13:23 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/295#issuecomment-7379745216) · edited 2026-12-03 13:25 UTC ### Automated A/B/B/A Benchmark Feedback (RX 9070 XT / Linux RADV) **Test setup:** - **Hardware / OS:** AMD Radeon RX 9070 XT 16 GB (RDNA4, `RADV GFX1201`), Ryzen 7 5700X, 46 GB RAM, Ubuntu 26.04.1 LTS (kernel `7.0.0-44-generic`), repo-built Mesa 26.3.1 RADV + vkd3d-proton - **Settings:** `VICTORY_BENCH=rt`, `VICTORY_BENCH_MINUTES=2` (first 60 s discarded, second 60 s measured), 2560x1440 → 4K FSR 4 Quality, no Frame Generation - **Methodology:** Interleaved `A -> B -> B -> A` (4 runs per scene), identical save restored before every run, shared warm pipeline cache (94,199 pipelines) - **A (baseline):** `main` (`842767a`) - **B (candidate):** PR #295 (`00e353f`) **Results:** | Scene | Baseline A (avg / 1% low) | Candidate B (avg / 1% low) | Delta | Pair wins | |---|---:|---:|---:|---:| | **Boat** (`2m x 4`) | `30.15 fps` (`30.4` / `29.9`) / `10.30` | **`30.45 fps`** (`30.2` / `30.7`) / `10.25` | **`+1.00%`** avg / `-0.49%` 1% low | 1/2 | | **Prison** (`2m x 4`) | `21.00 fps` (`21.2` / `20.8`) / `6.00` | **`21.15 fps`** (`21.2` / `21.1`) / **`6.25`** | **`+0.71%`** avg / **`+4.17%`** 1% low | 1/2 | **Summary:** Zero crashes or visual issues. Even though 4K RT on RX 9070 XT is heavily GPU-bound, both scenes came out slightly ahead on average FPS (`+0.7%`–`+1.0%`) and Prison saw a nice **+4.17% 1% low** improvement (`6.25` vs `6.00 fps`). Clean win! > **Caveat:** These runs used default `VICTORY_BENCH=rt` without scripted gameplay movement (`VICTORY_KEYS` / `VICTORY_KEYS_WORLD`), so they mostly measure stationary/cutscene frames. Updating our harness to inject scripted movement via `diag` + `VICTORY_KEYS_WORLD` and will follow up with moving-gameplay numbers.
github manually merged commit f0700bf09a into main 2026-12-03 16:31:12 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.