Index texture remap ranges only when an unpublished burst fills the queue #3730

Closed
github-bot wants to merge 1 commit from github-bot/gh-3730 into main AGit
Owner

@⁠selebate on GitHub · 2026-11-30 05:19 UTC · original
selebate:codex/remap-small-batch → main · +89 −33 · 1 files · 1 commits · closed without merging

What it changes

Texture remaps are recorded while holding a shared mutex. When the history is full, the existing queue can drain, sort and rebuild its entire unpublished suffix for each new write. This is expensive when writes revisit distant intervals in a large batch.

Keep the deque and its adjacent-tail shortcut for ordinary writes. When a full queue contains unpublished ranges, coalesce that suffix once and index it by address. Subsequent writes merge just the touching neighbors. A snapshot publishes the burst, clears the index, and lets each descriptor heap advance its own cursor. Evicting a range still signals a full rescan to readers that missed it.

This is one commit on NVIDIA main 41adb551. The original multi-reader queue and its full-queue compaction came from #2607. The change touches only crates/victory-gpu/src/descriptor/host.rs and includes a synthetic regression test.

How it was tested

CPU queue microbenchmarks. AMD Ryzen 9 9950X3D. Times are median milliseconds across nine rounds. The variant order rotates between rounds. “Always indexed” is an earlier local implementation applied independently to the same official source. It is included as a comparison point.

Workload NVIDIA main Always indexed This PR
4,096 fresh queues, each receiving 64 adjacent writes and a snapshot 1.241 3.251 1.231
Same setup, 64 disjoint writes per batch 2.027 11.149 2.166
Extend 8,192 existing disjoint spans in reverse order at capacity 828.198 0.742 0.733
Full, long-lived queue, 4,096 batches of 64 adjacent writes 1.231 3.029 1.169
Same full queue, 64 disjoint writes per batch 74.490 11.747 12.735

The small disjoint case took 6.9% longer than main in this run. The saturated-extension timing covers the write loop. The four batched timings include snapshots. Other build work was active during this local benchmark.

In game. Windows, RTX 5090 (driver 621.40), Series X, 3840×2160 output, DLSS Quality from 2560×1440, ray tracing and both frame generators off. All three executables used the official play entry point with the same 48 upstream preset values and the same frozen save. Each executable warmed its own shader cache and native pipeline library from the same guest inputs. All three built 2,558/2,558 recorded host pipelines, with zero scheduled on reopen. The first full-content scan reported 196 unsupported shader translations on each build. The reopen scan of the scene's shader input reported zero.

One pass per build. The window starts with the first legible “NINE MONTHS AGO” and ends with the first legible “PROLOGUE” after the restaurant. Foreground captures were taken about 1.5 seconds apart. Times use complete application-present intervals from the renderer CSV, checked against its nanosecond samples. P99 uses inclusive interpolation.

Official-base build Measured frames Mean FPS P99 (ms) Frames >100 ms Longest (ms) New host pipeline failures in window
Main 1,432 26.350 201.554 69 454.833 36
Always indexed 1,469 26.404 153.994 53 636.188 16
This PR 1,517 27.267 153.040 55 669.124 17

The renderer recorded 924, 858 and 873 remap writes per frame respectively in the sampled part of the scene. Parallel merge wall time averaged 2.69, 0.99 and 1.01 ms per frame. This timer includes work outside the queue. Windows returned E_OUTOFMEMORY for additional host pipelines created during all three runs. Available system commit fell below 450 MiB in every measured window. The candidate's longest frame increased. The scene measurements include these effects and carry more uncertainty than the isolated queue timings.

Correctness. The added test exercises promotion at capacity, two readers observing the same burst, eviction, and returning to deque-only operation after a snapshot. An independent byte-coverage model also checked two readers over 4,096,000 operations per variant at eight capacities including zero.

  • cargo test --locked -p victory-gpu --lib remap_history passed all three queue tests.
  • The full victory-gpu run reported 922 passed, 1 failed, and 60 ignored. The failure was shader_cache::tests::every_switch_of_the_translator_is_in_the_key, which reports that the translator no longer reads VICTORY_SCALAR_SPLITS. The same test failed on clean 41adb551 with the identical assertion.
  • The changed file passed cargo xtask policy --staged. Full-tree policy checks on both revisions flag the same existing hexadecimal sequence in crates/victory-loader/src/heap_sites/frame_users.rs.

