perf: a fill behind a copy at its place takes the copy's upload bytes (VICTORY_FILL_AFTER_COPY, off by default) #481

Open
github-bot wants to merge 2 commits from github-bot/gh-481 into main AGit
Owner

@⁠Anzymanz on GitHub · 2026-11-27 02:20 UTC · original
Anzymanz:perf/fill-after-copy → main · +364 −9 · 6 files · 2 commits · open

Numbers come from our own VIctory build on a different base (avatarmanz/VIctory-7900XTX c9c932cb plus our changes), not from AnyXboxX main: this change is unmeasured here. Hardware and conditions below.

What it fixes. On our build the submitting thread waited 48-67 ms a frame for flights before one kind of fill (two whole runs). We tested this switch together with two others our build also has, VICTORY_PLACED_ORDER=1 and VICTORY_LATE_WAIT_LISTS=512. With all three on:

  • those fill waits went to 0;
  • the thread's wait for the card fell from 44-100 to 9-27 ms a frame;
  • most of the saved wait moved to copy-back (50-60 to 67-84 ms a frame), which then became the critical path.

Frame time, from interleaved whole runs of the same scene: 154 ms with all three off (mean of 7 runs, range 137-181) against 145.5 ms with all three on (mean of 4 runs, range 133-157). The ranges overlap, so the frame figure is weak; the wait figures are the result. The three were never measured apart. On our build, this switch alone still left fills ahead of the copy refused.

Hardware: RX 9070 XT, Ryzen 9 5950X, Mesa 26.3.1 RADV, GE-Proton11-14 with the view-tree wineserver, Series X profile at 4K, ray tracing on.

What it needs beside it on AnyXboxX main (read from the code, not measured):

  • Late waits on. It only matters with late waits on (flights in the air). The launcher's Linux + AMD profile sets VICTORY_LATE_WAIT=0 (device lost on RADV, fork issue #184), so it does nothing in that profile. Unset, late waits are on when the relay is.
  • VICTORY_PLACED_ORDER (off by default). Without it, a card step that touches the copy's bytes is refused wherever the copy stands, so the fills ahead of the copy still wait.
  • VICTORY_LATE_WAIT_LISTS (256 by default). On our build, the 256-list cap cost 25 ms a frame once the fill waits were gone, until it was raised to 512.

Why. The title keeps a ring of constants in memory that flights are declared to write: a UAV view of its whole graphics heap, used by a few compute passes a frame. Once a frame, a copy at its place (host/place.rs) writes into that ring out of the list's upload memory, and a fill later in the same list reads those bytes as constants. The fill reads title memory on the CPU at submission (Step::Fill), so it waits until every flight declared to write there has landed. On the card it is refused while the list holds a copy at its place.

Change. With VICTORY_FILL_AFTER_COPY=1, such a fill reads the bytes from the copy's upload memory instead. All of these conditions must hold:

  • the last step of the list that writes the fill's bytes is a copy at its place, out of the list's upload memory;
  • that copy holds all of the fill's bytes;
  • the copy is not onto its own source;
  • nothing after it in the list writes its source or destination, or declares a shader write over either;
  • no step of ours that may write anything (a Run) stands between them.

Placed::prepare fills that upload memory on the CPU at the copy's step whether or not the copy can land yet, so the fill gets the same bytes the card has at the destination when the list reads them. The new Step::ForwardedFill does not read title memory, so it holds nothing back (blocked_by) and the card-step planner skips it. A copy out of a host copy is refused: the card copies what shaders wrote there, not what the CPU took. The frame-rate line counts forwarded fills per frame when the switch is on.

The decision is a pure function over the list's steps (host/place/forward.rs), unit-tested without a GPU. avatarmanz landed the same idea independently on their main (84917c34, renderer port RT part 1: HostList::forward_fill, port_rt::forwarded); credit to them.

Tests (Windows target through cargo-xwin, run under Wine):

  • the 9 new tests pass;
  • the crate's lib tests give 449 passed, 3 failed, 41 ignored. The 3 failures are in watch (holes_are_known_until_the_runtime_tells, no_mapping_is_lost_between_askers, what_is_left_alone_is_no_known_hole); they fail the same way on unmodified main under Wine (checked: 45 passed, the same 3 failed);
  • cargo xtask policy passes, and cargo clippy (Windows target) passes, with one warning in the untouched overlay.rs.

Not run: Windows itself, NVIDIA, and any game run on this branch.

Written with Claude Code (port by an OpenAI Codex agent, reviewed by Claude).

