perf: read the clock only for submission steps whose time is summed #279

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

@⁠Skyfrye on GitHub · 2026-11-26 00:13 UTC · original
Skyfrye:nep/step-clock → main · +106 −12 · 1 files · 2 commits · draft

Draft: the in-game A/B is pending (the change and its test are done; a measured run of the world with and without it is not).

Change

HostList::run_deferred (crates/victory-gpu/src/host.rs) read the clock (Instant::now) before every submission-time step of every list. Only two kinds of step use that time:

  • the title memory copies (Step::Copy, Step::Fill), summed into PREPARING[0] for the frame line;
  • with diagnostics, the title's work run at submission (Step::Run, Step::Host), summed into RunUs.

The others (Refresh, GpuWrite, Texture) only note what to do and continue before the time is used; they are most of a submission's steps. The clock is now read only for the first two (timed), and micros_since gives 0 where it was not read.

Where this comes from: a 30 s Nsight Systems capture of the world (release build of main at 3e258c8, launcher fast set, 263 frames). On the title's submitting thread, which spends 48 % of the time on the CPU in queue::execute, the innermost engine frame was Instant::now called from Host::submit (where run_deferred is inlined) on 2.8 % of the timer samples, and Instant::elapsed on 0.2 %. One QueryPerformanceCounter call measured 19 ns on this machine, so that is on the order of a million clock reads a second.

The frame line's sums do not change: the steps that were summed still are, with the same start and end.

Linked issue: none.

Verification

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

cargo build --locked --release -p victory                              -> Finished, no new warning
cargo build --locked --profile diag -p victory --features diagnostics  -> Finished, no new warning
cargo test --locked -p victory-gpu --lib -- host::tests::only_summed_steps_read_the_clock -> 1 passed
cargo test --locked -p victory-gpu --lib                               -> 184 passed, 3 failed, 3 ignored

The 3 failures are the same on main without this change (183 passed, 3 failed): 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.

New test only_summed_steps_read_the_clock: the copies are timed, the title's work only with diagnostics, and an unread clock counts 0 µs. (Refresh, GpuWrite and Texture need host objects made on a device; they take the false arm of the same match.) Without this change the test does not build, since timed and micros_since are new.

