Fuse refresh sifting when write watch is kept #3762

Manually merged
github merged 1 commit from github-bot/gh-3762 into main 2026-11-30 14:14:43 +00:00 AGit
Owner

@⁠SmallDevBigNothing on GitHub · 2026-11-30 06:11 UTC · original
SmallDevBigNothing:perf/measure-refresh-hot-path → main · +53 −1 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC

What it changes

When write-watch data is already kept for a submission and the parallel refresh is available, flush_all checks for unchanged spans as it refreshes the batch. This saves a separate worker dispatch and filter pass. The separate sift still runs when it can narrow the upcoming write-watch query or when the parallel refresh is unavailable. This change affects the path with VICTORY_FLUSH_SIFT=1.

How it was tested

Windows 11 build 26100, Core Ultra 5 225F, RTX 3060 12 GiB. The release benchmark uses synthetic write-watched buffers and the existing submission and refresh code. Each process warms up for eight submissions and times 64 more. Four paired process runs per variant, with alternating order, 4,096 spans and eight large flushes. One in eight spans changes each submission and the benchmark checks the copied bytes.

Refresh workers Baseline median Patched median Baseline p95 Patched p95
1 1.09 ms 0.94 ms 1.23 ms 1.12 ms
3 1.10 ms 0.98 ms 1.22 ms 1.15 ms
5 1.13 ms 1.01 ms 1.34 ms 1.17 ms

With sifting disabled, the three-worker wide case measured 0.96 ms on both revisions. The small-flush controls were within 0.05 ms of baseline. These are CPU submission timings. Gameplay FPS still needs a paired run.

  • Both locked release builds passed and reported the RTX 3060 in the shader-model probe.
  • Five refresh correctness tests passed and the new ignored benchmark passed in each run. The staged asset policy also passed.
  • Benchmark command: cargo test --release --locked -p victory-gpu --lib write_watched_submission_throughput -- --ignored --nocapture. Set VICTORY_LIGHT_REFRESH=1, VICTORY_WIDE_REFRESH=1, VICTORY_NEW_BATCH=0, VICTORY_FLUSH_SIFT=1 and select the worker count with VICTORY_WIDE_THREADS.

Checked for overlap

  • Checked open refresh-sifting PRs. #3705 and #3332 reduce the cost of the separate sift. This patch skips that pass only when the kept write watch and parallel update make it redundant. #2504 targets the journal lookup cost.

Implementation and testing assisted by Codex.

**@⁠SmallDevBigNothing** on GitHub · 2026-11-30 06:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3762) `SmallDevBigNothing:perf/measure-refresh-hot-path` → `main` · +53 −1 · 1 files · 1 commits · merged 2026-11-30 14:12 UTC ## What it changes When write-watch data is already kept for a submission and the parallel refresh is available, `flush_all` checks for unchanged spans as it refreshes the batch. This saves a separate worker dispatch and filter pass. The separate sift still runs when it can narrow the upcoming write-watch query or when the parallel refresh is unavailable. This change affects the path with `VICTORY_FLUSH_SIFT=1`. ## How it was tested Windows 11 build 26100, Core Ultra 5 225F, RTX 3060 12 GiB. The release benchmark uses synthetic write-watched buffers and the existing submission and refresh code. Each process warms up for eight submissions and times 64 more. Four paired process runs per variant, with alternating order, 4,096 spans and eight large flushes. One in eight spans changes each submission and the benchmark checks the copied bytes. | Refresh workers | Baseline median | Patched median | Baseline p95 | Patched p95 | | ---: | ---: | ---: | ---: | ---: | | 1 | 1.09 ms | 0.94 ms | 1.23 ms | 1.12 ms | | 3 | 1.10 ms | 0.98 ms | 1.22 ms | 1.15 ms | | 5 | 1.13 ms | 1.01 ms | 1.34 ms | 1.17 ms | With sifting disabled, the three-worker wide case measured 0.96 ms on both revisions. The small-flush controls were within 0.05 ms of baseline. These are CPU submission timings. Gameplay FPS still needs a paired run. - Both locked release builds passed and reported the RTX 3060 in the shader-model probe. - Five refresh correctness tests passed and the new ignored benchmark passed in each run. The staged asset policy also passed. - Benchmark command: `cargo test --release --locked -p victory-gpu --lib write_watched_submission_throughput -- --ignored --nocapture`. Set `VICTORY_LIGHT_REFRESH=1`, `VICTORY_WIDE_REFRESH=1`, `VICTORY_NEW_BATCH=0`, `VICTORY_FLUSH_SIFT=1` and select the worker count with `VICTORY_WIDE_THREADS`. ## Checked for overlap - [x] Checked open refresh-sifting PRs. #3705 and #3332 reduce the cost of the separate sift. This patch skips that pass only when the kept write watch and parallel update make it redundant. #2504 targets the journal lookup cost. Implementation and testing assisted by Codex.
Add a write-watched submission benchmark. With three refresh workers and sifting enabled, the median fell from 1.10 ms to 0.98 ms on a Core Ultra 5 225F.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 06:13:39 +00:00
Author
Owner

