Copies remember the ranges they took whole: a page part asked for again is not read again unless written #3818

Manually merged
github merged 2 commits from github-bot/gh-3818 into gh-pr/3818/base 2026-11-30 14:14:53 +00:00 AGit
Owner

@⁠stasadance on GitHub · 2026-11-30 08:21 UTC · original
stasadance:perf/copy-range-memo → main · +158 −20 · 2 files · 2 commits · merged 2026-11-30 14:12 UTC

What it changes

A copy remembers only the last and the longest range it took whole (ranged). Draws ask for parts of the same 64 KiB pages again in every submission, and copied notes a page only when a refresh holds all of it. So a part of a page that was asked for again after other ranges of the copy were read was read again from title memory, compared, and found unchanged. In a drive the frame line read "copies 23.3 ms 82.8 MB" a frame, while only 17.0 MB a frame was actually sent up: about 60 MB a frame were read and compared for nothing.

Each copy now also keeps a small memo of ranges it took whole, a slot each by the hash of the range's ends (range_memo, memo_slot), under the same lock and SeqLock as ranged. A range asked for again is known as taken whole unless it was written since. Copies of one 4 KiB page or less don't get a memo. VICTORY_RANGE_MEMO=0 goes back to the two slots alone.

How it was tested

  • GPU and profile: RTX 4090 on Linux (NVIDIA 620.73.04, kron4ek Wine 11.23, vkd3d-proton GE cae8353ed), DLSS + frame generation 2X
  • Before (run 20261129-225559, city driving): copies 42-46 ms and 85-90 MB a frame.
  • After (run 20261130-002520; that build also carried other copy-path changes, and the scene was on foot at dusk, not the same drive): copies 19-23 ms and 45-63 MB a frame, "ranges of copies known as taken whole by the memo alone" logged, no new warnings or errors. Not an isolated A/B.
  • cargo test passed for the crates it touches: native cargo test cannot build victory-gpu on a Linux host (same on main), so no; cargo xwin clippy for the Windows target adds no warning over current main.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #614, #1556 (no-op refreshes).
**@⁠stasadance** on GitHub · 2026-11-30 08:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3818) `stasadance:perf/copy-range-memo` → `main` · +158 −20 · 2 files · 2 commits · merged 2026-11-30 14:12 UTC ## What it changes A copy remembers only the last and the longest range it took whole (`ranged`). Draws ask for parts of the same 64 KiB pages again in every submission, and `copied` notes a page only when a refresh holds all of it. So a part of a page that was asked for again after other ranges of the copy were read was read again from title memory, compared, and found unchanged. In a drive the frame line read "copies 23.3 ms 82.8 MB" a frame, while only 17.0 MB a frame was actually sent up: about 60 MB a frame were read and compared for nothing. Each copy now also keeps a small memo of ranges it took whole, a slot each by the hash of the range's ends (`range_memo`, `memo_slot`), under the same lock and SeqLock as `ranged`. A range asked for again is known as taken whole unless it was written since. Copies of one 4 KiB page or less don't get a memo. `VICTORY_RANGE_MEMO=0` goes back to the two slots alone. ## How it was tested - GPU and profile: RTX 4090 on Linux (NVIDIA 620.73.04, kron4ek Wine 11.23, vkd3d-proton GE cae8353ed), DLSS + frame generation 2X - Before (run 20261129-225559, city driving): copies 42-46 ms and 85-90 MB a frame. - After (run 20261130-002520; that build also carried other copy-path changes, and the scene was on foot at dusk, not the same drive): copies 19-23 ms and 45-63 MB a frame, "ranges of copies known as taken whole by the memo alone" logged, no new warnings or errors. Not an isolated A/B. - `cargo test` passed for the crates it touches: native `cargo test` cannot build `victory-gpu` on a Linux host (same on main), so no; `cargo xwin clippy` for the Windows target adds no warning over current main. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #614, #1556 (no-op refreshes).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 08:22:50 +00:00
Author
Owner

@⁠dyshay on GitHub · 2026-11-30 08:55 UTC · original

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched code pass. A run on an RTX 4090 is queued. Frame times will follow here.

**@⁠dyshay** on GitHub · 2026-11-30 08:55 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3818#issuecomment-7273516690) Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with `--profile diag --features diagnostics`, and the CPU tests of the touched code pass. A run on an RTX 4090 is queued. Frame times will follow here.
Author
Owner

@⁠Yoruiopz on GitHub · 2026-11-30 09:31 UTC · original

Independent .05 check at exact PR head 8ab3c0342 on an RTX 5070 Laptop (8 GB). The locked Windows diagnostics executable built and played. I used the same executable, copied save, input tape, warm cache, Series S 640×360 rendered through DLSS Ultra Performance to 1080p, frame generation off. Each run settled for 25 seconds after the world loaded, then recorded a 21.5-second window with 16 pose-matched screenshots. Only VICTORY_RANGE_MEMO changed. The order was off/on, then on/off.

Pair Memo Rendered FPS Copy time Copy MB/frame Soft-view MB in a 10 s report Frame p99
A/B off 20.9 20.2 ms 56.25 11,329 85.6 ms
A/B on 20.9 20.4 ms 52.60 10,041 104.6 ms
B/A on 21.5 17.6 ms 49.75 9,897 102.3 ms
B/A off 21.3 18.9 ms 52.30 10,351 94.1 ms

