Renderer port 1 under VICTORY_PORT_ALL=1 leaves xmem's half off: the 182 MB 32-bit graphics heap is refused as Scattered #365

Open
opened 2026-11-26 19:46:59 +00:00 by github-bot · 1 comment
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-26 19:44 UTC · original

With VICTORY_PORT_ALL=1 alone (what scripts/play.ps1 sets), renderer port 1 is on in victory-gpu, but xmem's half of it is off. The 32-bit graphics pages are not put in address order, so their 182 MB heap is refused as "Scattered" and copied as before.

Where

crates/victory-hle/src/modules/xmem.rs:1087 at 2de9980 (main):

fn port_on() -> bool {
    static ON: LazyLock<bool> = LazyLock::new(|| std::env::var("VICTORY_PORT_CONSTANTS").is_ok_and(|v| v.trim() == "1"));
    *ON
}

crates/victory-gpu/src/port.rs on(), by contrast, says VICTORY_PORT_ALL "turns the port on by itself":

*ON.get_or_init(|| std::env::var("VICTORY_PORT_CONSTANTS").is_ok_and(|v| v.trim() == "1") || all())

arrange() (xmem) runs only when xmem's port_on() is true. It gives the freshly mapped physical pages of the 32-bit graphics reservation their slices in address order.

Why it matters

Every play.ps1 run (not -Safe) logs this, about 340 times in a 4-minute run:

WARN victory_gpu::port: renderer port 1: title memory not in place, a copy as before start=0x1d840000 len=182452224 window=false why="not one stretch of a section: Scattered"

The run also logs no "given their section's slices in address order" line. The same heap is then handled the old way.

Seen on an RTX 2070 SUPER 8 GB, Series S, local branch on top of main. Per frame of gameplay:

  • 10-12 refreshes of the whole range;
  • about 10,500 card-step fills read from its host copy;
  • the kernel write-watch asked over about 1.5 GB.

Runs with VICTORY_PORT_CONSTANTS=1 set directly, on the same PC, log the line below and the heap placed (title memory in place ... len=182452224):

the title's 32-bit graphics pages given their section's slices in address order ... moved=752

So everyone who runs port 1 through play.ps1 gets port 1 without its main part, the constants heap. Measurements taken with only PORT_ALL set are measurements of port 1 with that heap left out.

Suggestion

  • Have xmem's port_on() accept VICTORY_PORT_ALL=1 too, the same way port::on() does. Or read one shared switch, so the two halves cannot disagree again.
  • Pinning it with a test is awkward: both switches are read once per process. A comment on both functions that names the other would do.

Not checked

  • The gain has not been measured: the fixed build has not run yet. I'll add numbers here.
  • Only seen on Windows with an RTX 2070 SUPER. The code path does not depend on the card.

AI use

Log reading, source reading and write-up with AI assistance (Claude Code). The runs are my own.

**@⁠Jesper-Andersson** on GitHub · 2026-11-26 19:44 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/365) With `VICTORY_PORT_ALL=1` alone (what `scripts/play.ps1` sets), renderer port 1 is on in `victory-gpu`, but xmem's half of it is off. The 32-bit graphics pages are not put in address order, so their 182 MB heap is refused as "Scattered" and copied as before. ## Where `crates/victory-hle/src/modules/xmem.rs:1087` at `2de9980` (main): ```rust fn port_on() -> bool { static ON: LazyLock<bool> = LazyLock::new(|| std::env::var("VICTORY_PORT_CONSTANTS").is_ok_and(|v| v.trim() == "1")); *ON } ``` `crates/victory-gpu/src/port.rs` `on()`, by contrast, says `VICTORY_PORT_ALL` "turns the port on by itself": ```rust *ON.get_or_init(|| std::env::var("VICTORY_PORT_CONSTANTS").is_ok_and(|v| v.trim() == "1") || all()) ``` `arrange()` (xmem) runs only when xmem's `port_on()` is true. It gives the freshly mapped physical pages of the 32-bit graphics reservation their slices in address order. ## Why it matters Every `play.ps1` run (not `-Safe`) logs this, about 340 times in a 4-minute run: ``` WARN victory_gpu::port: renderer port 1: title memory not in place, a copy as before start=0x1d840000 len=182452224 window=false why="not one stretch of a section: Scattered" ``` The run also logs no "given their section's slices in address order" line. The same heap is then handled the old way. Seen on an RTX 2070 SUPER 8 GB, Series S, local branch on top of main. Per frame of gameplay: - 10-12 refreshes of the whole range; - about 10,500 card-step fills read from its host copy; - the kernel write-watch asked over about 1.5 GB. Runs with `VICTORY_PORT_CONSTANTS=1` set directly, on the same PC, log the line below and the heap placed (`title memory in place ... len=182452224`): ``` the title's 32-bit graphics pages given their section's slices in address order ... moved=752 ``` So everyone who runs port 1 through `play.ps1` gets port 1 without its main part, the constants heap. Measurements taken with only `PORT_ALL` set are measurements of port 1 with that heap left out. ## Suggestion - Have xmem's `port_on()` accept `VICTORY_PORT_ALL=1` too, the same way `port::on()` does. Or read one shared switch, so the two halves cannot disagree again. - Pinning it with a test is awkward: both switches are read once per process. A comment on both functions that names the other would do. ## Not checked - The gain has not been measured: the fixed build has not run yet. I'll add numbers here. - Only seen on Windows with an RTX 2070 SUPER. The code path does not depend on the card. ## AI use Log reading, source reading and write-up with AI assistance (Claude Code). The runs are my own.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:46:59 +00:00
Author
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-26 21:04 UTC · original

