host: keep refreshes in front across title writes that miss them (VICTORY_KEEP_AHEAD, off by default) #4

Open
SmartIngenieriayDesarrollo wants to merge 1 commit from upstream-pr/4 into main
SmartIngenieriayDesarrollo commented 2026-11-27 23:26:27 +00:00 (Migrated from github.com)

Imported from XaviFortes/VIctory-RDNA. Originally posted by SmartIngenieriayDesarrollo on 2026-11-27T23:26:27Z.


Your in-place work (5e6fec2, 4c210de, 0a07538 and PORT_BUFFERS) helped my build a lot, so here is something back. It is a port of the refresh-side change I'm proposing for Vice-Tay, adapted to this tree's Batch.

Most refreshes in a frame copy nothing: on Vice-Tay I counted 85 to 89 % of them coming back empty. The cause is Batch::title_written. When a submission copies a few bytes into title memory, either a buffer copy at submission or a placed copy with free, it clears every copy that refresh_front / refresh_ahead already brought up to date. Each later list then refreshes them all again.

With VICTORY_KEEP_AHEAD=1 (off by default), such a write drops only the ahead entries whose range holds one of its bytes, and resets last_ahead:

  • pending refreshes are still flushed first, and textures are still checked again;
  • a write that inplace::shown_bytes reports as shown elsewhere drops everything, as today;
  • Step::Run is unchanged;
  • diagnostics builds log kept and dropped counts on the split line.

Measured on Vice-Tay: Ryzen 7 5700X3D, one DDR4-3200 module (single channel), RX 7800 XT, Windows 11, Series S. A 120 s cutscene, A B B A: 10.94 → 11.98 fps (+9.5 %), preparation −9.9 %, copies −20.6 %.

I haven't run this tree in game with the switch yet. The port keeps the same logic and adds the last_ahead reset this tree needs. Off by default, nothing changes.

Tests: a_title_write_drops_only_the_ranges_ahead_it_touches (in mod batch). Checks: cargo test -p victory-gpu --lib --locked gives 396 passed, 0 failed, the new test included (Windows 11, MSVC). cargo clippy -- -D warnings stops on 7 lints that main already has (list.rs, draw.rs, descriptor/host.rs, host/panel.rs, host/place.rs, watch.rs), none in host.rs; cargo fmt --check likewise only flags untouched files.

— El_Santo

AI-assisted; measured and tested on my machine.

