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

Closed
github-bot wants to merge 1 commit from github-bot/gh-361 into main AGit
Owner

@⁠Skyfrye on GitHub · 2026-11-26 13:05 UTC · original
Skyfrye:nep/refresh-spans-once → main · +94 −41 · 1 files · 1 commits · closed without merging

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

**@⁠Skyfrye** on GitHub · 2026-11-26 13:05 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/361) `Skyfrye:nep/refresh-spans-once` → `main` · +94 −41 · 1 files · 1 commits · closed without merging ## 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)
`Host::submit` walked every step of a submission's lists for the one
write-watch asking (`VICTORY_ASK_ONCE`) and, behind flights in the air,
again in `stale_under_flights`, which took each refreshed copy's lock
to ask whether shader writes were pending and searched the spans kept
so far for the copy, at every refreshed range: some 22,000 a frame in
the world of the title this fork works on. Both now take one
`RefreshSpans`, made in one pass: per copy the span of its refreshed
ranges in first-seen order (a copy found by its key), and the ranges of
windows in a GPU upload heap one by one, which `rebar_stale` judges each
on its own as before. Whether a copy has writes pending is asked once
per copy.

Same ranges asked, same answer.

From Antigravity (gemini-4-neon-medium), commit 22d77e4 of the
perf/submit-deferred-card branch, reduced to this change (keeping the
per-range check of upload-heap windows) and ported to main by Claude
Opus 5.5.

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

@⁠LooperSalty on GitHub · 2026-11-26 15:41 UTC · original

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

**@⁠LooperSalty** on GitHub · 2026-11-26 15:41 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/361#issuecomment-7196619620) 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)
github-bot closed this pull request 2026-11-26 16:06:38 +00:00
Author
Owner

@⁠Skyfrye on GitHub · 2026-11-26 16:02 UTC · original

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.)

**@⁠Skyfrye** on GitHub · 2026-11-26 16:02 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/361#issuecomment-7197098583) 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

This discussion has been locked. Commenting is limited to contributors.
No description provided.