Pending: an A/B in the world (frame time; the submitting thread's share in Instant::now in a profile).

Oracle and test data

No game file. The profile numbers come from my own capture of my copy of the game; no game code, address or dump is in this PR.

Checklist

  • The PR covers a single reviewable behaviour (the clock is read only for steps whose time is summed).
  • A test fails without this change and passes with it (it does not build without it).
  • The commands and results of each check are given above (the in-game A/B is pending, said 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: engine function names from a profile of the engine; no title code.
  • Code taken from another project: none.

AI assistance: written with Claude Code. Claude Opus 5.5 read the Nsight Systems capture, wrote the change and its test, and wrote this description.

🤖 Generated with Claude Code

**@⁠Skyfrye** on GitHub · 2026-11-26 00:13 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/279) `Skyfrye:nep/step-clock` → `main` · +106 −12 · 1 files · 2 commits · draft **Draft: the in-game A/B is pending** (the change and its test are done; a measured run of the world with and without it is not). ## Change `HostList::run_deferred` (`crates/victory-gpu/src/host.rs`) read the clock (`Instant::now`) before every submission-time step of every list. Only two kinds of step use that time: - the title memory copies (`Step::Copy`, `Step::Fill`), summed into `PREPARING[0]` for the frame line; - with `diagnostics`, the title's work run at submission (`Step::Run`, `Step::Host`), summed into `RunUs`. The others (`Refresh`, `GpuWrite`, `Texture`) only note what to do and `continue` before the time is used; they are most of a submission's steps. The clock is now read only for the first two (`timed`), and `micros_since` gives 0 where it was not read. Where this comes from: a 30 s Nsight Systems capture of the world (release build of `main` at `3e258c8`, launcher fast set, 263 frames). On the title's submitting thread, which spends 48 % of the time on the CPU in `queue::execute`, the innermost engine frame was `Instant::now` called from `Host::submit` (where `run_deferred` is inlined) on 2.8 % of the timer samples, and `Instant::elapsed` on 0.2 %. One `QueryPerformanceCounter` call measured 19 ns on this machine, so that is on the order of a million clock reads a second. The frame line's sums do not change: the steps that were summed still are, with the same start and end. Linked issue: none. ## Verification Windows 11 26300, Rust 1.98.1 (MSVC), on upstream `main` at `578098b`, from `third_party/victory`: ``` cargo build --locked --release -p victory -> Finished, no new warning cargo build --locked --profile diag -p victory --features diagnostics -> Finished, no new warning cargo test --locked -p victory-gpu --lib -- host::tests::only_summed_steps_read_the_clock -> 1 passed cargo test --locked -p victory-gpu --lib -> 184 passed, 3 failed, 3 ignored ``` The 3 failures are the same on `main` without this change (183 passed, 3 failed): `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`. New test `only_summed_steps_read_the_clock`: the copies are timed, the title's work only with diagnostics, and an unread clock counts 0 µs. (`Refresh`, `GpuWrite` and `Texture` need host objects made on a device; they take the `false` arm of the same `match`.) Without this change the test does not build, since `timed` and `micros_since` are new. Pending: an A/B in the world (frame time; the submitting thread's share in `Instant::now` in a profile). ## Oracle and test data No game file. The profile numbers come from my own capture of my copy of the game; no game code, address or dump is in this PR. ## Checklist - [x] The PR covers a single reviewable behaviour (the clock is read only for steps whose time is summed). - [x] A test fails without this change and passes with it (it does not build without it). - [x] The commands and results of each check are given above (the in-game A/B is pending, said 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: engine function names from a profile of the engine; no title code. - [x] Code taken from another project: none. AI assistance: written with Claude Code. Claude Opus 5.5 read the Nsight Systems capture, wrote the change and its test, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`run_deferred` read the clock before every submission-time step, though
only the title memory copies (and, with diagnostics, the title's work run
at submission) use the time. Most steps are refreshes and textures that
only note what to do: in a 30 s Nsight Systems profile of the world the
clock was 2.8 % of the submitting thread's time.

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

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

Test report for #279 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 + #279
RTX 4060 Laptop 183 passed, main's 3 failed 184 passed, main's 3 failed
Intel UHD 183 passed, main's 3 failed 184 passed, main's 3 failed
WARP 196 passed, main's 3 failed 197 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. only_summed_steps_read_the_clock passes everywhere, both without and with diagnostics (WARP build). No new failure.

Note: timed matches every Step variant explicitly, so a new variant forces a decision. That's good. (#254 changes Step::Texture(_) to two fields, so whichever merges second needs Step::Texture(..) here.)

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/279#issuecomment-7189500388) Test report for #279 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 + #279 | |---|---|---| | RTX 4060 Laptop | 183 passed, main's 3 failed | 184 passed, main's 3 failed | | Intel UHD | 183 passed, main's 3 failed | 184 passed, main's 3 failed | | WARP | 196 passed, main's 3 failed | 197 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. `only_summed_steps_read_the_clock` passes everywhere, both without and with `diagnostics` (WARP build). No new failure. Note: `timed` matches every `Step` variant explicitly, so a new variant forces a decision. That's good. (#254 changes `Step::Texture(_)` to two fields, so whichever merges second needs `Step::Texture(..)` here.) _AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this._
github-bot force-pushed github-bot/gh-279 from f5430a2da3 to bf7196bf1b 2026-11-26 13:10:13 +00:00 Compare
Author
Owner

@⁠Skyfrye on GitHub · 2026-11-26 13:06 UTC · original

Rebased on main (8ed1109), plus one commit, bf7196b. It covers the timing of the same steps:

  • A run of upload fills is now timed once. That's some 9,700 fills a frame in the world, each under a microsecond; before, each read the clock twice and was counted as 0 µs.
  • A title copy is timed from after the flush that precedes it. The refreshes in that flush already count their own time.

The test only_summed_steps_read_the_clock covers FillTimer (cargo test --locked -p victory-gpu --lib only_summed_steps_read_the_clock -> 1 passed). The release build has no new warning. It was in the stacked game run described in #360: picture correct, no exception.

The fill timing comes from Antigravity (gemini-4-neon-medium), commit 22d77e4 of a local branch, ported by Claude Opus 5.5. A run of fills here also ends at a shader-write or texture step, because those do refresh work that is timed elsewhere.

🤖 Generated with Claude Code

**@⁠Skyfrye** on GitHub · 2026-11-26 13:06 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/279#issuecomment-7192875929) Rebased on `main` (8ed1109), plus one commit, bf7196b. It covers the timing of the same steps: - A run of upload fills is now timed once. That's some 9,700 fills a frame in the world, each under a microsecond; before, each read the clock twice and was counted as 0 µs. - A title copy is timed from after the flush that precedes it. The refreshes in that flush already count their own time. The test `only_summed_steps_read_the_clock` covers `FillTimer` (`cargo test --locked -p victory-gpu --lib only_summed_steps_read_the_clock` -> 1 passed). The release build has no new warning. It was in the stacked game run described in #360: picture correct, no exception. The fill timing comes from Antigravity (gemini-4-neon-medium), commit 22d77e4 of a local branch, ported by Claude Opus 5.5. A run of fills here also ends at a shader-write or texture step, because those do refresh work that is timed elsewhere. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request has changes conflicting with the target branch.
  • third_party/victory/crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/279/head:github-bot/gh-279'
git switch 'github-bot/gh-279'

Merge

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