perf: integration batch, cheaper title-memory copies (12 PRs, +13 % median fps measured) #358

Manually merged
github merged 34 commits from github-bot/gh-358 into main 2026-11-26 14:22:59 +00:00 AGit
Owner

@⁠LooperSalty on GitHub · 2026-11-26 12:41 UTC · original
LooperSalty:perf/copy-batch-2026-11-26 → main · +4378 −259 · 31 files · 35 commits · merged 2026-11-26 14:21 UTC

Integration batch, like #277: twelve open pull requests that cut the per-frame cost of the copies between title memory and the card. Their commits keep their authors. Several are drafts or are waiting for CI approval as first-time contributors, so they are brought in together here and tested as one.

Pull requests in this batch

PR Author What Switch
#340 Skyfrye transient windows leave out pages that hold what they last sent VICTORY_WINDOW_SKIP_SAME (sample mode by default, =1 saves)
#337 Skyfrye consecutive title submissions as one host submission VICTORY_MERGE_SUBMISSIONS (off by default)
#291 Skyfrye a list of the card copies marked changed instead of a sweep always on
#255 Skyfrye the compare result area becomes a ring VICTORY_RESULT_RING (on, =0 off)
#268 Skyfrye host copies under finished reads VICTORY_PAGE_WRITES=5 (off by default)
#323 mauroalvare reuse free space in window upload slabs always on
#325 mauroalvare reuse zeroed upload buffers for mip initialization always on
#332 mauroalvare stage only the requested rows for boxed texture uploads always on
#329 mauroalvare scratch chunks replace older idle buffers VICTORY_SCRATCH_POOL (on, =0 off)
#312 mauroalvare direct readback into title memory for tight linear textures always on
#304 mauroalvare one texture upload shared by duplicated heap views always on
#289 mauroalvare LRU eviction of staging buffers across size classes always on

Two conflicts were mechanical, with additions on both sides: #337 against #255 in host.rs, and #291 against #340 in shadow.rs. Left out: #292, #311 and #254 (correctness fixes, not copies), #276 (Wine only), #278 and #279 (lock and clock micro-optimisations).

Measured (maintainer's machine, 2026-11-26)

i7-13700KF, RTX 4070 SUPER, Windows 11, Series X, same save, launcher settings of main. Medians come from the VIctory log's frame-rate line; card occupancy from its "the card about N% busy" line.

Run Duration Median fps Last 2 min Card busy
main (8ed1109f) 5 min 13.4 13.2 70–77 %
this batch, defaults 6 min 13.7 14.6 72–89 %
this batch + VICTORY_WINDOW_SKIP_SAME=1 VICTORY_MERGE_SUBMISSIONS=1 VICTORY_PAGE_WRITES=5 11 min 15.2 14.6 78–85 %

No crash and no device loss in any run, and dropped draws per frame are about the same (440 / 478 / 445). Each configuration ran once. The three switches stay off by default in this PR: a follow-up turns them on in the launcher's tuned set once a second run confirms the gain.

Test plan

  • cargo test --release -p victory-gpu: 216 passed. The 3 that fail fail the same way on clean main (WARP tests descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed, indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others, indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots)
  • cargo xtask policy: 209 files ok
  • In-game runs above
  • CI green

🤖 Generated with Claude Code

https://claude.ai/code/session_01LwHrL62nyr3m1M4tJsHRox

**@⁠LooperSalty** on GitHub · 2026-11-26 12:41 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/358) `LooperSalty:perf/copy-batch-2026-11-26` → `main` · +4378 −259 · 31 files · 35 commits · merged 2026-11-26 14:21 UTC Integration batch, like #277: twelve open pull requests that cut the per-frame cost of the copies between title memory and the card. Their commits keep their authors. Several are drafts or are waiting for CI approval as first-time contributors, so they are brought in together here and tested as one. ## Pull requests in this batch | PR | Author | What | Switch | | --- | --- | --- | --- | | #340 | Skyfrye | transient windows leave out pages that hold what they last sent | `VICTORY_WINDOW_SKIP_SAME` (sample mode by default, `=1` saves) | | #337 | Skyfrye | consecutive title submissions as one host submission | `VICTORY_MERGE_SUBMISSIONS` (off by default) | | #291 | Skyfrye | a list of the card copies marked changed instead of a sweep | always on | | #255 | Skyfrye | the compare result area becomes a ring | `VICTORY_RESULT_RING` (on, `=0` off) | | #268 | Skyfrye | host copies under finished reads | `VICTORY_PAGE_WRITES=5` (off by default) | | #323 | mauroalvare | reuse free space in window upload slabs | always on | | #325 | mauroalvare | reuse zeroed upload buffers for mip initialization | always on | | #332 | mauroalvare | stage only the requested rows for boxed texture uploads | always on | | #329 | mauroalvare | scratch chunks replace older idle buffers | `VICTORY_SCRATCH_POOL` (on, `=0` off) | | #312 | mauroalvare | direct readback into title memory for tight linear textures | always on | | #304 | mauroalvare | one texture upload shared by duplicated heap views | always on | | #289 | mauroalvare | LRU eviction of staging buffers across size classes | always on | Two conflicts were mechanical, with additions on both sides: #337 against #255 in `host.rs`, and #291 against #340 in `shadow.rs`. Left out: #292, #311 and #254 (correctness fixes, not copies), #276 (Wine only), #278 and #279 (lock and clock micro-optimisations). ## Measured (maintainer's machine, 2026-11-26) i7-13700KF, RTX 4070 SUPER, Windows 11, Series X, same save, launcher settings of `main`. Medians come from the VIctory log's frame-rate line; card occupancy from its "the card about N% busy" line. | Run | Duration | Median fps | Last 2 min | Card busy | | --- | --- | --- | --- | --- | | `main` (8ed1109f) | 5 min | 13.4 | 13.2 | 70–77 % | | this batch, defaults | 6 min | 13.7 | 14.6 | 72–89 % | | this batch + `VICTORY_WINDOW_SKIP_SAME=1 VICTORY_MERGE_SUBMISSIONS=1 VICTORY_PAGE_WRITES=5` | 11 min | **15.2** | 14.6 | 78–85 % | No crash and no device loss in any run, and dropped draws per frame are about the same (440 / 478 / 445). Each configuration ran once. The three switches stay off by default in this PR: a follow-up turns them on in the launcher's tuned set once a second run confirms the gain. ## Test plan - [x] `cargo test --release -p victory-gpu`: 216 passed. The 3 that fail fail the same way on clean `main` (WARP tests `descriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewed`, `indirect::tests::warp_card_patch_writes_the_masked_bytes_and_no_others`, `indirect::tests::warp_card_fetch_copies_flagged_pieces_to_their_slots`) - [x] `cargo xtask policy`: 209 files ok - [x] In-game runs above - [ ] CI green 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01LwHrL62nyr3m1M4tJsHRox
Each submission that has host copies in the card's memory records a
compare whose results take one dword per piece of a 1 MiB area. The area
was reused from its start only when no plan was in the air; with the relay
one nearly always is, so the area only filled up, and each time it was
half taken the submitting thread drained every flight (a wait for the card
and the copy-back of all of them, counted as "lists in the air") before it
could go on.

Plans land in the order they were made, so the space they take comes back
in that order. The area is now a ring (resultring.rs): a plan takes one
stretch for the ranges the card compares, after the newest plan's, wrapping
to the start, and gives it back when it lands (Host::card_done, after its
results were read). The drain stays for an area three quarters taken by
plans still in the air. A plan that finds no stretch long enough compares
the ranges that fit and fetches the others, as when the area ran out before.

VICTORY_RESULT_RING=0 restores the previous rule (reused only when empty,
drained at half).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Found by an independent review of the ring. Once the ring has wrapped, its
free dwords can lie in two stretches, after the newest plan and before the
oldest, neither as long as a plan needs. The plan then got part of what it
asked for and compared only the ranges that fit; a plan with a range not
compared has its whole landing fetched the slow way. The former rule
(drain at half, then start from 0) always left one stretch.

The ring now remembers the most plans asked for lately (decaying by a
sixteenth at each plan) and Host::card_results_low also lets the flights
land when the longest free stretch is shorter than that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When a read of the title's (DirectStorage or a file read) into a plain
address finishes, the host copies of buffers that a copy or a pass took
while the read was under way keep the bytes from before until something
else marks the memory written. Bit 4 of VICTORY_PAGE_WRITES acts on those
reads; in the base it can only be had with "all", which also sets bit 2
(texture slots under the write made due again), the bit the code notes
"flooded the queue in an earlier form". In one 5-minute run on an RTX 5080
133,144 such reads finished and were only counted, while walls and meshes
showed late and the texture queue already held 800 to 5,900 textures.

