Skip to content

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 into
XaviFortes:mainfrom
SmartIngenieriayDesarrollo:keep-refreshes-ahead
Open

SmartIngenieriayDesarrollo wants to merge 1 commit into
XaviFortes:mainfrom
SmartIngenieriayDesarrollo:keep-refreshes-ahead

Conversation

@SmartIngenieriayDesarrollo

Copy link
Copy Markdown

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 (Claude Code): tested on my machine, text drafted with Claude.

🤖 Generated with Claude Code

…EEP_AHEAD)

A buffer copy into title memory at submission, done there or at its place
in the lists, cleared every copy brought up to date ahead of the
submission's steps. Each copy the later lists refresh was then added,
flushed and looked at again, though the write touched a few bytes of
title memory: on Vice-Tay, 85 to 89 % of a frame's refreshes were found
to copy nothing.

With VICTORY_KEEP_AHEAD=1 (off by default) such a write drops only the
copies whose refreshed range holds one of its bytes, and clears the
one-entry ahead cache. Pending refreshes are still done before the write,
and textures are checked again after it. A write into memory that views
of physical pages show drops all of them, as before. Work that may write
anywhere (Step::Run) is unchanged.

Ported from the Vice-Tay change, where it measured +9.5 % (A B B A, 120 s
cutscene) on a Ryzen 7 5700X3D with single-channel DDR4-3200 and an
RX 7800 XT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
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.

Copy link
Copy Markdown

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.

@KingKaom

Copy link
Copy Markdown

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants