perf: one pass over a submission's refreshes for the write-watch asking and the check behind flights #361

Closed
Skyfrye wants to merge 1 commit from upstream-pr/361 into main
Skyfrye commented 2026-11-26 13:05:42 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Skyfrye on 2026-11-26T13:05:42Z.


Change

Host::submit walked every step of a submission's lists twice:

  • once for the single write-watch asking (VICTORY_ASK_ONCE);
  • again, behind flights in the air, in stale_under_flights. At every refreshed range (about 22,000 a frame in the world of the title this fork works on), it took the copy's lock to ask whether shader writes were pending, then searched the spans kept so far for that copy.

Both now share one RefreshSpans, built in a single pass:

  • Per copy, the span of its refreshed ranges, in first-seen order. A copy is found by its key.
  • Windows in a GPU upload heap keep their ranges one by one, so rebar_stale still judges each range on its own, as before.
  • Whether a copy has writes pending is asked once per copy.

The ranges asked about and the answer are the same.

Supersedes nothing open. Related: #279 (clock reads in the same loop).

Linked issue: none.

Verification

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

cargo build --locked --release -p victory                         -> Finished; the 2 warnings main has, no new one
cargo test --locked -p victory-gpu --lib refresh_spans_tests        -> 1 passed

refreshes_join_per_copy_in_first_seen_order checks one span per copy, in first-seen order, covering all of the copy's ranges. It does not build without the change.