Now any number from 2 to 7 is taken as the bits themselves, and
"guards+reads" names 5 (bits 1 and 4: host copies under page writes and
under finished reads taken again, texture slots left alone). The names and
the meaning of "1" are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`card_dirty` went through every copy in the card's memory at every
submission (about 59 a frame in the world) to find the few whose flag was
up: in a 30 s Nsight Systems profile of the world that pass was 2.5 % of
the submitting thread's time.

A copy now goes into a list (`FLAGGED`) when its flag goes up, and
`card_dirty` takes that list. `CARDED` still lists every copy (for the
memory line); copies that are gone are taken off it when copies are made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep a write cursor for each pooled slab so a full current slab can fall back to space available in an earlier one. Exercise six rounds of live chunks and validate all copied bytes using D3D12 readback.
Use an immutable per-device source for repeated fresh-mip clears and keep older sources alive in the lists that recorded them. Bound the cached buffer size and verify the clear and partial write against GPU readback.
Keep recently returned scratch chunks under the idle byte cap, releasing oldest buffers after unlocking the pool. Test a large burst followed by repeatedly submitted small lists and verify the GPU copies.
Rebase a 2D source box onto a smaller staging footprint while keeping its row pitch and deferred fill. Verify the staged byte count and the resulting texture on D3D12, including pixels outside the copied patches.
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]>
The windows without a CPU side (VICTORY_CARD_WINDOW_UPLOAD=1) copy every page the
write watch or the guards name into an upload chunk and send it up whole: some
70 MB a frame in the world (Series S run, 20 fps). A page written need not hold
other bytes; nothing compared them.

Each such window now keeps a 64-bit print of the bytes it last sent for each
4 KiB page (an XXH3-style accumulate of eight lanes, some 40 GB/s on one core;
8 bytes a page). With VICTORY_WINDOW_SKIP_SAME=1 a page whose bytes give the
same print is neither copied nor sent: title memory is read 256 KiB at a time
into memory of the thread's, printed, and each run of other pages goes into a
chunk of its own. The card side still holds those bytes: nothing but the
window's sends writes it, in the order they were copied; a page sent only in
part keeps no print; a window made again starts with none; and a window that
shaders are said to write (unordered access, a title buffer copy on the card,
title memory by address: a bug, counted and logged) compares nothing from
then on.

Unset (the default), the pages are sent as before and one 4 KiB page in 16,
picked by its address, is read again and compared, so the new line can say how
much of what the windows send is the bytes they sent last time.
VICTORY_WINDOW_SKIP_SAME=0 compares nothing (the code path as before). The new
line, with the frame-rate line while there are transient windows, gives what
they took per frame: sent up and left out, and of it the bytes that held what
the window last sent, other bytes, and nothing to compare with. The ram line
gives the prints' memory.

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

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 12:41 UTC · original

Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T12:41:17.733806Z
We couldn’t complete this review. Comment @codex review to try again.
5c4b75f 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-26 12:41 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/358#issuecomment-7192329329) <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5c4b75fb080a188411565ca068d12a4f6e23be07","has_any_findings":true,"has_unresolved_findings":true,"status":"failed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ❌ Failed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ❌ **Failed** <relative-time datetime="2026-11-26T12:41:17.733806Z">2026-11-26T12:41:17.733806Z</relative-time><br/>We couldn’t complete this review. Comment `@codex review` to try again. | `5c4b75f` | 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

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 12:41 UTC · original

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 12:41 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/358#issuecomment-7192330145) You have reached your Codex usage limits for code reviews. You can see your limits in the [Codex usage dashboard](https://chatgpt.com/codex/cloud/settings/usage). To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your [settings](https://chatgpt.com/settings/code-review).
VICTORY_WINDOW_SKIP_SAME=1, VICTORY_MERGE_SUBMISSIONS=1 and
VICTORY_PAGE_WRITES=5 join the tuned set of anyxboxx run and the
Windows + NVIDIA launcher profile (42 variables). Measured on
2026-11-26 (RTX 4070 SUPER, Series X): main 13.4 fps median, this batch
with the switches 15.2 over 11 minutes, then 14.5 to 15.1 in four more
runs of the same base. The golden script, the counts in the tests and the
guides (EN and FR) follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LwHrL62nyr3m1M4tJsHRox
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-26 13:51 UTC · original

