GPU: VICTORY_LEAN_WINDOWS=1 — windows on the card with no CPU side, mapped in 64 KiB tiles (−0.8 GB commit, −2.1 GB memory in use) #265

Open
CDR-0000 wants to merge 1 commit from upstream-pr/265 into main
CDR-0000 commented 2026-11-24 23:03:09 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by CDR-0000 on 2026-11-24T23:03:09Z.


Opt-in. Windows of title memory go to the card with no CPU side, their buffers reserved and mapped in 64 KiB tiles as bytes are sent, through one 64 MiB upload ring. On an RTX 3080 Ti / 32 GB PC: private memory 0.8 GB lower once the world has settled (1.9 GB at the load), memory in use 2.1 GB lower, nothing seen to render differently.

Follow-up to #54, where the window and in-place switches moved private memory by at most ~0.3 GB.

Why

A window (4 MiB of title memory outside buffers, shadow.rs loose) was a whole CPU side in the PC's memory, plus a card side with VICTORY_CARD_WINDOWS_MB. In the world that was 2.1–3.0 GB, of which only 1.7–1.9 GB is ever sent. On a 32 GB PC with the page file Windows gave it, the commit ran out at ~23 GB private.

What it does (VICTORY_LEAN_WINDOWS=1, off by default)

  • No CPU side. A refresh only notes which bytes changed (Shadow::copy → card_changed). Host::card_before sends them from title memory to the card through one upload buffer used as a ring (Ring, VICTORY_LEAN_UPLOAD_MB, 64): each plan writes after the one before; a fence of our own is signalled behind each plan's copies, and a stretch is written over only once the card is done with it. A plan that would write over its own unsent bytes runs what it has and waits first (the world load). So lean windows hold 64 MiB of the PC's memory however many submissions fly with VICTORY_RELAY / VICTORY_LATE_WAIT. (A first version with one upload buffer per plan held 2.3 GB more write-combined memory with the relay; the ring replaced it.)
  • Tiles. Where the card reads unmapped tiles as zeros (tiled resources tier 2+), the window's buffer is reserved (Host::reserved_buffer). The 64 KiB tiles that bytes are sent to get tiles of a pool of 64 MiB heaps (Host::take_tiles, Shadow::tiles_to_map), mapped on the queue ahead of the copy (Host::map_tiles); a window let go gives its tiles back. A tile never sent reads as zeros, as a fresh buffer did. Below tier 2: a whole buffer. This is what lowers the commit — Windows charges the process for video memory too, so moving windows to the card with whole buffers (first version) saved memory in use but not commit.
  • Room. Windows default to 8 GB of the card under window_card_for's existing rule (a fifth of the budget stays free, so textures keep theirs); VICTORY_CARD_WINDOWS_MB still sets it. A window that finds no room stays as it was.
  • Writes. Shaders write no window (run 91: "0.0 MB compared in 0 ranges of windows"). A write declared for a lean window is counted (lean line), not compared or copied back. VICTORY_BVH_BUILDER=1, whose builder declares writes for every copy it reaches, turns lean windows off with a warning.
  • Lean line every 5 s: windows made, MB alive / MB in tiles mapped / MB of tile heaps, MB sent up, ring waits, writes left out.

Measured

RTX 3080 Ti 12 GB (driver 32.0.16.1742), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 26300. main 2119b0e + this, diag build, VICTORY_RELAY=2, same route (load into the prologue, no input), each run stopped by an outside guard at 20 GB private. Pairs run back to back.

seconds after the world load private, without private, VICTORY_LEAN_WINDOWS=1
+0 16.8 GB 15.0 GB −1.9 GB
+5 18.6 GB 17.4 GB −1.3 GB
+10 18.5 GB 17.8 GB −0.8 GB
+16 19.1 GB 18.2 GB −0.8 GB
+21 19.6 GB 18.9 GB −0.8 GB
memory in use at the stop 17.4 GB 15.3 GB −2.1 GB
  • Memory map: "windows of title memory and other 4 MiB allocations" 2,126 → 102 MB.
  • Lean line in the world: 815 windows, 2,932 MB alive, 1,865 MB in tiles mapped (1,920 MB of heaps); ~530 MB sent up per 5 s; 0 ring waits; 0 writes left out.
  • Frame rate about the same (2.6 vs 2.3 fps at 3,500–3,850 draws/frame; the two runs ended at different moments). No difference seen on screen.