In the world, my copy of the game, Series X, VICTORY_INDIRECT_RAW=3, the launcher's switches (VICTORY_WIDE_REFRESH=1 among them): one run of 300 s with this PR stacked with the other parts of the same split (#360, #361, #362) and #278, #279, #291, #292, #307, on main at 8ed1109.

  • The picture: checked by screen captures every 15 s. The prison cutscene, the cell and the corridor are drawn as on main. There was no exception and no device lost.
  • Frame rate: a median of 13.2 fps over the last 3 minutes, against 12.6 to 12.8 in earlier runs of main-like builds. That run got further into the story (the corridor, about 6,300 draws a frame), and the machine was about 60 % loaded by other work, so the difference is within what separates two runs here.
  • An earlier build with all of commit 22d77e4 (texture refreshes on the wide threads too, which this split leaves out; see #362) ran at 15.5 fps against 12.6 to 12.8.
  • No separate run per PR. These parts take CPU time off the submitting thread. I did not measure each on its own.

Oracle and test data

No game file.

Checklist

  • The PR covers a single reviewable behaviour: one pass over a submission's refreshes, shared by the asking and the check behind flights.
  • A test fails without this change and passes with it (the test does not build without 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: step counts only; no title code.
  • Code taken from another project: none. The code comes from a commit made with Antigravity in this fork's work (see below).

AI assistance: written with Antigravity (Google's AI IDE, model gemini-4-neon-medium) in commit 22d77e4 of a local branch. Claude Opus 5.5, in Claude Code, reduced it to this change and ported it to main. It also kept the per-range check of upload-heap windows, which a separate Claude Opus 5.5 review of 22d77e4 found had become per-copy. It ran the checks and the game, and wrote this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:6627285698 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/361). Originally posted by [Skyfrye](https://github.com/Skyfrye) on 2026-11-26T13:05:42Z. --- ## Change `Host::submit` walked every step of a submission's lists twice: - once for the single write-watch asking (`VICTORY_ASK_ONCE`); - again, behind flights in the air, in `stale_under_flights`. At every refreshed range (about 22,000 a frame in the world of the title this fork works on), it took the copy's lock to ask whether shader writes were pending, then searched the spans kept so far for that copy. Both now share one `RefreshSpans`, built in a single pass: - Per copy, the span of its refreshed ranges, in first-seen order. A copy is found by its key. - Windows in a GPU upload heap keep their ranges one by one, so `rebar_stale` still judges each range on its own, as before. - Whether a copy has writes pending is asked once per copy. The ranges asked about and the answer are the same. Supersedes nothing open. Related: #279 (clock reads in the same loop). Linked issue: none. ## Verification Windows 11 26300, Rust 1.98.1 (MSVC), on upstream `main` at `8ed1109`, from `third_party/victory`: ``` cargo build --locked --release -p victory -> Finished; the 2 warnings main has, no new one cargo test --locked -p victory-gpu --lib refresh_spans_tests -> 1 passed ``` `refreshes_join_per_copy_in_first_seen_order` checks one span per copy, in first-seen order, covering all of the copy's ranges. It does not build without the change. In the world, my copy of the game, Series X, `VICTORY_INDIRECT_RAW=3`, the launcher's switches (`VICTORY_WIDE_REFRESH=1` among them): one run of 300 s with this PR stacked with the other parts of the same split (#360, #361, #362) and #278, #279, #291, #292, #307, on `main` at `8ed1109`. - **The picture:** checked by screen captures every 15 s. The prison cutscene, the cell and the corridor are drawn as on `main`. There was no exception and no device lost. - **Frame rate:** a median of 13.2 fps over the last 3 minutes, against 12.6 to 12.8 in earlier runs of main-like builds. That run got further into the story (the corridor, about 6,300 draws a frame), and the machine was about 60 % loaded by other work, so the difference is within what separates two runs here. - **An earlier build** with all of commit 22d77e4 (texture refreshes on the wide threads too, which this split leaves out; see #362) ran at 15.5 fps against 12.6 to 12.8. - **No separate run per PR.** These parts take CPU time off the submitting thread. I did not measure each on its own. ## Oracle and test data No game file. ## Checklist - [x] The PR covers a single reviewable behaviour: one pass over a submission's refreshes, shared by the asking and the check behind flights. - [x] A test fails without this change and passes with it (the test does not build without 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: step counts only; no title code. - [x] Code taken from another project: none. The code comes from a commit made with Antigravity in this fork's work (see below). AI assistance: written with Antigravity (Google's AI IDE, model gemini-4-neon-medium) in commit 22d77e4 of a local branch. Claude Opus 5.5, in Claude Code, reduced it to this change and ported it to `main`. It also kept the per-range check of upload-heap windows, which a separate Claude Opus 5.5 review of 22d77e4 found had become per-copy. It ran the checks and the game, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
LooperSalty commented 2026-11-26 15:41:33 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-26T15:41:33Z.


This PR now conflicts with main in third_party/victory/crates/victory-gpu/src/host.rs (main moved with #358, #377 and #386). Please rebase on main, re-run the victory-gpu tests and force-push your branch.

🤖 Generated with Claude Code

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7196619620 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/361#issuecomment-7196619620). Originally posted by [LooperSalty](https://github.com/LooperSalty) on 2026-11-26T15:41:33Z. --- This PR now conflicts with main in `third_party/victory/crates/victory-gpu/src/host.rs` (main moved with #358, #377 and #386). Please rebase on main, re-run the victory-gpu tests and force-push your branch. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Skyfrye commented 2026-11-26 16:02:29 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Skyfrye on 2026-11-26T16:02:29Z.


Closing: #383 covers this. Its pending_spans_by_index (behind VICTORY_STEP_INDEX, which #386 turns on by default) does what RefreshSpans did inside stale_under_flights: it asks writes_pending() once per copy instead of at every refresh step, and finds a copy's span through a HashMap keyed by the copy's address instead of searching the spans kept so far. What is left here is only sharing one walk of the steps between the VICTORY_ASK_ONCE spans and stale_under_flights. With #383's index the extra walk costs a pointer compare and a flag read per step, which is not worth a PR of its own without a profile showing it. (Checked with Claude Opus 5.5.)

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7197098583 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/361#issuecomment-7197098583). Originally posted by [Skyfrye](https://github.com/Skyfrye) on 2026-11-26T16:02:29Z. --- Closing: #383 covers this. Its `pending_spans_by_index` (behind `VICTORY_STEP_INDEX`, which #386 turns on by default) does what `RefreshSpans` did inside `stale_under_flights`: it asks `writes_pending()` once per copy instead of at every refresh step, and finds a copy's span through a `HashMap` keyed by the copy's address instead of searching the spans kept so far. What is left here is only sharing one walk of the steps between the `VICTORY_ASK_ONCE` spans and `stale_under_flights`. With #383's index the extra walk costs a pointer compare and a flag read per step, which is not worth a PR of its own without a profile showing it. (Checked with Claude Opus 5.5.)

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LooperSalty/AnyXboxX!361
No description provided.