Submit thread: fills split by bytes, journal skips writes overwritten in the same round (VICTORY_COPIES_FILLS_FAST, VICTORY_WATCH_FAST_JOURNAL) #4758

Closed
github-bot wants to merge 4 commits from github-bot/gh-4757 into main AGit
Owner

@⁠henriazz10 on GitHub · 2026-12-01 05:25 UTC · original
henriazz10:perf/copies-fills-watch-journal → main · +239 −18 · 4 files · 4 commits · closed without merging

What it changes

Two parts of the submit thread that grow with how much the title writes:

  • VICTORY_COPIES_FILLS_FAST=1 (host/send.rs, host.rs): splits the fills by bytes instead of by count across the workers, so one large fill no longer holds the others back. The CARDED lookup in send_copied is filtered to the range being sent.
  • VICTORY_WATCH_FAST_JOURNAL=1 (watch.rs, shadow.rs): Journal::note skips the BTreeMap writes that would be overwritten in the same round, through PageEpochs::swap.
  • Both are turned on in play.rs.

How it was tested

  • GPU and profile: RTX 5080 16 GB, Ryzen 9 5950X, 32 GB RAM, Windows 11; Series X profile, 1706×960 → 2560×1440, DLSS Quality, frame generation off, ray tracing off.
  • Bench: fixed in-game route, 120 s, 2 alternated runs, from the submit-thread sub-phase lines of victory.log: copies and fills 5.0 → 1.7 ms per frame, asking the write watch 4.7 → 4.4 ms. That run also carried other switches that were later dropped; with them, frame time was −9.4 % against v2026.11.30.03. These two switches, measured on their own sub-phases, account for about 3.6 ms of it.
  • Checks on Windows with the repo's toolchain (1.98.1), same commands as ci.yml: cargo build --release passes. cargo clippy --workspace --all-targets --locked -- -D warnings gives no new finding (it already fails on main, in the same 3 files). cargo test --workspace --locked: 2486 pass; modules::xmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_it fails on every branch of this set and on none of the files they touch, and host::uav_pool::tests::host_list_uav_pool_lifecycle_retire_trim_and_info_queue once in the full parallel run, and each passes when run alone (--exact); main itself fails host::refresh_tests::chunked_nothing_new_with_matches_individual in the same run. cargo fmt --check already reports hundreds of hunks per file on main; the new code follows the style of the code around it.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related, not duplicates: #3705 (refresh sift with a worker pool), #4572 (trims write-watch scans across scattered ranges), #4248, #4654, #4577, #3945, #3760, #3756, #2267.

AI-assisted. Neon (Gemini) wrote the change; Claude Code reviewed it, rebased it on main, built it, ran the checks and measured it.

🤖 Generated with Claude Code