@⁠Smoodie7 on GitHub · 2026-11-30 06:21 UTC · original

Thanks for the benchmark, it is a useful one to have. One thing I noticed while reading flush_all: as far as I can tell, this only changes anything for people who set VICTORY_FLUSH_SIFT=1.

  • flush_sift() is switch::on("VICTORY_FLUSH_SIFT"), so it is off unless the variable is set, and no launcher (play.ps1, play-foxhound.ps1, victory play) sets it.
  • With it off, sifted is false, so when self.refreshes.len() > FEW and !batch, check_noop is already true in the wide_each_scoped path. The no-op checks already run inside the parallel update. That is the fused path this PR adds, and it is what everyone gets by default today.
  • Your numbers agree: patched FLUSH_SIFT=1 with 3 workers is 0.98 ms, against 0.96 ms with sifting off on both revisions.

So with a kept asking and the wide refresh, FLUSH_SIFT=1 now behaves like FLUSH_SIFT=0. That is fine, but it is not a speed-up over the default.

Two ways this could go further:

  1. Keep only the benchmark (write_watched_submission_throughput). It is the valuable part: it gives the refresh path a repeatable CPU number. If you drop the sifted change, it measures exactly what the default does.
  2. Where the sift still earns its cost. That is the !kept case, where it narrows the ranges for ask_ahead. A run of the benchmark without a kept asking, sift on and off, would show whether FLUSH_SIFT is worth keeping at all, or whether the switch and sift_refreshes can go.

A paired gameplay run with the default settings (sift off) would also show how much of the submitting thread's time is in refreshes. On my RTX 4070 Ti SUPER and Ryzen 7 7700, the lists' steps line shows 15–23 ms per frame in refreshes in the heavy scenes from #3512 and #3761. That is where a gain would show up in fps.

**@⁠Smoodie7** on GitHub · 2026-11-30 06:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3762#issuecomment-7270568553) Thanks for the benchmark, it is a useful one to have. One thing I noticed while reading `flush_all`: as far as I can tell, this only changes anything for people who set `VICTORY_FLUSH_SIFT=1`. - `flush_sift()` is `switch::on("VICTORY_FLUSH_SIFT")`, so it is off unless the variable is set, and no launcher (`play.ps1`, `play-foxhound.ps1`, `victory play`) sets it. - With it off, `sifted` is false, so when `self.refreshes.len() > FEW` and `!batch`, `check_noop` is already true in the `wide_each_scoped` path. The no-op checks already run inside the parallel update. That is the fused path this PR adds, and it is what everyone gets by default today. - Your numbers agree: patched `FLUSH_SIFT=1` with 3 workers is 0.98 ms, against 0.96 ms with sifting off on both revisions. So with a kept asking and the wide refresh, `FLUSH_SIFT=1` now behaves like `FLUSH_SIFT=0`. That is fine, but it is not a speed-up over the default. Two ways this could go further: 1. **Keep only the benchmark** (`write_watched_submission_throughput`). It is the valuable part: it gives the refresh path a repeatable CPU number. If you drop the `sifted` change, it measures exactly what the default does. 2. **Where the sift still earns its cost.** That is the `!kept` case, where it narrows the ranges for `ask_ahead`. A run of the benchmark without a kept asking, sift on and off, would show whether `FLUSH_SIFT` is worth keeping at all, or whether the switch and `sift_refreshes` can go. A paired gameplay run with the default settings (sift off) would also show how much of the submitting thread's time is in refreshes. On my RTX 4070 Ti SUPER and Ryzen 7 7700, the `lists' steps` line shows 15–23 ms per frame in refreshes in the heavy scenes from #3512 and #3761. That is where a gain would show up in fps.
github manually merged commit 309111953c into main 2026-11-30 14:14:43 +00:00
Author
Owner

@⁠SmallDevBigNothing on GitHub · 2026-11-30 18:02 UTC · original

@⁠Smoodie7 Thanks for pointing out the flush-local case. On a Core Ultra 5 225F, with no kept watch and three workers, enabling separate sifting raised the median from 1.07 to 1.47 ms for the wide all-watched fixture and from 0.61 to 0.78 ms for the wide mixed fixture. In the mixed case, candidate ranges handed to write watch fell from 4,096 to 960 even as total CPU time rose. Kept-watch timings were within run-to-run variation. #4272 has the asset-free reproducer. No defaults changed.

**@⁠SmallDevBigNothing** on GitHub · 2026-11-30 18:02 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3762#issuecomment-7287229031) @⁠Smoodie7 Thanks for pointing out the flush-local case. On a Core Ultra 5 225F, with no kept watch and three workers, enabling separate sifting raised the median from 1.07 to 1.47 ms for the wide all-watched fixture and from 0.61 to 0.78 ms for the wide mixed fixture. In the mixed case, candidate ranges handed to write watch fell from 4,096 to 960 even as total CPU time rose. Kept-watch timings were within run-to-run variation. #4272 has the asset-free reproducer. No defaults changed.
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!3762
No description provided.