Checked for overlap

  • Searched open PRs for RemapQueue, remap/texture with BTreeMap, and requeuing remapped textures. This builds on merged #2607. Open #3551 changes when drawn textures get requeued after a grace period.
**@⁠selebate** on GitHub · 2026-11-30 05:19 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3730) `selebate:codex/remap-small-batch` → `main` · +89 −33 · 1 files · 1 commits · closed without merging ## What it changes Texture remaps are recorded while holding a shared mutex. When the history is full, the existing queue can drain, sort and rebuild its entire unpublished suffix for each new write. This is expensive when writes revisit distant intervals in a large batch. Keep the deque and its adjacent-tail shortcut for ordinary writes. When a full queue contains unpublished ranges, coalesce that suffix once and index it by address. Subsequent writes merge just the touching neighbors. A snapshot publishes the burst, clears the index, and lets each descriptor heap advance its own cursor. Evicting a range still signals a full rescan to readers that missed it. This is one commit on NVIDIA main `41adb551`. The original multi-reader queue and its full-queue compaction came from #2607. The change touches only `crates/victory-gpu/src/descriptor/host.rs` and includes a synthetic regression test. ## How it was tested **CPU queue microbenchmarks.** AMD Ryzen 9 9950X3D. Times are median milliseconds across nine rounds. The variant order rotates between rounds. “Always indexed” is an earlier local implementation applied independently to the same official source. It is included as a comparison point. | Workload | NVIDIA main | Always indexed | This PR | |---|---:|---:|---:| | 4,096 fresh queues, each receiving 64 adjacent writes and a snapshot | 1.241 | 3.251 | 1.231 | | Same setup, 64 disjoint writes per batch | 2.027 | 11.149 | 2.166 | | Extend 8,192 existing disjoint spans in reverse order at capacity | 828.198 | 0.742 | 0.733 | | Full, long-lived queue, 4,096 batches of 64 adjacent writes | 1.231 | 3.029 | 1.169 | | Same full queue, 64 disjoint writes per batch | 74.490 | 11.747 | 12.735 | The small disjoint case took 6.9% longer than main in this run. The saturated-extension timing covers the write loop. The four batched timings include snapshots. Other build work was active during this local benchmark. **In game.** Windows, RTX 5090 (driver 621.40), Series X, 3840×2160 output, DLSS Quality from 2560×1440, ray tracing and both frame generators off. All three executables used the official `play` entry point with the same 48 upstream preset values and the same frozen save. Each executable warmed its own shader cache and native pipeline library from the same guest inputs. All three built 2,558/2,558 recorded host pipelines, with zero scheduled on reopen. The first full-content scan reported 196 unsupported shader translations on each build. The reopen scan of the scene's shader input reported zero. One pass per build. The window starts with the first legible “NINE MONTHS AGO” and ends with the first legible “PROLOGUE” after the restaurant. Foreground captures were taken about 1.5 seconds apart. Times use complete application-present intervals from the renderer CSV, checked against its nanosecond samples. P99 uses inclusive interpolation. | Official-base build | Measured frames | Mean FPS | P99 (ms) | Frames >100 ms | Longest (ms) | New host pipeline failures in window | |---|---:|---:|---:|---:|---:|---:| | Main | 1,432 | 26.350 | 201.554 | 69 | 454.833 | 36 | | Always indexed | 1,469 | 26.404 | 153.994 | 53 | 636.188 | 16 | | This PR | 1,517 | 27.267 | 153.040 | 55 | 669.124 | 17 | The renderer recorded 924, 858 and 873 remap writes per frame respectively in the sampled part of the scene. Parallel merge wall time averaged 2.69, 0.99 and 1.01 ms per frame. This timer includes work outside the queue. Windows returned `E_OUTOFMEMORY` for additional host pipelines created during all three runs. Available system commit fell below 450 MiB in every measured window. The candidate's longest frame increased. The scene measurements include these effects and carry more uncertainty than the isolated queue timings. **Correctness.** The added test exercises promotion at capacity, two readers observing the same burst, eviction, and returning to deque-only operation after a snapshot. An independent byte-coverage model also checked two readers over 4,096,000 operations per variant at eight capacities including zero. - `cargo test --locked -p victory-gpu --lib remap_history` passed all three queue tests. - The full `victory-gpu` run reported 922 passed, 1 failed, and 60 ignored. The failure was `shader_cache::tests::every_switch_of_the_translator_is_in_the_key`, which reports that the translator no longer reads `VICTORY_SCALAR_SPLITS`. The same test failed on clean `41adb551` with the identical assertion. - The changed file passed `cargo xtask policy --staged`. Full-tree policy checks on both revisions flag the same existing hexadecimal sequence in `crates/victory-loader/src/heap_sites/frame_users.rs`. ## Checked for overlap - [x] Searched open PRs for `RemapQueue`, remap/texture with `BTreeMap`, and requeuing remapped textures. This builds on merged #2607. Open #3551 changes when drawn textures get requeued after a grace period.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 05:24:20 +00:00
Author
Owner

