Keep refreshes in front across title writes that miss them (VICTORY_KEEP_AHEAD) #388

Open
github-bot wants to merge 1 commit from github-bot/gh-388 into main AGit
Owner

@⁠SmartIngenieriayDesarrollo on GitHub · 2026-11-27 23:26 UTC · original
SmartIngenieriayDesarrollo:keep-refreshes-ahead → main · +162 −3 · 1 files · 1 commits · open

Most refreshes in a frame copy nothing. I counted 85 to 89 % of 9,000–11,000 refreshes per frame coming back empty, about 38 ms of the submitting thread. Almost all of that waste starts with one small write.

When a submission copies a few bytes into title memory, either a buffer copy done at submission or a placed copy at its place in the lists, Batch::title_written throws away every copy that refresh_front / refresh_ahead had already brought up to date. Every later list then adds, flushes and checks those copies again, even though the write touched none of them.

With VICTORY_KEEP_AHEAD=1 (off by default), such a write drops only the copies whose refreshed range contains one of its bytes:

  • byte for byte, not by 64 KiB page;
  • pending refreshes are still flushed before the write, and textures are still checked again after it;
  • a write into memory that physical-page views show (inplace::shown_bytes) still drops everything, as today;
  • Step::Run work, which may write anywhere, is unchanged;
  • diagnostics builds log per frame how many writes kept copies, and how many copies were kept and dropped.

Measured on a Ryzen 7 5700X3D with one DDR4-3200 module (single channel) and an RX 7800 XT, Series S, Vice-Tay 791648b plus a frame CSV patch: a 120 s cutscene, runs A B B A, 10.94 → 11.98 fps (+9.5 %).

  • Both B runs were outside the A range.
  • Preparation fell 9.9 % and copies 20.6 %.
  • The p10 frame rate rose 12.7 %.

I kept it on through the rest of my tuning, but I haven't repeated an alternating A/B on current main (0148258).

On a PC like mine every flush is memory bandwidth taken from the frame. On a high-end PC it is still submitting-thread time handed back.

Two tests cover it: a_title_write_drops_only_the_ranges_ahead_it_touches (the batch bookkeeping) and a_title_write_refreshes_again_only_the_copies_it_touches. The second runs a real copy over the end of one range and checks that every host copy still matches title memory, with the switch on and off. Checks: cargo clippy -p victory-gpu --all-targets --locked -- -D warnings is clean and cargo test -p victory-gpu --lib --locked gives 529 passed, 0 failed, the two new tests included (Windows 11, MSVC, the repo toolchain). cargo fmt --check only flags files this PR does not touch.

— El_Santo

AI-assisted (Claude Code and Codex): measured on my machine, text drafted with Claude.

🤖 Generated with Claude Code