**@⁠henriazz10** on GitHub · 2026-12-01 05:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4757) `henriazz10:perf/copies-fills-watch-journal` → `main` · +239 −18 · 4 files · 4 commits · closed without merging <!-- Thanks for the pull request. Please label it (pr-fix, pr-feature, pr-performance, pr-diagnostics, pr-refactor, pr-docs or pr-tests, plus the area labels), or put the label in the title, like [pr-fix]. --> ## What it changes Two parts of the submit thread that grow with how much the title writes: - `VICTORY_COPIES_FILLS_FAST=1` (`host/send.rs`, `host.rs`): splits the fills by bytes instead of by count across the workers, so one large fill no longer holds the others back. The `CARDED` lookup in `send_copied` is filtered to the range being sent. - `VICTORY_WATCH_FAST_JOURNAL=1` (`watch.rs`, `shadow.rs`): `Journal::note` skips the `BTreeMap` writes that would be overwritten in the same round, through `PageEpochs::swap`. - Both are turned on in `play.rs`. ## How it was tested - GPU and profile: RTX 5080 16 GB, Ryzen 9 5950X, 32 GB RAM, Windows 11; Series X profile, 1706×960 → 2560×1440, DLSS Quality, frame generation off, ray tracing off. - Bench: fixed in-game route, 120 s, 2 alternated runs, from the submit-thread sub-phase lines of `victory.log`: `copies and fills` **5.0 → 1.7 ms per frame**, `asking the write watch` 4.7 → 4.4 ms. That run also carried other switches that were later dropped; with them, frame time was −9.4 % against `v2026.11.30.03`. These two switches, measured on their own sub-phases, account for about 3.6 ms of it. - Checks on Windows with the repo's toolchain (1.98.1), same commands as `ci.yml`: `cargo build --release` passes. `cargo clippy --workspace --all-targets --locked -- -D warnings` gives no new finding (it already fails on `main`, in the same 3 files). `cargo test --workspace --locked`: 2486 pass; `modules::xmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_it` fails on every branch of this set and on none of the files they touch, and `host::uav_pool::tests::host_list_uav_pool_lifecycle_retire_trim_and_info_queue` once in the full parallel run, and each passes when run alone (`--exact`); `main` itself fails `host::refresh_tests::chunked_nothing_new_with_matches_individual` in the same run. `cargo fmt --check` already reports hundreds of hunks per file on `main`; the new code follows the style of the code around it. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related, not duplicates: #3705 (refresh sift with a worker pool), #4572 (trims write-watch scans across scattered ranges), #4248, #4654, #4577, #3945, #3760, #3756, #2267. AI-assisted. Neon (Gemini) wrote the change; Claude Code reviewed it, rebased it on `main`, built it, ran the checks and measured it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Targets 'copies and fills' (4.9 ms in c2-rel1130b-mf) behind
VICTORY_COPIES_FILLS_FAST=1 (off by default):
- Parallelizes Batch::fill() when fills.len() >= 96 or total_bytes >= 256 KiB,
  splitting fills > 128 KiB into disjoint 128 KiB chunks across
  shadow::wide_each_scoped.
- Stores immutable (start, end) bounds alongside Weak<Shadow> in CARDED so
  shadow::send_copied() only calls Weak::upgrade() on overlapping shadows
  (0-2 instead of ~3,900) and skips pending/outside allocation when
  has_pending is false.
- Resets Step::Placed timer after batch.fill()/title_written() to stop
  double-counting into SPLIT[7].

(cherry picked from commit 2a992c7180980106a662a26fd6497a1db3cd9024)
Targets 'asking the write watch' (4.6 ms in c2-rel1130b-mf) behind
VICTORY_WATCH_FAST_JOURNAL=1 (off by default):
- Adds PageEpochs::swap() so Journal::note() updates WRITTEN_EPOCHS directly
  under the exclusive JOURNAL write lock without inserting thousands of pages
  per frame into the unread BTreeMap Journal::written.
- Adds PageEpochs::all_within_slice() so new_in() (VICTORY_NEW_BATCH=1) reads
  WRITTEN_EPOCHS consistently.
- Honors VICTORY_AHEAD_GAP_KB (ahead_gap()) in ask_once().

(cherry picked from commit 7d0fdf423d83b70f3dcbf64e24cfb19e049ffd0c)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 05:29:16 +00:00
Author
Owner

@⁠IRennie74 on GitHub · 2026-12-01 06:28 UTC · original

Some notes from reading the diff.

VICTORY_WATCH_FAST_JOURNAL also changes ask_once: its join gap becomes ahead_gap() instead of AHEAD_GAP. By default that's the same 8 MiB, but VICTORY_AHEAD_GAP_KB then sets the gap for ask_once too, not only for the flush path. The PR description doesn't mention this, and the switch's name doesn't suggest it. #4572 edits the same ask_once loop and deliberately keeps the two apart (VICTORY_ASK_ONCE_GAP_KB for ask_once, while VICTORY_AHEAD_GAP_KB "continues to govern its own path"). The two will conflict there, and it's unclear which behaviour is intended. Leaving that hunk out would keep this PR to the journal.

I checked the journal part and found no problem. Journal::note is the only writer of WRITTEN_EPOCHS and runs under the journal's write lock, so swap's plain load-then-store is safe. asked, writes and writes_since already read WRITTEN_EPOCHS when sync_epochs is set, and new_in was the one reader still walking written, which the PR covers. Pages past MAX_PAGES still go to the map, as before.

For scale on a smaller CPU: on a Ryzen 5 5600X with an RTX 3060 (Series S, DLSS Performance, standing), "copies and fills" is about 4 ms and "asking the write watch" 3-4 ms of the submitting thread's roughly 47 ms. That thread is the bottleneck there. The 5.0 -> 1.7 ms here is a sub-phase figure from one run with other switches present. A frame-time A/B with only these two switches would tell how much reaches the frame.

