Mixed refresh batches can finish waiting for one long texture task #1820

Closed
opened 2026-11-29 00:27:23 +00:00 by github-bot · 3 comments
Owner

@⁠NotADonky43 on GitHub · 2026-11-29 00:24 UTC · original

In a local Series X opening trace on an RTX 5070 Ti, texture refreshes accounted for ~61% of the exclusive last-task-class tail across 175 sampled mixed CPU batches; buffer copies accounted for most of the rest. Changes to write-watch locking alone did not improve frame tails here. Testing an opt-in choice of which independent texture job starts first, without moving work between batches or changing GPU uploads. Scope: host.rs / Batch::refresh_front. Related to #1298 but not the journal or copy-planning changes; source-only implementation and repeated A/B results to follow.

**@⁠NotADonky43** on GitHub · 2026-11-29 00:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/1820) In a local Series X opening trace on an RTX 5070 Ti, texture refreshes accounted for ~61% of the exclusive last-task-class tail across 175 sampled mixed CPU batches; buffer copies accounted for most of the rest. Changes to write-watch locking alone did not improve frame tails here. Testing an opt-in choice of which independent texture job starts first, without moving work between batches or changing GPU uploads. Scope: host.rs / Batch::refresh_front. Related to #1298 but not the journal or copy-planning changes; source-only implementation and repeated A/B results to follow.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 00:27:23 +00:00
Author
Owner

@⁠NotADonky43 on GitHub · 2026-11-29 00:24 UTC · original

/claim

**@⁠NotADonky43** on GitHub · 2026-11-29 00:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/1820#issuecomment-7248095381) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-29 00:24 UTC · original

Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

**@⁠github-actions[bot]** on GitHub · 2026-11-29 00:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/1820#issuecomment-7248096772) Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
Author
Owner

@⁠kalberts0089-hash on GitHub · 2026-11-29 08:00 UTC · original · edited 2026-11-29 08:19 UTC

The textures in a mixed refresh_front batch are still started in step order on main at e1f2eb6. I checked the code path and ran the scheduler with synthetic jobs on my machine. I can't run the game here, so these are not game numbers.

Code at e1f2eb6

  • crates/victory-gpu/src/host.rs:9086: refresh_front() is ahead_of_writes() && (VICTORY_JOIN_PARTS > 1 || VICTORY_REFRESH_FRONT). ahead_of_writes() (host.rs:9065-9068) is on unless VICTORY_REFRESH_AHEAD=0 or VICTORY_LIGHT_REFRESH=0 is set or wide refresh is off. Wide refresh is on by default with 4 or more logical CPUs. apps/victory/src/play.rs:58 sets VICTORY_JOIN_PARTS=8, so victory.exe takes this path by default.
  • host.rs:9436-9439: with wide_textures() on (the default), textures go into due in the order their Step::Texture appears. Nothing orders them by size.
  • host.rs:9476-9479: one wide_each_from(spans.len() + due.len(), due.len(), wide_chunk(), ...) call. Texture indices come before copy indices, so textures are claimed before copies. Among themselves, they run in step order.
  • shadow.rs:1990-1996: when VICTORY_WIDE_CHUNK is unset (chunk 1), this falls through to wide_each, which hands out indices in order from one shared counter. With a larger chunk, claim still hands textures out one at a time (shadow.rs:2025).
  • shadow.rs:1812: the pool is available_parallelism * 3/8, clamped to 2..8 helpers. On my 24-thread CPU that is 8 helpers plus the submitting thread, 9 in total.
  • The other path, Batch::refresh_textures (host.rs:9571-9581), only runs when refresh_front is off. It is a separate wide_each over the textures, and #1821 doesn't touch it.

#1821 on current main
The PR diff was written against the older wide_each(...) line. It still merges cleanly onto e1f2eb6. The reorder happens before the wide_each_from call, so it works alongside the VICTORY_WIDE_CHUNK change (7ab985d).

git merge --no-commit pr1821   -> Automatic merge went well (host.rs +34)
cargo test --locked -p victory-gpu --release --lib -- promote_one_refresh wide_chunk_tests front_spans batch
test host::promote_one_refresh_preserves_ties_and_all_other_jobs ... ok
test result: ok. 14 passed; 0 failed; 2 ignored

Scheduler probe (synthetic, busy-wait jobs)
I wrote a throwaway ignored test (local only, not part of the PR) that calls shadow::wide_each_from(tex + 200, tex, chunk, ..) with batches shaped like refresh_front:

  • one 4 ms "texture"
  • the other textures at 0.5 ms each
  • 200 "copies" at 20 µs each

It compares the long texture placed last against placed first. Each line is the median of 40 runs on a machine with 24 logical CPUs:

wide_threads+1 = 9
tex  4 chunk 1  long last: 4032 us   long first: 4027 us
tex  4 chunk 8  long last: 4033 us   long first: 4025 us
tex 16 chunk 1  long last: 4540 us   long first: 4026 us
tex 16 chunk 8  long last: 4543 us   long first: 4026 us
tex 32 chunk 1  long last: 5552 us   long first: 4033 us

A second run gave the same numbers within a few µs.