**@⁠SmartIngenieriayDesarrollo** on GitHub · 2026-11-27 23:26 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/388) `SmartIngenieriayDesarrollo:keep-refreshes-ahead` → `main` · +162 −3 · 1 files · 1 commits · open Most refreshes in a frame copy nothing. I counted 85 to 89 % of 9,000–11,000 refreshes per frame coming back empty, about 38 ms of the submitting thread. Almost all of that waste starts with one small write. When a submission copies a few bytes into title memory, either a buffer copy done at submission or a placed copy at its place in the lists, `Batch::title_written` throws away every copy that `refresh_front` / `refresh_ahead` had already brought up to date. Every later list then adds, flushes and checks those copies again, even though the write touched none of them. With `VICTORY_KEEP_AHEAD=1` (off by default), such a write drops only the copies whose refreshed range contains one of its bytes: - byte for byte, not by 64 KiB page; - pending refreshes are still flushed before the write, and textures are still checked again after it; - a write into memory that physical-page views show (`inplace::shown_bytes`) still drops everything, as today; - `Step::Run` work, which may write anywhere, is unchanged; - diagnostics builds log per frame how many writes kept copies, and how many copies were kept and dropped. Measured on a Ryzen 7 5700X3D with one DDR4-3200 module (single channel) and an RX 7800 XT, Series S, Vice-Tay `791648b` plus a frame CSV patch: a 120 s cutscene, runs A B B A, **10.94 → 11.98 fps (+9.5 %)**. - Both B runs were outside the A range. - Preparation fell 9.9 % and copies 20.6 %. - The p10 frame rate rose 12.7 %. I kept it on through the rest of my tuning, but I haven't repeated an alternating A/B on current `main` (`0148258`). On a PC like mine every flush is memory bandwidth taken from the frame. On a high-end PC it is still submitting-thread time handed back. Two tests cover it: `a_title_write_drops_only_the_ranges_ahead_it_touches` (the batch bookkeeping) and `a_title_write_refreshes_again_only_the_copies_it_touches`. The second runs a real copy over the end of one range and checks that every host copy still matches title memory, with the switch on and off. Checks: `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` is clean and `cargo test -p victory-gpu --lib --locked` gives 529 passed, 0 failed, the two new tests included (Windows 11, MSVC, the repo toolchain). `cargo fmt --check` only flags files this PR does not touch. — El_Santo _AI-assisted (Claude Code and Codex): measured on my machine, text drafted with Claude._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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: 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. 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, which other addresses
may show too, drops all of them, as before. Work that may write anywhere
(deferred steps) is unchanged.

Diagnostics builds with the switch on say per frame how many title writes
kept copies, how many were kept and dropped, and how many writes fell
into views.

Measured on a Ryzen 7 5700X3D, single-channel DDR4-3200, RX 7800 XT,
Series S, a 120 s cutscene window, runs A B B A: 10.94 -> 11.98 fps
(+9.5 %), preparation -9.9 %, copies -20.6 %.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 23:29:50 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-27 23:26 UTC · original · edited 2026-11-27 23:29 UTC

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:08.070462Z 0334d59 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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-27 23:26 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/388#issuecomment-7230144030) · edited 2026-11-27 23:29 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"0334d598083f7e8b1015c316f2b60485acbee4f4","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:08.070462Z">2026-11-27T23:29:08.070462Z</relative-time> | `0334d59` | 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>
Author
Owner

@⁠akimfomin on GitHub · 2026-11-28 00:04 UTC · original

I ran PortBridge’s tree check between #388 0334d59 and #379 ecc003e. The pair combines without a Git conflict. There is one useful combined control: exercise #379’s mapped alias with KEEP_AHEAD both off and on. Pre-refresh a buffer through view B, write through view A, then verify the refreshed bytes through B and both texture heaps’ notices. #388 already falls back to a full refresh for any mapped portion of the write; the combined check would preserve that guard if the PRs land together. The tree check and source review are from PortBridge, with no new GPU run.

**@⁠akimfomin** on GitHub · 2026-11-28 00:04 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/388#issuecomment-7230619436) I ran PortBridge’s tree check between #388 `0334d59` and #379 `ecc003e`. The pair combines without a Git conflict. There is one useful combined control: exercise #379’s mapped alias with KEEP_AHEAD both off and on. Pre-refresh a buffer through view B, write through view A, then verify the refreshed bytes through B and both texture heaps’ notices. #388 already falls back to a full refresh for [any mapped portion of the write](https://github.com/TaynanGT/Vice-Tay/blob/0334d598083f7e8b1015c316f2b60485acbee4f4/crates/victory-gpu/src/inplace.rs#L485-L499); the combined check would preserve that guard if the PRs land together. The tree check and source review are from [PortBridge](https://github.com/akimfomin/PortBridge), with no new GPU run.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/388/head:github-bot/gh-388'
git switch 'github-bot/gh-388'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-388'
git switch 'github-bot/gh-388'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-388'
git switch 'github-bot/gh-388'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-388'
git switch 'main'
git merge --squash 'github-bot/gh-388'
git switch 'main'
git merge --ff-only 'github-bot/gh-388'
git switch 'main'
git merge 'github-bot/gh-388'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.