<!-- greyfinch-sync:XaviFortes/VIctory-RDNA:issue:5534406479 --> Imported from [XaviFortes/VIctory-RDNA](https://github.com/XaviFortes/VIctory-RDNA/pull/4). Originally posted by [SmartIngenieriayDesarrollo](https://github.com/SmartIngenieriayDesarrollo) on 2026-11-27T23:26:27Z. --- Your in-place work (`5e6fec2`, `4c210de`, `0a07538` and `PORT_BUFFERS`) helped my build a lot, so here is something back. It is a port of the refresh-side change I'm proposing for Vice-Tay, adapted to this tree's `Batch`. Most refreshes in a frame copy nothing: on Vice-Tay I counted 85 to 89 % of them coming back empty. The cause is `Batch::title_written`. When a submission copies a few bytes into title memory, either a buffer copy at submission or a placed copy with `free`, it clears every copy that `refresh_front` / `refresh_ahead` already brought up to date. Each later list then refreshes them all again. With `VICTORY_KEEP_AHEAD=1` (off by default), such a write drops only the `ahead` entries whose range holds one of its bytes, and resets `last_ahead`: - pending refreshes are still flushed first, and textures are still checked again; - a write that `inplace::shown_bytes` reports as shown elsewhere drops everything, as today; - `Step::Run` is unchanged; - diagnostics builds log kept and dropped counts on the split line. Measured on Vice-Tay: Ryzen 7 5700X3D, **one** DDR4-3200 module (single channel), RX 7800 XT, Windows 11, Series S. A 120 s cutscene, A B B A: 10.94 → 11.98 fps (+9.5 %), preparation −9.9 %, copies −20.6 %. I haven't run this tree in game with the switch yet. The port keeps the same logic and adds the `last_ahead` reset this tree needs. Off by default, nothing changes. Tests: `a_title_write_drops_only_the_ranges_ahead_it_touches` (in `mod batch`). Checks: `cargo test -p victory-gpu --lib --locked` gives 396 passed, 0 failed, the new test included (Windows 11, MSVC). `cargo clippy -- -D warnings` stops on 7 lints that `main` already has (`list.rs`, `draw.rs`, `descriptor/host.rs`, `host/panel.rs`, `host/place.rs`, `watch.rs`), none in `host.rs`; `cargo fmt --check` likewise only flags untouched files. — El_Santo _AI-assisted; measured and tested on my machine._
chatgpt-codex-connector[bot] commented 2026-11-27 23:26:35 +00:00 (Migrated from github.com)

Imported from XaviFortes/VIctory-RDNA. Originally posted by chatgpt-codex-connector[bot] on 2026-11-27T23:26:35Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T23:29:22.611369Z 3a592a8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:XaviFortes/VIctory-RDNA:comment:7230144415 --> Imported from [XaviFortes/VIctory-RDNA](https://github.com/XaviFortes/VIctory-RDNA/pull/4#issuecomment-7230144415). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-27T23:26:35Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"3a592a8ed607055d9328c263b80c27d33506a324","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-27T23:29:22.611369Z">2026-11-27T23:29:22.611369Z</relative-time> | `3a592a8` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
akimfomin commented 2026-11-28 01:34:52 +00:00 (Migrated from github.com)

Imported from XaviFortes/VIctory-RDNA. Originally posted by akimfomin on 2026-11-28T01:34:52Z.


I checked the byte-range predicate in 3a592a8e against disjoint byte sets on 10,000 deterministic inputs near a page boundary. Adjacent writes on the same page and empty writes stayed correctly distinct from a one-byte overlap. This was a CPU model, with no render or performance measurement. KLBF #57 uses page-level dirty-copy tracking at a different stage. If the two ideas are combined, keep the byte-exact invalidation and use the page mask as a separate copy-work optimization. A shared synthetic fixture with two cached ranges in one page and one aliased write would verify that distinction and the conservative full-reset fallback.

<!-- greyfinch-sync:XaviFortes/VIctory-RDNA:comment:7231768185 --> Imported from [XaviFortes/VIctory-RDNA](https://github.com/XaviFortes/VIctory-RDNA/pull/4#issuecomment-7231768185). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-28T01:34:52Z. --- I checked the byte-range predicate in `3a592a8e` against disjoint byte sets on 10,000 deterministic inputs near a page boundary. Adjacent writes on the same page and empty writes stayed correctly distinct from a one-byte overlap. This was a CPU model, with no render or performance measurement. [KLBF #57](https://github.com/PastiiJay/klbf-lab/pull/57) uses page-level dirty-copy tracking at a different stage. If the two ideas are combined, keep the byte-exact invalidation and use the page mask as a separate copy-work optimization. A shared synthetic fixture with two cached ranges in one page and one aliased write would verify that distinction and the conservative full-reset fallback.
KingKaom commented 2026-11-28 13:34:02 +00:00 (Migrated from github.com)

Imported from XaviFortes/VIctory-RDNA. Originally posted by KingKaom on 2026-11-28T13:34:02Z.


RX 9070 XT (RDNA4) check of this change rebased onto current tip (4e3a4d2 + PR head, diag build, warm shader cache, Series X target, scripted 4x40s walk, two ~21 min runs vs one control run of tip alone):

  • Tip alone: walk median 33.5 ms/frame (sitting at the 30 fps cadence floor), hitches 0.4/min (per-second samples over 2x run median) max 128 ms, copies 8.7 ms / 52.7 MB per frame
  • KEEP_AHEAD=1 run 1: walk median 36.2 ms/frame, hitches 1.0/min max 322 ms, copies 7.5 ms / 51.0 MB per frame
  • KEEP_AHEAD=1 run 2: walk median 34.4 ms/frame, hitches 0.9/min max 362 ms, copies 8.3 ms / 52.6 MB per frame

The diagnostics split line shows the mechanism is live here, about 27 title writes per frame keep the ahead copies and 0 are dropped. So no win on this card and this tip, hitches run about double the control and neither run reaches the cadence floor the control sits at. That fits the effect being traffic bound: single-channel DDR4 saves real refresh work, on this box the skipped refreshes were already cheap.

Thanks for the clean port.

AI-assisted (Hermes Agent)

<!-- greyfinch-sync:XaviFortes/VIctory-RDNA:comment:7240026815 --> Imported from [XaviFortes/VIctory-RDNA](https://github.com/XaviFortes/VIctory-RDNA/pull/4#issuecomment-7240026815). Originally posted by [KingKaom](https://github.com/KingKaom) on 2026-11-28T13:34:02Z. --- RX 9070 XT (RDNA4) check of this change rebased onto current tip (`4e3a4d2` + PR head, diag build, warm shader cache, Series X target, scripted 4x40s walk, two ~21 min runs vs one control run of tip alone): - Tip alone: walk median 33.5 ms/frame (sitting at the 30 fps cadence floor), hitches 0.4/min (per-second samples over 2x run median) max 128 ms, copies 8.7 ms / 52.7 MB per frame - KEEP_AHEAD=1 run 1: walk median 36.2 ms/frame, hitches 1.0/min max 322 ms, copies 7.5 ms / 51.0 MB per frame - KEEP_AHEAD=1 run 2: walk median 34.4 ms/frame, hitches 0.9/min max 362 ms, copies 8.3 ms / 52.6 MB per frame The diagnostics split line shows the mechanism is live here, about 27 title writes per frame keep the ahead copies and 0 are dropped. So no win on this card and this tip, hitches run about double the control and neither run reaches the cadence floor the control sits at. That fits the effect being traffic bound: single-channel DDR4 saves real refresh work, on this box the skipped refreshes were already cheap. Thanks for the clean port. <sub>AI-assisted (Hermes Agent)</sub>
SmartIngenieriayDesarrollo commented 2026-11-28 20:59:57 +00:00 (Migrated from github.com)

Imported from XaviFortes/VIctory-RDNA. Originally posted by SmartIngenieriayDesarrollo on 2026-11-28T20:59:57Z.


@KingKaom thank you for the long RX 9070 XT runs. That's the result I expected on a fast-memory box. The switch is live there (27 writes a frame keep their copies), but the refreshes it skips were already cheap, so there's no gain. On a single-channel DDR4 PC the same skipped work is real memory traffic.

The hitches worry me more than the median. Did the control run use the same diag build and session length? With one control against two runs I can't tell whether it's the switch or the run. Since it doesn't help on this kind of hardware, I'm fine with it staying off by default, which it already is.

@akimfomin: agreed. Byte-exact invalidation should stay. A page mask would be a separate copy-work optimization on top of it.

— El_Santo

<!-- greyfinch-sync:XaviFortes/VIctory-RDNA:comment:7245697167 --> Imported from [XaviFortes/VIctory-RDNA](https://github.com/XaviFortes/VIctory-RDNA/pull/4#issuecomment-7245697167). Originally posted by [SmartIngenieriayDesarrollo](https://github.com/SmartIngenieriayDesarrollo) on 2026-11-28T20:59:57Z. --- @KingKaom thank you for the long RX 9070 XT runs. That's the result I expected on a fast-memory box. The switch is live there (27 writes a frame keep their copies), but the refreshes it skips were already cheap, so there's no gain. On a single-channel DDR4 PC the same skipped work is real memory traffic. The hitches worry me more than the median. Did the control run use the same diag build and session length? With one control against two runs I can't tell whether it's the switch or the run. Since it doesn't help on this kind of hardware, I'm fine with it staying off by default, which it already is. @akimfomin: agreed. Byte-exact invalidation should stay. A page mask would be a separate copy-work optimization on top of it. — El_Santo
KingKaom commented 2026-11-28 21:39:53 +00:00 (Migrated from github.com)

Imported from XaviFortes/VIctory-RDNA. Originally posted by KingKaom on 2026-11-28T21:39:53Z.


@El_Santo answering your control question directly: yes, the control was the same diag exe, same scripted walk route, same session length around 21 min, same warm shader cache. Only the switch differed. It was n=1 control against n=2 KEEP_AHEAD runs, so your caveat about not separating switch from run is fair. For what it is worth the hitch rates were 0.4/min control versus 1.0/min and 0.9/min with the switch on, so the split direction is consistent, but the counts are small.

One flag while I have your attention: current main tip carries VICTORY_KEEP_AHEAD=1 in the RDNA fast preset (4cc5b11), so RDNA profiles opt in by default there. Our counterexample was measured with the switch as an opt-in knob, but it does apply to that promoted state on this card.

AI-assisted (Hermes Agent)

<!-- greyfinch-sync:XaviFortes/VIctory-RDNA:comment:7246182066 --> Imported from [XaviFortes/VIctory-RDNA](https://github.com/XaviFortes/VIctory-RDNA/pull/4#issuecomment-7246182066). Originally posted by [KingKaom](https://github.com/KingKaom) on 2026-11-28T21:39:53Z. --- @El_Santo answering your control question directly: yes, the control was the same diag exe, same scripted walk route, same session length around 21 min, same warm shader cache. Only the switch differed. It was n=1 control against n=2 KEEP_AHEAD runs, so your caveat about not separating switch from run is fair. For what it is worth the hitch rates were 0.4/min control versus 1.0/min and 0.9/min with the switch on, so the split direction is consistent, but the counts are small. One flag while I have your attention: current main tip carries `VICTORY_KEEP_AHEAD=1` in the RDNA fast preset (`4cc5b11`), so RDNA profiles opt in by default there. Our counterexample was measured with the switch as an opt-in knob, but it does apply to that promoted state on this card. <sub>AI-assisted (Hermes Agent)</sub>
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/4:upstream-pr/4'
git switch 'upstream-pr/4'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/4'
git switch 'upstream-pr/4'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4'
git switch 'upstream-pr/4'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4'
git switch 'main'
git merge --squash 'upstream-pr/4'
git switch 'main'
git merge --ff-only 'upstream-pr/4'
git switch 'main'
git merge 'upstream-pr/4'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
XaviFortes/VIctory-RDNA!4
No description provided.