Refreshes: no-op spans dropped before they are queued, clean spans sifted before the per-span lock (VICTORY_FLUSH_FAST_NOOP, _V2) #4774

Closed
henriazz10 wants to merge 3 commits from upstream-pr/4774 into main
henriazz10 commented 2026-12-01 07:23:57 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by henriazz10 on 2026-12-01T07:23:57Z.


What it changes

Refreshes are the largest part of the submit thread: about 28–32 ms of a 60 ms preparation per frame in our logs, and about 92 % of the spans they walk change nothing (no-op). Each no-op still paid for an ahead snapshot, an OWNED read lock and a tell_watch per span.

  • VICTORY_FLUSH_FAST_NOOP=1: caches the ahead snapshot once per submission and drops no-op spans early in Batch::add, before they are queued.
  • VICTORY_FLUSH_FAST_NOOP_V2=1: in flush_all, sifts the clean spans first (owned_snap, ahead_contains first, last_clean), so the per-span OWNED lock and tell_watch are skipped for them. It also fixes the merge of disjoint intervals in Batch::add, which could join two ranges that do not touch.
  • Both are turned on in play.rs. A span that does change takes the same path as before.

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, measured from victory.log after a 20 s warm-up and compared at matched scene load (42–56k thin calls per frame), with the same build switching only these settings:
    • FLUSH_FAST_NOOP=1: submit-thread preparation −7.3 % at matched load (−8.7 % inside the load band), 2 alternated runs per config.
    • FLUSH_FAST_NOOP_V2=1 on top: a further −4.8 % (1 run), and −13 % together with another switch that turned out to do nothing in that run, which makes it effectively V2 alone. In fps, about 13.1 → 15.3 at matched load.
  • Real play with this and the other changes of this set (texture queue, sub-range copy-back, fills and journal; each in its own pull request) against v2026.11.30.03, same route: frame time at matched load 75.3 → 70.6 ms; submit-thread preparation 70.7 → 65.4 ms (−7.5 %).
  • 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: 2488 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 console_insn::tests::clzero_on_a_guarded_line_goes_through_the_guard 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: #4294 (skips the stale-page walk for ranges with no journal writes), #4042 (skips Does::Refresh without copies), #4532 (caches watch::ahead per generation), #4422, #3958.

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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5581047942 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4774). Originally posted by [henriazz10](https://github.com/henriazz10) on 2026-12-01T07:23:57Z. --- <!-- 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 Refreshes are the largest part of the submit thread: about 28–32 ms of a 60 ms preparation per frame in our logs, and about 92 % of the spans they walk change nothing (no-op). Each no-op still paid for an ahead snapshot, an `OWNED` read lock and a `tell_watch` per span. - `VICTORY_FLUSH_FAST_NOOP=1`: caches the ahead snapshot once per submission and drops no-op spans early in `Batch::add`, before they are queued. - `VICTORY_FLUSH_FAST_NOOP_V2=1`: in `flush_all`, sifts the clean spans first (`owned_snap`, `ahead_contains` first, `last_clean`), so the per-span `OWNED` lock and `tell_watch` are skipped for them. It also fixes the merge of disjoint intervals in `Batch::add`, which could join two ranges that do not touch. - Both are turned on in `play.rs`. A span that does change takes the same path as before. ## 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, measured from `victory.log` after a 20 s warm-up and compared at matched scene load (42–56k thin calls per frame), with the same build switching only these settings: - `FLUSH_FAST_NOOP=1`: submit-thread preparation **−7.3 %** at matched load (−8.7 % inside the load band), 2 alternated runs per config. - `FLUSH_FAST_NOOP_V2=1` on top: a further **−4.8 %** (1 run), and **−13 %** together with another switch that turned out to do nothing in that run, which makes it effectively V2 alone. In fps, about 13.1 → 15.3 at matched load. - Real play with this and the other changes of this set (texture queue, sub-range copy-back, fills and journal; each in its own pull request) against `v2026.11.30.03`, same route: frame time at matched load 75.3 → 70.6 ms; submit-thread preparation 70.7 → 65.4 ms (−7.5 %). - 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`: 2488 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 `console_insn::tests::clzero_on_a_guarded_line_goes_through_the_guard` 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: #4294 (skips the stale-page walk for ranges with no journal writes), #4042 (skips Does::Refresh without copies), #4532 (caches watch::ahead per generation), #4422, #3958. 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)
DoubleD17 commented 2026-12-01 10:51:04 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-12-01T10:51:04Z.


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 #4757 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_FLUSH_FAST_NOOP=1 and VICTORY_FLUSH_FAST_NOOP_V2=1, #4757'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 (#4757, 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)
refreshes 20.50 ms (19.4 to 21.9) 19.60 ms (18.4 to 20.7)
asking the write watch 5.08 ms 4.88 ms
in its submissions 57.3 ms (53.8 to 60.5) 54.3 ms (52.0 to 57.5)
  • 6,990 to 7,350 spans a frame went through the flushes in every run, both arms. 5,800 to 6,130 of them were "known to copy nothing" (83 %).
  • Frame rate: base fps mean 16.29 (control) against 16.70 (this PR).
    • On the light view only (the seconds where the idle camera's heavier view is not on screen), preparation is +0.2 ms and fps -0.1 %.
  • So on this PC and profile the refresh cut is about 0.9 ms a frame, and the per-run ranges overlap. We could not resolve the -7.3 % / -4.8 % here. It may need the denser scenes of a route rather than an idle camera.

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.
  • No stale or mismatched surfaces, which is what skipped refreshes would show.

Not tested: movement (idle camera only), Series S, frame generation on, other cards.

AI Assisted

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7308817836 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4774#issuecomment-7308817836). Originally posted by [DoubleD17](https://github.com/DoubleD17) on 2026-12-01T10:51:04Z. --- 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 #4757 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_FLUSH_FAST_NOOP=1` and `VICTORY_FLUSH_FAST_NOOP_V2=1`, #4757'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 (#4757, 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) | |---|---|---| | refreshes | 20.50 ms (19.4 to 21.9) | 19.60 ms (18.4 to 20.7) | | asking the write watch | 5.08 ms | 4.88 ms | | in its submissions | 57.3 ms (53.8 to 60.5) | 54.3 ms (52.0 to 57.5) | - 6,990 to 7,350 spans a frame went through the flushes in every run, both arms. 5,800 to 6,130 of them were "known to copy nothing" (83 %). - **Frame rate:** base fps mean 16.29 (control) against 16.70 (this PR). - On the light view only (the seconds where the idle camera's heavier view is not on screen), preparation is +0.2 ms and fps -0.1 %. - So on this PC and profile the refresh cut is about 0.9 ms a frame, and the per-run ranges overlap. We could not resolve the -7.3 % / -4.8 % here. It may need the denser scenes of a route rather than an idle camera. **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. - No stale or mismatched surfaces, which is what skipped refreshes would show. **Not tested:** movement (idle camera only), Series S, frame generation on, other cards. AI Assisted
tillo88 commented 2026-12-01 12:07:05 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tillo88 on 2026-12-01T12:07:05Z.


I queued this PR on my replay bench, but it does not merge on top of v2026.11.30.03, the latest release (merge conflict), so there are no numbers from it yet. I'll try again on the next release.

Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7310674263 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4774#issuecomment-7310674263). Originally posted by [tillo88](https://github.com/tillo88) on 2026-12-01T12:07:05Z. --- I queued this PR on my replay bench, but it does not merge on top of v2026.11.30.03, the latest release (merge conflict), so there are no numbers from it yet. I'll try again on the next release. Measured unattended on a replay bench (same save, recorded controller input via VICTORY_INPUT_REPLAY); numbers and text prepared with Claude.
Razen114514 commented 2026-12-01 14:40:05 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Razen114514 on 2026-12-01T14:40:05Z.


A third host with the same shape of numbers, from a much smaller card, and one detail
about where the no-op cost is paid here.

Host: RTX 5060 8 GB, i5-13490F, 32 GB, Windows 11 build 26200, driver 621.1.0.
Series S, 960x540 scene through the title's FidelityFX path to 1920x1080, DLSS
performance, DLSS frame generation 2x, at v2026.11.30.03. Log line, per frame:

preparing per frame, the submitting thread: 47.0 ms in its submissions: ... 25.6 in the
lists' steps (refreshes 16.6 in 40 flushes of 10593, 9560 of them known to copy nothing,
1942 on several threads, 0.1 one at a time in 123 before shader writes; copies and fills
2.8, ...)

So 90.2 % of the refreshes here are already known to copy nothing (9560 / 10593),
which matches your 92 % on quite different hardware -- the ratio looks structural, not
config-dependent.

What that is worth here, scaled down. The same switch set measured -13 % of the
submit thread's preparation on your RTX 5080, where refreshes are about half of it
(28-32 ms of 60). Here the whole preparation is 47 ms and refreshes are 16.6 ms of it,
about 35 %, so the same -13 % of the refresh part would be roughly -9 % (about 4 ms a
frame)
, not -13 % of everything. I have not built this branch, so that is arithmetic
from the two logs, not a measurement of your change on this card.

The detail worth having: the log says known to copy nothing, so the runtime
already decides this before queuing -- but the span still goes into Batch and 1,942 of
the calls land on several threads in that window. That is the step
VICTORY_FLUSH_FAST_NOOP drops before it is queued, which is why I think the small-card
case may gain a little more than the ratio suggests: on this machine the per-span work
that remains is dispatch, not copying.

No review of the diff -- this is two hosts' logs side by side. If it helps, I can run the
switch here once you say the branch builds on main and post the before/after from this
card, which is the one configuration none of the PRs in this set has measured.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7314631414 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4774#issuecomment-7314631414). Originally posted by [Razen114514](https://github.com/Razen114514) on 2026-12-01T14:40:05Z. --- A third host with the same shape of numbers, from a much smaller card, and one detail about where the no-op cost is paid here. **Host**: RTX 5060 8 GB, i5-13490F, 32 GB, Windows 11 build 26200, driver 621.1.0. Series S, 960x540 scene through the title's FidelityFX path to 1920x1080, DLSS performance, DLSS frame generation 2x, at `v2026.11.30.03`. Log line, per frame: ``` preparing per frame, the submitting thread: 47.0 ms in its submissions: ... 25.6 in the lists' steps (refreshes 16.6 in 40 flushes of 10593, 9560 of them known to copy nothing, 1942 on several threads, 0.1 one at a time in 123 before shader writes; copies and fills 2.8, ...) ``` So **90.2 % of the refreshes here are already known to copy nothing** (`9560 / 10593`), which matches your 92 % on quite different hardware -- the ratio looks structural, not config-dependent. **What that is worth here, scaled down.** The same switch set measured -13 % of the submit thread's preparation on your RTX 5080, where refreshes are about half of it (28-32 ms of 60). Here the whole preparation is 47 ms and refreshes are 16.6 ms of it, about 35 %, so the same -13 % of the refresh part would be roughly **-9 % (about 4 ms a frame)**, not -13 % of everything. I have not built this branch, so that is arithmetic from the two logs, not a measurement of your change on this card. **The detail worth having**: the log says *known* to copy nothing, so the runtime already decides this before queuing -- but the span still goes into `Batch` and 1,942 of the calls land on several threads in that window. That is the step `VICTORY_FLUSH_FAST_NOOP` drops before it is queued, which is why I think the small-card case may gain a little more than the ratio suggests: on this machine the per-span work that remains is dispatch, not copying. No review of the diff -- this is two hosts' logs side by side. If it helps, I can run the switch here once you say the branch builds on `main` and post the before/after from this card, which is the one configuration none of the PRs in this set has measured.
trustno1-coder commented 2026-12-01 18:32:32 +00:00 (Migrated from github.com)

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


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:7321110965 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4774#issuecomment-7321110965). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:32:32Z. --- 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!4774
No description provided.