perf: VICTORY_MERGE_SUBMISSIONS sends consecutive title submissions as one host submission #337

Manually merged
github merged 2 commits from github-bot/gh-337 into main 2026-11-26 14:23:03 +00:00 AGit
Owner

@⁠Skyfrye on GitHub · 2026-11-26 06:27 UTC · original
Skyfrye:nep/merge-submissions → main · +1180 −13 · 5 files · 2 commits · merged 2026-11-26 14:21 UTC

Draft: a small gain for a large change; for the maintainer to weigh.

Change

VICTORY_MERGE_SUBMISSIONS=1 (off by default: unset runs today's code paths): consecutive title submissions in the late/relay path are held and sent to the card as one host submission, so the submitting thread's fixed work per submission (descriptor::sync_heaps, watch::ask_once, shadow::card_dirty, card_before, list close/reset, ExecuteCommandLists + Signal, the relay's bookkeeping) is paid once per group. Each later submission of a group starts with a full barrier, as the boundary between two submissions did. A victory-merge thread sends a group 500 µs after its first submission.

A group is sent at: a fence signal on any queue; a wait for a memory value that held work may write (a held bottom-of-pipe write that meets the wait lets the part behind it join instead); a present, a synchronous submission of ours, a settle, page mappings on a queue; a submission that reads what held or flying shaders write, copies over memory a held one reads, or runs our own code on title memory; 256 lists or 32 submissions held; the 500 µs timer. =2 also carries fence signals behind the group (sent when the fence is queried or waited on): not recommended, see below.

A new frame line, "title submissions merged per frame", counts title submissions, host submissions and sends by reason.

Why: in a 30 s Nsight Systems profile of the world (main at 3e258c8), the frame was bound by the title's submitting thread (about 59 submissions a frame), most of its time in that fixed per-submission work.

Known risk: a held submission is prepared when it is sent, not when the title gave it, so it can see title memory up to 500 µs newer.

Linked issue: none.

Verification

Windows 11 26300, Rust 1.98.1 (MSVC), on upstream main at c4c93bd, from third_party/victory:

cargo build --locked --release -p victory                                   -> Finished, no new warning
VICTORY_D3D12_WARP=1 cargo test --locked -p victory-gpu --lib -- --test-threads=1  -> 192 passed, 3 failed

The 3 failures are those of main: spans_say_the_next_start_and_the_lowest_level_viewed, warp_card_fetch_copies_flagged_pieces_to_their_slots, warp_card_patch_writes_the_masked_bytes_and_no_others. 9 new tests: 7 for the decision of what may be held and what sends a group (they do not build without the change), 2 on the software adapter for the host side. Run with several threads, the test binary ends with an access violation about one run in 4 to 8, and so does main (1 of 8).

In the world, my copy of the game, the same build both ways (this change plus #308, VICTORY_INDIRECT_RAW=3), runs of 300 s alternating:

Console Switch fps (median of the last minute) Host submissions per frame
Series X (4K) =1 15.4 (machine 82 % loaded), 17.5 28 title submissions in 10.2-10.9 (sent for fence signals 10.1-10.4 a frame)
Series X off 15.7, 17.8 28
Series X =2 17.1; the second run lost the device 28 in 4.6-5.0
Series S (--console series-s, 1280x720) =1 20.8, 21.6
Series S off 20.3, 20.9 28

With =1 the submitting thread's preparing fell from 48-52 to 40-46 ms a frame at 4K, where the card (about 70 % busy) limits the frame too; with the card at about a third busy (Series S) the frame rate went up by about 3 %. No exception and no device lost with =1 (6 runs).

Oracle and test data

No game file. The counts come from my own runs of my copy of the game.

Checklist

  • The PR covers a single reviewable behaviour (consecutive title submissions sent as one host submission, behind a switch).
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success. (Nothing unimplemented here.)
  • README: not touched.
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: submission counts; no title code.
  • Code taken from another project: none.

AI assistance: written with Claude Code. Claude Opus 5.5 (a subagent) designed and wrote the change and its tests; Claude Opus 5.5 (coordinating) ran the game A/B and wrote this description.

🤖 Generated with Claude Code

**@⁠Skyfrye** on GitHub · 2026-11-26 06:27 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/337) `Skyfrye:nep/merge-submissions` → `main` · +1180 −13 · 5 files · 2 commits · merged 2026-11-26 14:21 UTC **Draft: a small gain for a large change; for the maintainer to weigh.** ## Change `VICTORY_MERGE_SUBMISSIONS=1` (off by default: unset runs today's code paths): consecutive title submissions in the late/relay path are held and sent to the card as one host submission, so the submitting thread's fixed work per submission (`descriptor::sync_heaps`, `watch::ask_once`, `shadow::card_dirty`, `card_before`, list close/reset, ExecuteCommandLists + Signal, the relay's bookkeeping) is paid once per group. Each later submission of a group starts with a full barrier, as the boundary between two submissions did. A `victory-merge` thread sends a group 500 µs after its first submission. A group is sent at: a fence signal on any queue; a wait for a memory value that held work may write (a held bottom-of-pipe write that meets the wait lets the part behind it join instead); a present, a synchronous submission of ours, a settle, page mappings on a queue; a submission that reads what held or flying shaders write, copies over memory a held one reads, or runs our own code on title memory; 256 lists or 32 submissions held; the 500 µs timer. `=2` also carries fence signals behind the group (sent when the fence is queried or waited on): not recommended, see below. A new frame line, "title submissions merged per frame", counts title submissions, host submissions and sends by reason. Why: in a 30 s Nsight Systems profile of the world (main at 3e258c8), the frame was bound by the title's submitting thread (about 59 submissions a frame), most of its time in that fixed per-submission work. Known risk: a held submission is prepared when it is sent, not when the title gave it, so it can see title memory up to 500 µs newer. Linked issue: none. ## Verification Windows 11 26300, Rust 1.98.1 (MSVC), on upstream `main` at `c4c93bd`, from `third_party/victory`: ``` cargo build --locked --release -p victory -> Finished, no new warning VICTORY_D3D12_WARP=1 cargo test --locked -p victory-gpu --lib -- --test-threads=1 -> 192 passed, 3 failed ``` The 3 failures are those of `main`: `spans_say_the_next_start_and_the_lowest_level_viewed`, `warp_card_fetch_copies_flagged_pieces_to_their_slots`, `warp_card_patch_writes_the_masked_bytes_and_no_others`. 9 new tests: 7 for the decision of what may be held and what sends a group (they do not build without the change), 2 on the software adapter for the host side. Run with several threads, the test binary ends with an access violation about one run in 4 to 8, and so does `main` (1 of 8). In the world, my copy of the game, the same build both ways (this change plus #308, `VICTORY_INDIRECT_RAW=3`), runs of 300 s alternating: | Console | Switch | fps (median of the last minute) | Host submissions per frame | |---|---|---|---| | Series X (4K) | `=1` | 15.4 (machine 82 % loaded), 17.5 | 28 title submissions in 10.2-10.9 (sent for fence signals 10.1-10.4 a frame) | | Series X | off | 15.7, 17.8 | 28 | | Series X | `=2` | 17.1; the second run lost the device | 28 in 4.6-5.0 | | Series S (`--console series-s`, 1280x720) | `=1` | 20.8, 21.6 | | | Series S | off | 20.3, 20.9 | 28 | With `=1` the submitting thread's preparing fell from 48-52 to 40-46 ms a frame at 4K, where the card (about 70 % busy) limits the frame too; with the card at about a third busy (Series S) the frame rate went up by about 3 %. No exception and no device lost with `=1` (6 runs). ## Oracle and test data No game file. The counts come from my own runs of my copy of the game. ## Checklist - [x] The PR covers a single reviewable behaviour (consecutive title submissions sent as one host submission, behind a switch). - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. (Nothing unimplemented here.) - [x] README: not touched. - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: submission counts; no title code. - [x] Code taken from another project: none. AI assistance: written with Claude Code. Claude Opus 5.5 (a subagent) designed and wrote the change and its tests; Claude Opus 5.5 (coordinating) ran the game A/B and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The thread that submits for the title pays fixed work per host submission
(the placed-heap descriptor pass, the write-watch asking, the pass over
copies in the card's memory, the refresh threads' joins, list close and
reset, a send and a signal, a flight for the relay), about 59 times a frame.
With VICTORY_MERGE_SUBMISSIONS=1 a title submission sent ahead
(VICTORY_LATE_WAIT / VICTORY_RELAY) is held back and joins the next ones; they
go to the card as one host submission, in the title's order, with a barrier
(UAV and aliasing barriers on no resource) in front of each submission after
the first.

They are sent at: a fence signal on any queue (=2: the signal is carried
behind them, and the title asking about that fence or a queue waiting for it
sends them), a wait for a memory value that a held submission may write
(one met by a held bottom-of-pipe write lets the part behind it join), a
present, a synchronous submission of ours, a settle, page mappings on a
queue, a next submission that reads what held shaders or flights in the air
write, copies over what a held one brings to the card, or runs code of ours
on title memory, 256 lists or 32 submissions, and 500 us after the first
was held (a thread of its own). Counters per frame on the frame line:
title submissions, host submissions, sends by reason.

Off (the default) every path is as before. The decision logic is in
merge.rs with unit tests; two WARP tests cover the step summary and the
barrier prelude.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:36:39 +00:00
Author
Owner

@⁠KainanP on GitHub · 2026-11-26 10:32 UTC · original

Test report for #337 on three adapters.

Merges cleanly onto current main. Setup: current origin/main (c4c93bd) merged with this PR, Windows 11, cargo test --locked in third_party/victory. Adapters: RTX 4060 Laptop (DXGI 0), Intel UHD 8086:a78b (16-lane waves, no FP64), WARP. The hardware adapter is picked by name through a local, uncommitted test hook and confirmed in its log; WARP for victory-gpu is --features diagnostics + VICTORY_D3D12_WARP=1. victory-gpu runs with --test-threads=1.

victory-gpu --lib main main + #337
RTX 4060 Laptop 183 passed, main's 3 failed 192 passed, main's 3 failed
Intel UHD 183 passed, main's 3 failed 192 passed, main's 3 failed
WARP 196 passed, main's 3 failed 205 passed, main's 3 failed

"main's 3" = descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed, indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots, indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others. They fail on all three adapters on main too. The 9 new tests pass everywhere. No new failure.

Extra runs on the RTX (same binary): VICTORY_MERGE_SUBMISSIONS=1 gives 192 passed, main's 3 failed, and =2 gives the same. Few unit tests go through the late/relay path, so this only shows the switch doesn't break the rest. Run with the default thread count (4 runs), one run ended without a result line (a crash), which matches the access violation you see on main too.

Notes from reading merge.rs:

  • Plan::refuses compares the next submission's read with held shader writes and its written with held brought. It does not compare the next submission's brought (refreshes and textures) with held shader writes. A refresh of title bytes that a held submission's shaders write would, prepared in the group, read the CPU side before those writes landed. On its own it would be behind a flight anyway, so this may already be covered by the relay's under-writes merge. If so, a comment in refuses would say why the pair isn't checked.
  • The 500 µs window means the timer thread prepares and sends on behalf of the title's queue. Is late_threads/settle ordering unchanged when the timer thread and the submitting thread race to send the same group? I did not find a test with both.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.

**@⁠KainanP** on GitHub · 2026-11-26 10:32 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/337#issuecomment-7189502966) Test report for #337 on three adapters. Merges cleanly onto current main. Setup: current `origin/main` (c4c93bd) merged with this PR, Windows 11, `cargo test --locked` in `third_party/victory`. Adapters: RTX 4060 Laptop (DXGI 0), Intel UHD 8086:a78b (16-lane waves, no FP64), WARP. The hardware adapter is picked by name through a local, uncommitted test hook and confirmed in its log; WARP for victory-gpu is `--features diagnostics` + `VICTORY_D3D12_WARP=1`. victory-gpu runs with `--test-threads=1`. | `victory-gpu --lib` | main | main + #337 | |---|---|---| | RTX 4060 Laptop | 183 passed, main's 3 failed | 192 passed, main's 3 failed | | Intel UHD | 183 passed, main's 3 failed | 192 passed, main's 3 failed | | WARP | 196 passed, main's 3 failed | 205 passed, main's 3 failed | "main's 3" = `descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed`, `indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots`, `indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others`. They fail on all three adapters on main too. The 9 new tests pass everywhere. No new failure. Extra runs on the RTX (same binary): `VICTORY_MERGE_SUBMISSIONS=1` gives 192 passed, main's 3 failed, and `=2` gives the same. Few unit tests go through the late/relay path, so this only shows the switch doesn't break the rest. Run with the default thread count (4 runs), one run ended without a result line (a crash), which matches the access violation you see on main too. Notes from reading `merge.rs`: - `Plan::refuses` compares the next submission's `read` with held `shader` writes and its `written` with held `brought`. It does not compare the next submission's `brought` (refreshes and textures) with held `shader` writes. A refresh of title bytes that a held submission's shaders write would, prepared in the group, read the CPU side before those writes landed. On its own it would be behind a flight anyway, so this may already be covered by the relay's under-writes merge. If so, a comment in `refuses` would say why the pair isn't checked. - The 500 µs window means the timer thread prepares and sends on behalf of the title's queue. Is `late_threads`/settle ordering unchanged when the timer thread and the submitting thread race to send the same group? I did not find a test with both. _AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this._
github-bot referenced this pull request from a commit 2026-11-26 12:41:47 +00:00
github-bot referenced this pull request from a commit 2026-11-26 12:41:47 +00:00
github manually merged commit 9a588d07d4 into main 2026-11-26 14:23:03 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.