So moving the largest texture first only shortens the batch when there are more textures than pool threads (9 here). The gain is about the time the earlier textures take to drain before the long one gets a thread: 0.5 ms with 16 textures and 1.5 ms with 32. With no more textures than threads, every texture starts at once and the order makes no measurable difference. VICTORY_WIDE_CHUNK doesn't change this, because textures are claimed one at a time either way.

Two things that follow from the code (untested in game):

  • largest_first moves only one job to the front. If a batch has two long textures and more textures than threads, the second keeps its place in step order.
  • The size key is Staging::memory().1, the number of bytes of title memory read (crates/victory-gpu/src/texture.rs:1532). A texture whose memory hasn't changed may be cheap whatever its size, as the PR description already says.

To tell whether this matters in game, a useful number from the trace would be how many textures a mixed batch usually has compared with the machine's pool size.

**@⁠kalberts0089-hash** on GitHub · 2026-11-29 08:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/1820#issuecomment-7252830624) · edited 2026-11-29 08:19 UTC The textures in a mixed `refresh_front` batch are still started in step order on main at e1f2eb6. I checked the code path and ran the scheduler with synthetic jobs on my machine. I can't run the game here, so these are not game numbers. **Code at e1f2eb6** - `crates/victory-gpu/src/host.rs:9086`: `refresh_front()` is `ahead_of_writes() && (VICTORY_JOIN_PARTS > 1 || VICTORY_REFRESH_FRONT)`. `ahead_of_writes()` (`host.rs:9065-9068`) is on unless `VICTORY_REFRESH_AHEAD=0` or `VICTORY_LIGHT_REFRESH=0` is set or wide refresh is off. Wide refresh is on by default with 4 or more logical CPUs. `apps/victory/src/play.rs:58` sets `VICTORY_JOIN_PARTS=8`, so `victory.exe` takes this path by default. - `host.rs:9436-9439`: with `wide_textures()` on (the default), textures go into `due` in the order their `Step::Texture` appears. Nothing orders them by size. - `host.rs:9476-9479`: one `wide_each_from(spans.len() + due.len(), due.len(), wide_chunk(), ...)` call. Texture indices come before copy indices, so textures are claimed before copies. Among themselves, they run in step order. - `shadow.rs:1990-1996`: when `VICTORY_WIDE_CHUNK` is unset (chunk 1), this falls through to `wide_each`, which hands out indices in order from one shared counter. With a larger chunk, `claim` still hands textures out one at a time (`shadow.rs:2025`). - `shadow.rs:1812`: the pool is `available_parallelism * 3/8`, clamped to 2..8 helpers. On my 24-thread CPU that is 8 helpers plus the submitting thread, 9 in total. - The other path, `Batch::refresh_textures` (`host.rs:9571-9581`), only runs when `refresh_front` is off. It is a separate `wide_each` over the textures, and #1821 doesn't touch it. **#1821 on current main** The PR diff was written against the older `wide_each(...)` line. It still merges cleanly onto e1f2eb6. The reorder happens before the `wide_each_from` call, so it works alongside the `VICTORY_WIDE_CHUNK` change (7ab985d). ``` git merge --no-commit pr1821 -> Automatic merge went well (host.rs +34) cargo test --locked -p victory-gpu --release --lib -- promote_one_refresh wide_chunk_tests front_spans batch test host::promote_one_refresh_preserves_ties_and_all_other_jobs ... ok test result: ok. 14 passed; 0 failed; 2 ignored ``` **Scheduler probe (synthetic, busy-wait jobs)** I wrote a throwaway ignored test (local only, not part of the PR) that calls `shadow::wide_each_from(tex + 200, tex, chunk, ..)` with batches shaped like `refresh_front`: - one 4 ms "texture" - the other textures at 0.5 ms each - 200 "copies" at 20 µs each It compares the long texture placed last against placed first. Each line is the median of 40 runs on a machine with 24 logical CPUs: ``` wide_threads+1 = 9 tex 4 chunk 1 long last: 4032 us long first: 4027 us tex 4 chunk 8 long last: 4033 us long first: 4025 us tex 16 chunk 1 long last: 4540 us long first: 4026 us tex 16 chunk 8 long last: 4543 us long first: 4026 us tex 32 chunk 1 long last: 5552 us long first: 4033 us ``` A second run gave the same numbers within a few µs. So moving the largest texture first only shortens the batch when there are more textures than pool threads (9 here). The gain is about the time the earlier textures take to drain before the long one gets a thread: 0.5 ms with 16 textures and 1.5 ms with 32. With no more textures than threads, every texture starts at once and the order makes no measurable difference. `VICTORY_WIDE_CHUNK` doesn't change this, because textures are claimed one at a time either way. Two things that follow from the code (untested in game): - `largest_first` moves only one job to the front. If a batch has two long textures and more textures than threads, the second keeps its place in step order. - The size key is `Staging::memory().1`, the number of bytes of title memory read (`crates/victory-gpu/src/texture.rs:1532`). A texture whose memory hasn't changed may be cheap whatever its size, as the PR description already says. To tell whether this matters in game, a useful number from the trace would be how many textures a mixed batch usually has compared with the machine's pool size.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA#1820
No description provided.