**@⁠IRennie74** on GitHub · 2026-12-01 06:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4757#issuecomment-7302916210) Some notes from reading the diff. `VICTORY_WATCH_FAST_JOURNAL` also changes `ask_once`: its join gap becomes `ahead_gap()` instead of `AHEAD_GAP`. By default that's the same 8 MiB, but `VICTORY_AHEAD_GAP_KB` then sets the gap for `ask_once` too, not only for the flush path. The PR description doesn't mention this, and the switch's name doesn't suggest it. #4572 edits the same `ask_once` loop and deliberately keeps the two apart (`VICTORY_ASK_ONCE_GAP_KB` for `ask_once`, while `VICTORY_AHEAD_GAP_KB` "continues to govern its own path"). The two will conflict there, and it's unclear which behaviour is intended. Leaving that hunk out would keep this PR to the journal. I checked the journal part and found no problem. `Journal::note` is the only writer of `WRITTEN_EPOCHS` and runs under the journal's write lock, so `swap`'s plain load-then-store is safe. `asked`, `writes` and `writes_since` already read `WRITTEN_EPOCHS` when `sync_epochs` is set, and `new_in` was the one reader still walking `written`, which the PR covers. Pages past `MAX_PAGES` still go to the map, as before. For scale on a smaller CPU: on a Ryzen 5 5600X with an RTX 3060 (Series S, DLSS Performance, standing), "copies and fills" is about 4 ms and "asking the write watch" 3-4 ms of the submitting thread's roughly 47 ms. That thread is the bottleneck there. The 5.0 -> 1.7 ms here is a sub-phase figure from one run with other switches present. A frame-time A/B with only these two switches would tell how much reaches the frame.
Author
Owner

@⁠DoubleD17 on GitHub · 2026-12-01 10:51 UTC · original

A measurement of this PR on an 8-core CPU, in case it helps.