FPS and copy values are medians of the in-window host reports. Frame p99 uses the CSV frames with 3,500–7,000 draws. Each run had one fully retained 10-second soft-view report. Memo-on recorded 85 and 92 memo-only refresh skips per frame. This shows fewer soft-view bytes and moderately lower copy volume on this route. The rendered FPS was close across the pairs, and the upper tail was longer with the memo enabled. Each condition was only sampled twice in this fixed porch scene.

I also ran a CPU-only regression twice in fresh processes at exact head plus this optional test commit. The test displaces both legacy notes so only the memo can skip the unchanged partial range, then writes a byte through a second mapping. Both VICTORY_RANGE_MEMO=0 and =1 passed. The memo skipped the unchanged reread, and both paths subsequently copied the edited byte and matched all 128 KiB of expected CPU-side data.

**@⁠Yoruiopz** on GitHub · 2026-11-30 09:31 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3818#issuecomment-7274335595) Independent .05 check at exact PR head 8ab3c0342 on an RTX 5070 Laptop (8 GB). The locked Windows diagnostics executable built and played. I used the same executable, copied save, input tape, warm cache, Series S 640×360 rendered through DLSS Ultra Performance to 1080p, frame generation off. Each run settled for 25 seconds after the world loaded, then recorded a 21.5-second window with 16 pose-matched screenshots. Only VICTORY_RANGE_MEMO changed. The order was off/on, then on/off. | Pair | Memo | Rendered FPS | Copy time | Copy MB/frame | Soft-view MB in a 10 s report | Frame p99 | | --- | --- | ---: | ---: | ---: | ---: | ---: | | A/B | off | 20.9 | 20.2 ms | 56.25 | 11,329 | 85.6 ms | | A/B | on | 20.9 | 20.4 ms | 52.60 | 10,041 | 104.6 ms | | B/A | on | 21.5 | 17.6 ms | 49.75 | 9,897 | 102.3 ms | | B/A | off | 21.3 | 18.9 ms | 52.30 | 10,351 | 94.1 ms | FPS and copy values are medians of the in-window host reports. Frame p99 uses the CSV frames with 3,500–7,000 draws. Each run had one fully retained 10-second soft-view report. Memo-on recorded 85 and 92 memo-only refresh skips per frame. This shows fewer soft-view bytes and moderately lower copy volume on this route. The rendered FPS was close across the pairs, and the upper tail was longer with the memo enabled. Each condition was only sampled twice in this fixed porch scene. I also ran a CPU-only regression twice in fresh processes at exact head plus this [optional test commit](https://github.com/Yoruiopz/VIctory-NVIDIA/commit/1c53d9e315bd37be719894b3c619961af826f9e0). The test displaces both legacy notes so only the memo can skip the unchanged partial range, then writes a byte through a second mapping. Both VICTORY_RANGE_MEMO=0 and =1 passed. The memo skipped the unchanged reread, and both paths subsequently copied the edited byte and matched all 128 KiB of expected CPU-side data.
Author
Owner

@⁠stasadance on GitHub · 2026-11-30 09:37 UTC · original

Thanks @⁠Yoruiopz, that A/B is exactly what this needed. Looking for what could lengthen the tail, I found one real cost: to count MEMO_SAVED, every look the memo answered was evaluated a second time with the two slots alone, on nearly every look rather than just the memo-only skips. That second pass repeats published() (which can make tell_watch() scan the heap) and the OWNED/JOURNAL read locks that title-side writes take for writing, so the submitting thread and the title's writers block each other more. It's diagnostics-only now (the new commit on this branch); release builds no longer do it.

Two other effects I'd expect, both smaller: one extra cache line read per look for the memo slot, and written pages inside memo'd ranges going through the parts path (again_at) instead of one plain run, which moves fewer bytes but holds copy_lock a little longer. If you rerun, more pairs plus the lock-wait line would show whether the tail moves.

**@⁠stasadance** on GitHub · 2026-11-30 09:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3818#issuecomment-7274454572) Thanks @⁠Yoruiopz, that A/B is exactly what this needed. Looking for what could lengthen the tail, I found one real cost: to count `MEMO_SAVED`, every look the memo answered was evaluated a second time with the two slots alone, on nearly every look rather than just the memo-only skips. That second pass repeats `published()` (which can make `tell_watch()` scan the heap) and the `OWNED`/`JOURNAL` read locks that title-side writes take for writing, so the submitting thread and the title's writers block each other more. It's diagnostics-only now (the new commit on this branch); release builds no longer do it. Two other effects I'd expect, both smaller: one extra cache line read per look for the memo slot, and written pages inside memo'd ranges going through the parts path (`again_at`) instead of one plain run, which moves fewer bytes but holds `copy_lock` a little longer. If you rerun, more pairs plus the lock-wait line would show whether the tail moves.
github-bot changed target branch from main to gh-pr/3818/base 2026-11-30 14:14:50 +00:00
github manually merged commit 7ada6b2745 into gh-pr/3818/base 2026-11-30 14:14:51 +00:00
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!3818
No description provided.