@⁠dyshay on GitHub · 2026-11-30 05:49 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 crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.

**@⁠dyshay** on GitHub · 2026-11-30 05:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3730#issuecomment-7270047015) 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 crates pass. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-30 06:07 UTC · original · approved these changes

Tested locally merged onto main (41adb551).

  • Merge: Clean merge in crates/victory-gpu/src/descriptor/host.rs.
  • Tests (RTX 5090): cargo test -p victory-gpu --lib descriptor::host::tests:: passed (73 passed; 0 failed; 1 ignored, including the new remap_history_indexes_only_a_saturated_burst test) with 0 new warnings.

Clean lazy indexing for RemapQueue saturated bursts. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-30 06:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3730#pullrequestreview-6107584660) · **approved these changes** Tested locally merged onto `main` (`41adb551`). - **Merge**: Clean merge in `crates/victory-gpu/src/descriptor/host.rs`. - **Tests (RTX 5090)**: `cargo test -p victory-gpu --lib descriptor::host::tests::` passed (`73 passed; 0 failed; 1 ignored`, including the new `remap_history_indexes_only_a_saturated_burst` test) with 0 new warnings. Clean lazy indexing for `RemapQueue` saturated bursts. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Freeman022026 on GitHub · 2026-11-30 13:53 UTC · original

Tested on v2026.11.29.05 (41adb551) on the same machine (Ryzen 7 7800X3D, RTX 4090 24 GB, driver 621.14, 64 GB RAM, Windows 11, Series X profile, 2560x1440, DLSS Performance, 2x Frame Generation, RT off).

In a 47-minute stock .05 run, RemapQueue filled at 47 seconds and logged 4.05 million evictions in 12 minutes. In dense scenes (55k or more translated list calls per frame, 111 seconds), median opening or noting guards was 14.47 ms (max 40.9 ms), merging what was fetched was 7.05 ms, copying back was 17.9 ms, and median dense frame time was 56.6 ms (17.7 base fps).

In an 81-minute run with this PR applied (same 55k+ call bracket, 337 seconds), median opening or noting guards dropped to 1.37 ms (a 10.6x reduction) and merging what was fetched dropped to 2.93 ms. That build also had #2175, #3798, and the four #3809 switches enabled, with copying back at 13.5 ms and median dense frame time at 51.0 ms (19.6 base fps). The remap_history unit tests pass.

**@⁠Freeman022026** on GitHub · 2026-11-30 13:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3730#issuecomment-7280526504) Tested on v2026.11.29.05 (`41adb551`) on the same machine (Ryzen 7 7800X3D, RTX 4090 24 GB, driver 621.14, 64 GB RAM, Windows 11, Series X profile, 2560x1440, DLSS Performance, 2x Frame Generation, RT off). In a 47-minute stock `.05` run, `RemapQueue` filled at 47 seconds and logged 4.05 million evictions in 12 minutes. In dense scenes (55k or more translated list calls per frame, 111 seconds), median `opening or noting guards` was 14.47 ms (max 40.9 ms), `merging what was fetched` was 7.05 ms, `copying back` was 17.9 ms, and median dense frame time was 56.6 ms (17.7 base fps). In an 81-minute run with this PR applied (same 55k+ call bracket, 337 seconds), median `opening or noting guards` dropped to 1.37 ms (a 10.6x reduction) and `merging what was fetched` dropped to 2.93 ms. That build also had #2175, #3798, and the four #3809 switches enabled, with `copying back` at 13.5 ms and median dense frame time at 51.0 ms (19.6 base fps). The `remap_history` unit tests pass.
github-bot closed this pull request 2026-12-01 18:51:26 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:49 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:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3730#issuecomment-7321612430) 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!3730
No description provided.