Setup

  • Hardware: RTX 5070 12 GB (driver 621.40), Ryzen 7 5800X (8 cores, 16 threads), 64 GB RAM, Windows 11.
  • Build: one release build, main 5fabb46e with this PR and #4775 merged. The only conflict was the play.rs defaults block, where both sets were kept.
  • Arms: every run passes all four switches by --set, so the arms differ only by them:
    • control: all 0;
    • this PR: VICTORY_COPIES_FILLS_FAST=1 and VICTORY_WATCH_FAST_JOURNAL=1, #4775's two at 0.
  • Profile: Series X, 2560x1440 DLAA, frame generation off, ray tracing off.
  • Runs: idle camera from the same starting point, 150 s from the first world frame, four runs per arm, alternated with a third arm (#4775, reported there). Each run ends with 200 frames captured at 10 a second.

Submitting thread, per frame (the "preparing per frame, the submitting thread" line, mean of each run's 150 s):

control (4 runs) this PR (4 runs)
copies and fills 3.63 ms (3.33 to 3.78) 1.83 ms (1.75 to 1.90)
asking the write watch 5.08 ms 4.88 ms
refreshes 20.50 ms 20.00 ms
in its submissions 57.3 ms (53.8 to 60.5) 54.7 ms (52.5 to 58.0)
  • "Copies and fills" halves in every run: the slowest run with this PR is under the fastest control run.
  • Frame rate: base fps mean 16.29 (control) against 16.95 (this PR).
    • On the light view only (the seconds where the idle camera's heavier view is not on screen), preparation is -1.1 ms and fps +1.9 %.
    • That is inside our control spread (2.4 ms), so four runs resolve the sub-phase cut but not a frame-rate gain on this PC.

Picture: 800 frames per arm; we looked at every frame a frame-to-frame check flagged.

  • With this PR, one frame was flagged: distant foliage missing for one frame.
  • We see that one-frame vegetation gap on main as well, so it is not from this change.

Not tested:

  • VICTORY_AHEAD_GAP_KB / ask_once (the point raised above).
  • Movement (idle camera only), Series S, frame generation on, other cards.

AI Assisted

**@⁠DoubleD17** on GitHub · 2026-12-01 10:51 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4757#issuecomment-7308817128) A measurement of this PR on an 8-core CPU, in case it helps. **Setup** - **Hardware:** RTX 5070 12 GB (driver 621.40), Ryzen 7 5800X (8 cores, 16 threads), 64 GB RAM, Windows 11. - **Build:** one release build, main 5fabb46e with this PR and #4775 merged. The only conflict was the `play.rs` defaults block, where both sets were kept. - **Arms:** every run passes all four switches by `--set`, so the arms differ only by them: - control: all `0`; - this PR: `VICTORY_COPIES_FILLS_FAST=1` and `VICTORY_WATCH_FAST_JOURNAL=1`, #4775's two at `0`. - **Profile:** Series X, 2560x1440 DLAA, frame generation off, ray tracing off. - **Runs:** idle camera from the same starting point, 150 s from the first world frame, four runs per arm, alternated with a third arm (#4775, reported there). Each run ends with 200 frames captured at 10 a second. **Submitting thread, per frame** (the "preparing per frame, the submitting thread" line, mean of each run's 150 s): | | control (4 runs) | this PR (4 runs) | |---|---|---| | copies and fills | 3.63 ms (3.33 to 3.78) | **1.83 ms** (1.75 to 1.90) | | asking the write watch | 5.08 ms | 4.88 ms | | refreshes | 20.50 ms | 20.00 ms | | in its submissions | 57.3 ms (53.8 to 60.5) | 54.7 ms (52.5 to 58.0) | - "Copies and fills" halves in every run: the slowest run with this PR is under the fastest control run. - **Frame rate:** base fps mean 16.29 (control) against 16.95 (this PR). - On the light view only (the seconds where the idle camera's heavier view is not on screen), preparation is -1.1 ms and fps +1.9 %. - That is inside our control spread (2.4 ms), so four runs resolve the sub-phase cut but not a frame-rate gain on this PC. **Picture:** 800 frames per arm; we looked at every frame a frame-to-frame check flagged. - With this PR, one frame was flagged: distant foliage missing for one frame. - We see that one-frame vegetation gap on main as well, so it is not from this change. **Not tested:** - `VICTORY_AHEAD_GAP_KB` / `ask_once` (the point raised above). - Movement (idle camera only), Series S, frame generation on, other cards. AI Assisted
Author
Owner

@⁠korbannour578-alt on GitHub · 2026-12-01 12:05 UTC · original

Test result on an RTX 4060 Laptop 8 GB (i7-13620H 6P+4E, 32 GB RAM, NVIDIA 610.78), Series S profile, build 5fabb46e + the warpGTAIV/VIctory-8GB small-card policy.

I applied #4758 and #3958 together (one build, so I can't split the effect between them), with COPIES_FILLS_FAST, WATCH_FAST_JOURNAL, SUBMIT_SPLIT=1 and OFF_LINE=1 set.

  • fps went down: 9-11 fps driving vs ~11.4 before
  • preparing time on the submit thread went up: 40-50 ms/frame vs ~33 ms before
  • a brown patch/wall appeared over the road while driving (not seen without these changes)

So on this laptop it was a regression and I reverted it. Happy to test one PR at a time if that helps narrow it down.

Full laptop report: #4868

**@⁠korbannour578-alt** on GitHub · 2026-12-01 12:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4757#issuecomment-7310643641) Test result on an RTX 4060 Laptop 8 GB (i7-13620H 6P+4E, 32 GB RAM, NVIDIA 610.78), Series S profile, build 5fabb46e + the warpGTAIV/VIctory-8GB small-card policy. I applied #4758 and #3958 together (one build, so I can't split the effect between them), with COPIES_FILLS_FAST, WATCH_FAST_JOURNAL, SUBMIT_SPLIT=1 and OFF_LINE=1 set. - fps went **down**: 9-11 fps driving vs ~11.4 before - preparing time on the submit thread went **up**: 40-50 ms/frame vs ~33 ms before - a brown patch/wall appeared over the road while driving (not seen without these changes) So on this laptop it was a regression and I reverted it. Happy to test one PR at a time if that helps narrow it down. Full laptop report: #4868
github-bot closed this pull request 2026-12-01 18:36:40 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:33 UTC · original

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.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:33 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4757#issuecomment-7321126060) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!4758
No description provided.