Not fixed by this: the process still reaches ~19–20 GB private in the world (title heaps, texture copies, write-combined buffer copies); this takes ~0.8 GB of commit and ~2 GB of memory in use off it.

Checks

  • cargo clippy --release -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo test --release -p victory-gpu: 116 passed, 0 failed, 1 ignored, on the card — including new ring_tests (placement, wrap-around, long asks in pieces, overlap) and tiles_tests (tiles a range touches).
  • Not tested: AMD/Intel cards, tier-1 cards (they take the whole-buffer path), Linux/Proton, 8 GB cards (the room rule should keep windows off a full card, untried).

Written with Claude Code (Claude Opus 5.5); the runs are mine.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593172184 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/265). Originally posted by [CDR-0000](https://github.com/CDR-0000) on 2026-11-24T23:03:09Z. --- **Opt-in. Windows of title memory go to the card with no CPU side, their buffers reserved and mapped in 64 KiB tiles as bytes are sent, through one 64 MiB upload ring. On an RTX 3080 Ti / 32 GB PC: private memory 0.8 GB lower once the world has settled (1.9 GB at the load), memory in use 2.1 GB lower, nothing seen to render differently.** Follow-up to #54, where the window and in-place switches moved private memory by at most ~0.3 GB. ### Why A window (4 MiB of title memory outside buffers, `shadow.rs` `loose`) was a whole CPU side in the PC's memory, plus a card side with `VICTORY_CARD_WINDOWS_MB`. In the world that was 2.1–3.0 GB, of which only 1.7–1.9 GB is ever sent. On a 32 GB PC with the page file Windows gave it, the commit ran out at ~23 GB private. ### What it does (`VICTORY_LEAN_WINDOWS=1`, off by default) - **No CPU side.** A refresh only notes which bytes changed (`Shadow::copy` → `card_changed`). `Host::card_before` sends them from title memory to the card through **one upload buffer used as a ring** (`Ring`, `VICTORY_LEAN_UPLOAD_MB`, 64): each plan writes after the one before; a fence of our own is signalled behind each plan's copies, and a stretch is written over only once the card is done with it. A plan that would write over its own unsent bytes runs what it has and waits first (the world load). So lean windows hold 64 MiB of the PC's memory however many submissions fly with `VICTORY_RELAY` / `VICTORY_LATE_WAIT`. (A first version with one upload buffer per plan held 2.3 GB more write-combined memory with the relay; the ring replaced it.) - **Tiles.** Where the card reads unmapped tiles as zeros (tiled resources tier 2+), the window's buffer is reserved (`Host::reserved_buffer`). The 64 KiB tiles that bytes are sent to get tiles of a pool of 64 MiB heaps (`Host::take_tiles`, `Shadow::tiles_to_map`), mapped on the queue ahead of the copy (`Host::map_tiles`); a window let go gives its tiles back. A tile never sent reads as zeros, as a fresh buffer did. Below tier 2: a whole buffer. This is what lowers the commit — Windows charges the process for video memory too, so moving windows to the card with whole buffers (first version) saved memory in use but not commit. - **Room.** Windows default to 8 GB of the card under `window_card_for`'s existing rule (a fifth of the budget stays free, so textures keep theirs); `VICTORY_CARD_WINDOWS_MB` still sets it. A window that finds no room stays as it was. - **Writes.** Shaders write no window (run 91: "0.0 MB compared in 0 ranges of windows"). A write declared for a lean window is counted (lean line), not compared or copied back. `VICTORY_BVH_BUILDER=1`, whose builder declares writes for every copy it reaches, turns lean windows off with a warning. - **Lean line** every 5 s: windows made, MB alive / MB in tiles mapped / MB of tile heaps, MB sent up, ring waits, writes left out. ### Measured RTX 3080 Ti 12 GB (driver 32.0.16.1742), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 26300. `main` `2119b0e` + this, diag build, `VICTORY_RELAY=2`, same route (load into the prologue, no input), each run stopped by an outside guard at 20 GB private. Pairs run back to back. | seconds after the world load | private, without | private, `VICTORY_LEAN_WINDOWS=1` | | |---|---|---|---| | +0 | 16.8 GB | 15.0 GB | −1.9 GB | | +5 | 18.6 GB | 17.4 GB | −1.3 GB | | +10 | 18.5 GB | 17.8 GB | −0.8 GB | | +16 | 19.1 GB | 18.2 GB | −0.8 GB | | +21 | 19.6 GB | 18.9 GB | −0.8 GB | | memory in use at the stop | 17.4 GB | 15.3 GB | −2.1 GB | - Memory map: "windows of title memory and other 4 MiB allocations" 2,126 → 102 MB. - Lean line in the world: 815 windows, 2,932 MB alive, **1,865 MB in tiles mapped** (1,920 MB of heaps); ~530 MB sent up per 5 s; **0 ring waits**; 0 writes left out. - Frame rate about the same (2.6 vs 2.3 fps at 3,500–3,850 draws/frame; the two runs ended at different moments). No difference seen on screen. **Not fixed by this:** the process still reaches ~19–20 GB private in the world (title heaps, texture copies, write-combined buffer copies); this takes ~0.8 GB of commit and ~2 GB of memory in use off it. ### Checks - `cargo clippy --release -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo test --release -p victory-gpu`: 116 passed, 0 failed, 1 ignored, on the card — including new `ring_tests` (placement, wrap-around, long asks in pieces, overlap) and `tiles_tests` (tiles a range touches). - Not tested: AMD/Intel cards, tier-1 cards (they take the whole-buffer path), Linux/Proton, 8 GB cards (the room rule should keep windows off a full card, untried). *Written with Claude Code (Claude Opus 5.5); the runs are mine.*
SkillIssueXO commented 2026-11-24 23:09:41 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by SkillIssueXO on 2026-11-24T23:06:59Z.


Baseline data for the memory window change from a longer 2119b0e Series X run at 1080p with VICTORY_RELAY=2 and VICTORY_TEXTURE_BUDGET_MB=3072 on an RTX 5070 Ti / 32 GiB system.

  • Over the last 29 seconds of the renderer census, windows outside buffers rose from 5,744 to 6,364 MiB while title-filled texture copies stayed near the cap (3,115 → 3,081 MiB). The final census showed 6,184 MiB of windows referenced by descriptor slots and 4,352 MiB of pages ever copied.
  • The runner stopped at 2.95 GiB of free Windows commit during the first mission. All 584 CPU comparison reports through that poll showed zero window ranges.

This gives a later-scene baseline for the opt-in path, in particular for checking peak commit, upload-ring waits and declared writes left out. AI-assisted log analysis.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7147031285 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/265#issuecomment-7147031285). Originally posted by [SkillIssueXO](https://github.com/SkillIssueXO) on 2026-11-24T23:06:59Z. --- Baseline data for the memory window change from a longer `2119b0e` Series X run at 1080p with `VICTORY_RELAY=2` and `VICTORY_TEXTURE_BUDGET_MB=3072` on an RTX 5070 Ti / 32 GiB system. - Over the last 29 seconds of the renderer census, windows outside buffers rose from 5,744 to 6,364 MiB while title-filled texture copies stayed near the cap (3,115 → 3,081 MiB). The final census showed 6,184 MiB of windows referenced by descriptor slots and 4,352 MiB of pages ever copied. - The runner stopped at 2.95 GiB of free Windows commit during the first mission. All 584 CPU comparison reports through that poll showed zero window ranges. This gives a later-scene baseline for the opt-in path, in particular for checking peak commit, upload-ring waits and declared writes left out. AI-assisted log analysis.
chatgpt-codex-connector[bot commented 2026-11-25 01:12:05 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:56:05Z.


To use Codex here, create a Codex account and connect to github.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7149039367 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/265#issuecomment-7149039367). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T00:56:05Z. --- To use Codex here, [create a Codex account and connect to github](https://chatgpt.com/codex/cloud/settings/connectors).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/265:upstream-pr/265'
git switch 'upstream-pr/265'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/265'
git switch 'upstream-pr/265'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/265'
git switch 'upstream-pr/265'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/265'
git switch 'main'
git merge --squash 'upstream-pr/265'
git switch 'main'
git merge --ff-only 'upstream-pr/265'
git switch 'main'
git merge 'upstream-pr/265'
git push origin 'main'
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
fxceless/victory-fork!265
No description provided.