Update: 38cb70af now turns the three switches on by default (VICTORY_WINDOW_SKIP_SAME=1, VICTORY_MERGE_SUBMISSIONS=1, VICTORY_PAGE_WRITES=5) in anyxboxx run's tuned set and in the Windows + NVIDIA launcher profile (42 variables). The golden script, the tests and the guides (EN and FR) are updated. Four more runs of this base on 2026-11-26 measured 14.5 to 15.1 fps median (main: 13.4). The CLAMP_AFTER_WRITER and Wave32 ports follow in #377, stacked on this PR.

🤖 Generated with Claude Code

**@⁠LooperSalty** on GitHub · 2026-11-26 13:51 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/358#issuecomment-7193944991) Update: `38cb70af` now turns the three switches on by default (`VICTORY_WINDOW_SKIP_SAME=1`, `VICTORY_MERGE_SUBMISSIONS=1`, `VICTORY_PAGE_WRITES=5`) in `anyxboxx run`'s tuned set and in the Windows + NVIDIA launcher profile (42 variables). The golden script, the tests and the guides (EN and FR) are updated. Four more runs of this base on 2026-11-26 measured 14.5 to 15.1 fps median (`main`: 13.4). The CLAMP_AFTER_WRITER and Wave32 ports follow in #377, stacked on this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github manually merged commit 374cac77ce into main 2026-11-26 14:22:59 +00:00
Author
Owner

@⁠Skyfrye on GitHub · 2026-11-26 14:28 UTC · original

A picture problem with VICTORY_WINDOW_SKIP_SAME=1, which main's launcher now sets (profiles.toml, run/settings.rs).

What I saw: same build (main c4c93bd + #308 + #340), same scene (the first cutscene, at the same point), Series X, VICTORY_INDIRECT_RAW=3, RTX 5080, screen captures every 15 s.

  • With VICTORY_WINDOW_SKIP_SAME=1, a rectangle of multicoloured noise covered a character's face.
  • Without it, the same face was drawn correctly.

It was one run each, so I can't rule out chance. The multicoloured confetti on skin that #333 seemed to bring varies between builds in the same way, and is being traced to ray-tracing programs reading leftover memory while the structure builder is off. Leaving pages out of windows could just change which leftover values they read. Either way, I put #340 back to draft for this (comment there) before it was merged here.

My Series S frame rates in #340 were also not valid: with --console series-s the 3D scene is black without AMD's FidelityFX DLL (VICTORY_FSR_DLL), see #338.

Suggestion: keep VICTORY_WINDOW_SKIP_SAME off in the launcher's set until a run with screen captures of faces (the cell and the diner in the first cutscene) shows them clean with it on. I'll post here when I have such a run.

🤖 Generated with Claude Code

**@⁠Skyfrye** on GitHub · 2026-11-26 14:28 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/358#issuecomment-7194861227) A picture problem with `VICTORY_WINDOW_SKIP_SAME=1`, which main's launcher now sets (`profiles.toml`, `run/settings.rs`). What I saw: same build (main c4c93bd + #308 + #340), same scene (the first cutscene, at the same point), Series X, `VICTORY_INDIRECT_RAW=3`, RTX 5080, screen captures every 15 s. - With `VICTORY_WINDOW_SKIP_SAME=1`, a rectangle of multicoloured noise covered a character's face. - Without it, the same face was drawn correctly. It was one run each, so I can't rule out chance. The multicoloured confetti on skin that #333 seemed to bring varies between builds in the same way, and is being traced to ray-tracing programs reading leftover memory while the structure builder is off. Leaving pages out of windows could just change which leftover values they read. Either way, I put #340 back to draft for this (comment there) before it was merged here. My Series S frame rates in #340 were also not valid: with `--console series-s` the 3D scene is black without AMD's FidelityFX DLL (`VICTORY_FSR_DLL`), see #338. Suggestion: keep `VICTORY_WINDOW_SKIP_SAME` off in the launcher's set until a run with screen captures of faces (the cell and the diner in the first cutscene) shows them clean with it on. I'll post here when I have such a run. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This discussion has been locked. Commenting is limited to contributors.
No description provided.