**@⁠Anzymanz** on GitHub · 2026-11-27 02:20 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/481) `Anzymanz:perf/fill-after-copy` → `main` · +364 −9 · 6 files · 2 commits · open > **Numbers come from our own VIctory build on a different base** (avatarmanz/VIctory-7900XTX `c9c932cb` plus our changes), **not from AnyXboxX `main`**: this change is unmeasured here. Hardware and conditions below. **What it fixes.** On our build the submitting thread waited 48-67 ms a frame for flights before one kind of fill (two whole runs). We tested this switch together with two others our build also has, `VICTORY_PLACED_ORDER=1` and `VICTORY_LATE_WAIT_LISTS=512`. With all three on: - those fill waits went to 0; - the thread's wait for the card fell from 44-100 to 9-27 ms a frame; - most of the saved wait moved to copy-back (50-60 to 67-84 ms a frame), which then became the critical path. Frame time, from interleaved whole runs of the same scene: 154 ms with all three off (mean of 7 runs, range 137-181) against 145.5 ms with all three on (mean of 4 runs, range 133-157). The ranges overlap, so the frame figure is weak; the wait figures are the result. The three were never measured apart. On our build, this switch alone still left fills ahead of the copy refused. Hardware: RX 9070 XT, Ryzen 9 5950X, Mesa 26.3.1 RADV, GE-Proton11-14 with the view-tree wineserver, Series X profile at 4K, ray tracing on. **What it needs beside it on AnyXboxX `main`** (read from the code, not measured): - **Late waits on.** It only matters with late waits on (flights in the air). The launcher's Linux + AMD profile sets `VICTORY_LATE_WAIT=0` (device lost on RADV, fork issue #184), so it does nothing in that profile. Unset, late waits are on when the relay is. - **`VICTORY_PLACED_ORDER` (off by default).** Without it, a card step that touches the copy's bytes is refused wherever the copy stands, so the fills ahead of the copy still wait. - **`VICTORY_LATE_WAIT_LISTS` (256 by default).** On our build, the 256-list cap cost 25 ms a frame once the fill waits were gone, until it was raised to 512. **Why.** The title keeps a ring of constants in memory that flights are declared to write: a UAV view of its whole graphics heap, used by a few compute passes a frame. Once a frame, a copy at its place (`host/place.rs`) writes into that ring out of the list's upload memory, and a fill later in the same list reads those bytes as constants. The fill reads title memory on the CPU at submission (`Step::Fill`), so it waits until every flight declared to write there has landed. On the card it is refused while the list holds a copy at its place. **Change.** With `VICTORY_FILL_AFTER_COPY=1`, such a fill reads the bytes from the copy's upload memory instead. All of these conditions must hold: - the last step of the list that writes the fill's bytes is a copy at its place, out of the list's upload memory; - that copy holds all of the fill's bytes; - the copy is not onto its own source; - nothing after it in the list writes its source or destination, or declares a shader write over either; - no step of ours that may write anything (a `Run`) stands between them. `Placed::prepare` fills that upload memory on the CPU at the copy's step whether or not the copy can land yet, so the fill gets the same bytes the card has at the destination when the list reads them. The new `Step::ForwardedFill` does not read title memory, so it holds nothing back (`blocked_by`) and the card-step planner skips it. A copy out of a host copy is refused: the card copies what shaders wrote there, not what the CPU took. The frame-rate line counts forwarded fills per frame when the switch is on. The decision is a pure function over the list's steps (`host/place/forward.rs`), unit-tested without a GPU. avatarmanz landed the same idea independently on their main (`84917c34`, renderer port RT part 1: `HostList::forward_fill`, `port_rt::forwarded`); credit to them. **Tests** (Windows target through cargo-xwin, run under Wine): - the 9 new tests pass; - the crate's lib tests give 449 passed, 3 failed, 41 ignored. The 3 failures are in `watch` (`holes_are_known_until_the_runtime_tells`, `no_mapping_is_lost_between_askers`, `what_is_left_alone_is_no_known_hole`); they fail the same way on unmodified `main` under Wine (checked: 45 passed, the same 3 failed); - `cargo xtask policy` passes, and `cargo clippy` (Windows target) passes, with one warning in the untouched `overlay.rs`. Not run: Windows itself, NVIDIA, and any game run on this branch. Written with Claude Code (port by an OpenAI Codex agent, reviewed by Claude).
A fill of upload memory whose bytes were all written last, in the same list,
by a copy at its place out of the list's upload memory now reads them from
that upload memory (Step::ForwardedFill), so it no longer waits for flights
declared to write the copy's destination. Placed::prepare fills the upload
memory on the CPU at the copy's step either way. Refused: part only, a copy
out of a host copy, a copy onto its source, a later write or shader-write
declaration over the source or destination, a Run between. The decision is a
pure function over the list's steps (host/place/forward.rs) with unit tests;
forwarded fills are counted on the frame-rate line.

Ported from our own VIctory branch (another base), where it was measured.
Same idea, independently: avatarmanz/VIctory-7900XTX 84917c34 (renderer port
RT, part 1).

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

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-27 02:21 UTC · original · edited 2026-11-27 02:27 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-27T02:27:06.158907Z 6580d42 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 02:21 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/481#issuecomment-7208045836) · edited 2026-11-27 02:27 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"6580d4285f8bc011dd31721c673a6f1f32a9652a","has_any_findings":true,"has_unresolved_findings":true,"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-27T02:27:06.158907Z">2026-11-27T02:27:06.158907Z</relative-time> | `6580d42` | 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>
Review (chatgpt-codex-connector, P2): with VICTORY_FILL_AFTER_COPY=1 every
fill walked the whole list behind it when nothing matched, O(fills x steps)
with a growing vector on the recording path. The list now keeps its copies at
their place out of upload memory since its last Run (index, destination,
bytes); only one of those that holds the whole fill can give it its bytes, so
the walk starts at the earliest such copy, and a fill with none costs a look
at that short list. What is forwarded is unchanged: a test compares the
bounded walk with the whole walk over 4,000 generated lists, and a 100,000-step
list without such a copy is not walked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-27 02:27 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6580d4285f

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-27 02:27 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/481#pullrequestreview-6082688281) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `6580d4285f` <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". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
@ -0,0 +86,4 @@
}
let fill = src..src.checked_add(len)?;
let mut later = Vec::new();
for step in steps {
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-27 02:27 UTC · original

P2 Badge Avoid rescanning every prior step for each fill

With VICTORY_FILL_AFTER_COPY=1, every defer_upload_fill invokes this walk. On a command list with many fills and writes but no Run barrier or earlier Placed copy covering a fill source, the loop visits the entire prefix and accumulates its writes before returning None; repeating that for M fills over N steps is O(MN) and repeatedly grows a temporary vector on the recording path even though every fill falls back. This can erase the opt-in optimization on nonmatching lists; index or short-circuit eligible placements instead of rescanning the history for each fill.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-27 02:27 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/481#discussion_r4715073327) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Avoid rescanning every prior step for each fill** With `VICTORY_FILL_AFTER_COPY=1`, every `defer_upload_fill` invokes this walk. On a command list with many fills and writes but no `Run` barrier or earlier `Placed` copy covering a fill source, the loop visits the entire prefix and accumulates its writes before returning `None`; repeating that for M fills over N steps is O(MN) and repeatedly grows a temporary vector on the recording path even though every fill falls back. This can erase the opt-in optimization on nonmatching lists; index or short-circuit eligible placements instead of rescanning the history for each fill. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
@ -0,0 +86,4 @@
}
let fill = src..src.checked_add(len)?;
let mut later = Vec::new();
for step in steps {
Author
Owner

@⁠Anzymanz on GitHub · 2026-11-27 02:38 UTC · original

Fair point, fixed in fe33308 without changing what gets forwarded.

The list now keeps its copies at their place out of upload memory since its last Run (index, destination, bytes). Only such a copy that holds the whole fill can give it its bytes. So forward first picks the earliest of those that holds the fill, and walks back only to it. A fill with none costs a look at that short list, usually empty or one entry, and no walk at all.

Before that copy there is only a Run (which ends the walk with nothing) or steps that can't give the fill its bytes. So the result is the same as walking every step. Two new tests cover this:

  • one compares the bounded walk with the whole walk over 4,000 generated lists;
  • one checks that a 100,000-step list without such a copy isn't walked.

All 11 forwarding tests pass under Wine (Windows target), and clippy is clean apart from the existing warning in overlay.rs.

Written with Claude Code.

**@⁠Anzymanz** on GitHub · 2026-11-27 02:38 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/481#discussion_r4715138101) Fair point, fixed in fe33308 without changing what gets forwarded. The list now keeps its copies at their place out of upload memory since its last `Run` (index, destination, bytes). Only such a copy that holds the whole fill can give it its bytes. So `forward` first picks the earliest of those that holds the fill, and walks back only to it. A fill with none costs a look at that short list, usually empty or one entry, and no walk at all. Before that copy there is only a `Run` (which ends the walk with nothing) or steps that can't give the fill its bytes. So the result is the same as walking every step. Two new tests cover this: - one compares the bounded walk with the whole walk over 4,000 generated lists; - one checks that a 100,000-step list without such a copy isn't walked. All 11 forwarding tests pass under Wine (Windows target), and clippy is clean apart from the existing warning in `overlay.rs`. Written with Claude Code.
This pull request can be merged automatically.
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/481/head:github-bot/gh-481'
git switch 'github-bot/gh-481'

Merge

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