Write watch: a submission's askings spread over threads (VICTORY_SUBMIT_PARALLEL=<n>, opt-in) #4576

Closed
Mikey970 wants to merge 14 commits from upstream-pr/4576 into main
Mikey970 commented 2026-11-30 23:01:05 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Mikey970 on 2026-11-30T23:01:05Z.


[pr-performance] opt-in, off by default.

What it changes

VICTORY_SUBMIT_PARALLEL=<n> (unset, 0 or 1: off; at most 16). With it, a submission's one write-watch asking (watch::ask_once, and ask_rest after ask_first/ask_more) is spread over n threads, the asking one among them:

  • ask_once: its runs are cut into disjoint parts (split_runs: at piece boundaries; a piece longer than a thread's share, at least 16 MiB, cut into shares; pages an earlier piece covers left to that one, so no page is asked twice). The parts are asked at once on a small pool (victory-split, land::each_split), longest first, each by ask_run_all, and the answers joined in address order before the journal is told, as one thread would tell it. Pages in the gaps between two parts are not asked (they are not put in ahead, so writes asks about them later, as for any page no run covers).
  • ask_rest: its merged groups (already disjoint) are asked on the pool, each exactly as the loop asked it (the group, then its pieces if refused; the body moved into ask_alone), joined in order.
  • The threads kept for refreshes (shadow::wide_threads) are at least n-1 helpers unless VICTORY_WIDE_THREADS is set.
  • Frame line when used: write watch asked on several threads per frame (VICTORY_SUBMIT_PARALLEL=n): ... askings in ... parts, ... ms waited for them.

Unset, the code paths are the ones on main (the only change is ask_rest's loop body moved into a function).

Why: on our runs the submitting thread spent ~6 ms a frame (10-13 ms in heavy seconds) in GetWriteWatch with reset, one run after another.

How it was tested

All in-game numbers below are from our fork's build of the same change (not yet run in-game from this branch on main), on one PC: RTX 4080, Ryzen 7 9800X3D, Series X profile 1440p -> 4K DLSS, DLSS frame generation on.

  • Before: bench 26.5 rendered fps, heavy scenes 22.1.
  • After (VICTORY_SUBMIT_PARALLEL set; benches R112/R113): 31.1 rendered fps (+17%), heavy scenes 25.1 (+14%). Without frame generation: 31.9 vs 31.0. Captured frames correct, no errors in the logs.
  • Micro-benchmark (standalone, 4 GiB in 16 write-watched reservations, GetWriteWatch with reset over all of it): 1 thread 3.8 ms, 8 threads 2.2 ms; with 6 other busy threads in the process 8.6 ms vs 2.5 ms (x3.4). The kernel does not serialize resetting askings across threads on this machine.
  • For shader changes: none.
  • cargo test for the crate it touches: the three new tests in watch::split_tests (part splitting is disjoint, in address order, covers every page once incl. overlapping pieces; runs asked on threads find exactly what one thread finds, joined in order; ask_rest groups incl. a refused one asked as one thread asks them) pass (5 repeated runs), plus the existing watch:: (72) and land:: tests, also with VICTORY_SUBMIT_PARALLEL=4 set; cargo clippy -p victory-gpu --all-targets adds no warnings (the 2 it reports are on main already).

Risks: the extra threads compete with the title's threads for cores (that is why it is opt-in); how the kernel's resetting GetWriteWatch (TLB flushes) scales across threads may differ by CPU, Windows build and Wine/Proton.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #4489 (VICTORY_SUBMIT_PIPE, the opposite approach: one collector thread serialising all askings, on the premise that concurrent resetting askings contend in the kernel; our measurement above found they scale here), #4395 (VICTORY_ASK_BY_RES, cuts askings at reservation boundaries; composes with this), #2647 (scratch reuse in asking). None asks a submission's askings in parallel.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5575351378 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4576). Originally posted by [Mikey970](https://github.com/Mikey970) on 2026-11-30T23:01:05Z. --- [pr-performance] opt-in, off by default. ## What it changes `VICTORY_SUBMIT_PARALLEL=<n>` (unset, 0 or 1: off; at most 16). With it, a submission's one write-watch asking (`watch::ask_once`, and `ask_rest` after `ask_first`/`ask_more`) is spread over n threads, the asking one among them: - `ask_once`: its runs are cut into disjoint parts (`split_runs`: at piece boundaries; a piece longer than a thread's share, at least 16 MiB, cut into shares; pages an earlier piece covers left to that one, so no page is asked twice). The parts are asked at once on a small pool (`victory-split`, `land::each_split`), longest first, each by `ask_run_all`, and the answers joined in address order before the journal is told, as one thread would tell it. Pages in the gaps between two parts are not asked (they are not put in `ahead`, so `writes` asks about them later, as for any page no run covers). - `ask_rest`: its merged groups (already disjoint) are asked on the pool, each exactly as the loop asked it (the group, then its pieces if refused; the body moved into `ask_alone`), joined in order. - The threads kept for refreshes (`shadow::wide_threads`) are at least n-1 helpers unless `VICTORY_WIDE_THREADS` is set. - Frame line when used: `write watch asked on several threads per frame (VICTORY_SUBMIT_PARALLEL=n): ... askings in ... parts, ... ms waited for them`. Unset, the code paths are the ones on main (the only change is `ask_rest`'s loop body moved into a function). Why: on our runs the submitting thread spent ~6 ms a frame (10-13 ms in heavy seconds) in `GetWriteWatch` with reset, one run after another. ## How it was tested All in-game numbers below are from our fork's build of the same change (not yet run in-game from this branch on main), on one PC: RTX 4080, Ryzen 7 9800X3D, Series X profile 1440p -> 4K DLSS, DLSS frame generation on. - Before: bench 26.5 rendered fps, heavy scenes 22.1. - After (`VICTORY_SUBMIT_PARALLEL` set; benches R112/R113): 31.1 rendered fps (+17%), heavy scenes 25.1 (+14%). Without frame generation: 31.9 vs 31.0. Captured frames correct, no errors in the logs. - Micro-benchmark (standalone, 4 GiB in 16 write-watched reservations, `GetWriteWatch` with reset over all of it): 1 thread 3.8 ms, 8 threads 2.2 ms; with 6 other busy threads in the process 8.6 ms vs 2.5 ms (x3.4). The kernel does not serialize resetting askings across threads on this machine. - For shader changes: none. - `cargo test` for the crate it touches: the three new tests in `watch::split_tests` (part splitting is disjoint, in address order, covers every page once incl. overlapping pieces; runs asked on threads find exactly what one thread finds, joined in order; `ask_rest` groups incl. a refused one asked as one thread asks them) pass (5 repeated runs), plus the existing `watch::` (72) and `land::` tests, also with `VICTORY_SUBMIT_PARALLEL=4` set; `cargo clippy -p victory-gpu --all-targets` adds no warnings (the 2 it reports are on main already). Risks: the extra threads compete with the title's threads for cores (that is why it is opt-in); how the kernel's resetting `GetWriteWatch` (TLB flushes) scales across threads may differ by CPU, Windows build and Wine/Proton. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #4489 (`VICTORY_SUBMIT_PIPE`, the opposite approach: one collector thread serialising all askings, on the premise that concurrent resetting askings contend in the kernel; our measurement above found they scale here), #4395 (`VICTORY_ASK_BY_RES`, cuts askings at reservation boundaries; composes with this), #2647 (scratch reuse in asking). None asks a submission's askings in parallel. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
trustno1-coder commented 2026-12-01 18:37:30 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:37:30Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321236756 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4576#issuecomment-7321236756). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:37:30Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

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
trustno1-coder/VIctory-NVIDIA!4576
No description provided.