A correction to my suggestion above: on this card, turning xmem's half on makes the frame slower, so "have port_on() accept VICTORY_PORT_ALL" is not the fix to take without measuring.

I built the change with a switch to undo it (VICTORY_PORT_ARRANGE=0) and ran both with the same build, save and route.

  • Machine: RTX 2070 SUPER 8 GB, Series S, DLSS.
  • Settings: play.ps1 defaults, including VICTORY_CARD_BUFFERS_MIN_KB=64 and MB=1024.
  • Each run: about 4 minutes, 33-40 gameplay intervals.
per frame, gameplay medians xmem's half on (heap in place) off (heap copied, as on main)
frame, median / p90 204 / 469 ms 179 / 260 ms
card busy (the card's clock) 60 % 79 %
title waiting at presents 24.5 ms 8.4 ms
port 1: fills read out of its regions on the CPU 12,092 522
card steps: fills done on the card 59 9,212

With the 182 MB heap in place, the fills that read it can no longer be done on the card from its host copy (VICTORY_CARD_STEPS=2). They are done by the CPU, about 12,000 a frame, and the card waits more. With the heap left as a copy, card steps do them on the card, and that is clearly faster here.

So the mismatch is real: with PORT_ALL alone, port 1 is on but its main region is refused. Whether to close it depends on the card. It is a gain where card steps are off or the card reads PC memory cheaply (the README's 7900 XTX numbers), and a loss here. It would be better settled on purpose than by default: for example, keep PORT_ALL as it is and document that it does not place the 32-bit heap. Or place the heap only where card steps are off.

Not checked: other cards, and VICTORY_CARD_STEPS=0 with the heap in place.

AI use: log reading and write-up with AI assistance (Claude Code). The runs are my own.

**@⁠Jesper-Andersson** on GitHub · 2026-11-26 21:04 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/365#issuecomment-7203365292) A correction to my suggestion above: on this card, turning xmem's half on makes the frame **slower**, so "have `port_on()` accept `VICTORY_PORT_ALL`" is not the fix to take without measuring. I built the change with a switch to undo it (`VICTORY_PORT_ARRANGE=0`) and ran both with the same build, save and route. - Machine: RTX 2070 SUPER 8 GB, Series S, DLSS. - Settings: `play.ps1` defaults, including `VICTORY_CARD_BUFFERS_MIN_KB=64` and `MB=1024`. - Each run: about 4 minutes, 33-40 gameplay intervals. | per frame, gameplay medians | xmem's half on (heap in place) | off (heap copied, as on main) | |---|---|---| | frame, median / p90 | 204 / 469 ms | **179 / 260 ms** | | card busy (`the card's clock`) | 60 % | 79 % | | title waiting at presents | 24.5 ms | 8.4 ms | | port 1: fills read out of its regions on the CPU | 12,092 | 522 | | card steps: fills done on the card | 59 | 9,212 | With the 182 MB heap in place, the fills that read it can no longer be done on the card from its host copy (`VICTORY_CARD_STEPS=2`). They are done by the CPU, about 12,000 a frame, and the card waits more. With the heap left as a copy, card steps do them on the card, and that is clearly faster here. So the mismatch is real: with `PORT_ALL` alone, port 1 is on but its main region is refused. Whether to close it depends on the card. It is a gain where card steps are off or the card reads PC memory cheaply (the README's 7900 XTX numbers), and a loss here. It would be better settled on purpose than by default: for example, keep `PORT_ALL` as it is and document that it does not place the 32-bit heap. Or place the heap only where card steps are off. Not checked: other cards, and `VICTORY_CARD_STEPS=0` with the heap in place. AI use: log reading and write-up with AI assistance (Claude Code). The runs are my own.
This discussion has been locked. Commenting is limited to contributors.
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/avatarmanz--VIctory-7900XTX#365
No description provided.