perf(um): VICTORY_LAZY_HIDDEN=1 maps lazily bound pages hidden from the card until it asks (only with VICTORY_BVH_HARDWARE=0; off by default) #639

Open
github-bot wants to merge 1 commit from github-bot/gh-639 into main AGit
Owner

@⁠Raptorbk45 on GitHub · 2026-12-05 22:37 UTC · original
Raptorbk45:perf/lazy-hidden → main · +43 −2 · 3 files · 1 commits · open

This only acts with VICTORY_BVH_HARDWARE=0. On main the hardware node test is on by default wherever the card and driver have it (VICTORY_BVH_HARDWARE unset; run.sh exports VICTORY_BVH_IN_PLACE=1), and then this switch does nothing but log that it is ignored. It is for people who run with VICTORY_BVH_HARDWARE=0 (no hardware node test; note that the low–high presets set VICTORY_BVH_BUILDER=0 but not VICTORY_BVH_HARDWARE=0, so they still need it set).

8aec563 (#38) made lazy binding show every page to the card at once, because the nodes of a hardware BVH64 hold addresses the card follows without anything asking for them. Without the hardware node test nothing reads that way, so with VICTORY_LAZY_HIDDEN=1 a lazily bound page that nothing has pointed the card at yet is mapped HIDDEN again (as before 8aec563) and shown when something does (want → reveal). Each page shown is an address-mapping call of about 40 µs on the submitting thread; in our streaming bursts a third to a half of the pages bound were never asked for.

Off by default; with it off (or with VICTORY_BVH_HARDWARE not 0) the protections passed are exactly main's.

How it was checked

Run after the final edit, on Linux (CachyOS), against main at 8c4e6633:

  • ./build.sh check (release, MSVC target): passes; the one warning (room_lately never used, resource.rs) is already on main
  • cargo xtask policy: passes
  • cargo test -p victory-core --lib menu: 18 passed

Not run: the game, on this branch. The data below is from our fork.

Branch head: d0b388b8.

No unit test: the switch only changes the protection bits handed to the unified-memory driver path (map/show_as), which needs RADV with the unified-memory patch and a card; the decision itself is two env reads.

Data (from our fork, not re-measured on this branch)

Measured on our fork on 5 December 2026, the first 150 s of the world after loading the save where the arrest cinematic plays (the cinematic plays by itself; runs launched unattended), with a RADV build carrying extra counters. Conditions: RX 7700 XT 12 GB, Ryzen 5 5600X, 32 GB, CachyOS, RADV from setup.sh's Mesa, CONSOLE=series-s, 1920x1080, no ray tracing (VICTORY_BVH_BUILDER=0 VICTORY_BVH_HARDWARE=0), VICTORY_FRAME_INTERVAL_MS=0, VICTORY_RECORD_PLACES=1 VICTORY_RECORD_RANGES=1 and the rest of our fork's run.sh defaults.

Runs Median fps Seconds with a frame over 100 ms Seconds under 20 fps Frame in the streaming bursts
Fork defaults (4 runs) 39.6 14.6 % 11.3 56.2 ms
VICTORY_PAGES=0 alone (1 run) 38.8 10.8 % 8 47.6 ms
VICTORY_LAZY_HIDDEN=1 alone (1 run) 41.1 12.8 % 8 52.1 ms
VICTORY_PAGES=0 VICTORY_LAZY_HIDDEN=1 (6 runs) 39.7 8.0 % 5.8 46.4 ms

The median does not move; the bursts get shorter. Together the two halve the mapping calls in the bursts (about 7,300 → 3,200 a second) and the submitting thread's time applying the title's page mappings (about 20 → 12 ms a frame). Most of the gain is VICTORY_PAGES=0 (already on main); this switch's own share is the difference between the second and fourth rows, with one run of the former. No broken image seen in those runs. More context in #636. Please measure on your own streaming scenes before trusting it.

Checks

  • One subject
  • Off by default; off = main
  • Docs: docs/SETTINGS.md and run.conf.default, both saying it only acts with VICTORY_BVH_HARDWARE=0
  • N/A: unit test (see above)
  • Queue checked: #596 changes um/residency.rs, not lazy binding; independent
  • cargo xtask policy
**@⁠Raptorbk45** on GitHub · 2026-12-05 22:37 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/639) `Raptorbk45:perf/lazy-hidden` → `main` · +43 −2 · 3 files · 1 commits · open **This only acts with `VICTORY_BVH_HARDWARE=0`.** On `main` the hardware node test is on by default wherever the card and driver have it (`VICTORY_BVH_HARDWARE` unset; `run.sh` exports `VICTORY_BVH_IN_PLACE=1`), and then this switch does nothing but log that it is ignored. It is for people who run with `VICTORY_BVH_HARDWARE=0` (no hardware node test; note that the low–high presets set `VICTORY_BVH_BUILDER=0` but not `VICTORY_BVH_HARDWARE=0`, so they still need it set). 8aec563 (#38) made lazy binding show every page to the card at once, because the nodes of a hardware BVH64 hold addresses the card follows without anything asking for them. Without the hardware node test nothing reads that way, so with `VICTORY_LAZY_HIDDEN=1` a lazily bound page that nothing has pointed the card at yet is mapped `HIDDEN` again (as before 8aec563) and shown when something does (`want` → `reveal`). Each page shown is an address-mapping call of about 40 µs on the submitting thread; in our streaming bursts a third to a half of the pages bound were never asked for. Off by default; with it off (or with `VICTORY_BVH_HARDWARE` not `0`) the protections passed are exactly `main`'s. ## How it was checked Run after the final edit, on Linux (CachyOS), against `main` at 8c4e6633: - `./build.sh check` (release, MSVC target): passes; the one warning (`room_lately` never used, `resource.rs`) is already on `main` - `cargo xtask policy`: passes - `cargo test -p victory-core --lib menu`: 18 passed Not run: the game, on this branch. The data below is from our fork. Branch head: `d0b388b8`. No unit test: the switch only changes the protection bits handed to the unified-memory driver path (`map`/`show_as`), which needs RADV with the unified-memory patch and a card; the decision itself is two env reads. ## Data (from our fork, not re-measured on this branch) Measured on our fork on 5 December 2026, the first 150 s of the world after loading the save where the arrest cinematic plays (the cinematic plays by itself; runs launched unattended), with a RADV build carrying extra counters. Conditions: RX 7700 XT 12 GB, Ryzen 5 5600X, 32 GB, CachyOS, RADV from `setup.sh`'s Mesa, `CONSOLE=series-s`, 1920x1080, **no ray tracing (`VICTORY_BVH_BUILDER=0 VICTORY_BVH_HARDWARE=0`)**, `VICTORY_FRAME_INTERVAL_MS=0`, `VICTORY_RECORD_PLACES=1 VICTORY_RECORD_RANGES=1` and the rest of our fork's `run.sh` defaults. | Runs | Median fps | Seconds with a frame over 100 ms | Seconds under 20 fps | Frame in the streaming bursts | |---|---:|---:|---:|---:| | Fork defaults (4 runs) | 39.6 | 14.6 % | 11.3 | 56.2 ms | | `VICTORY_PAGES=0` alone (1 run) | 38.8 | 10.8 % | 8 | 47.6 ms | | `VICTORY_LAZY_HIDDEN=1` alone (1 run) | 41.1 | 12.8 % | 8 | 52.1 ms | | `VICTORY_PAGES=0 VICTORY_LAZY_HIDDEN=1` (6 runs) | 39.7 | 8.0 % | 5.8 | 46.4 ms | The median does not move; the bursts get shorter. Together the two halve the mapping calls in the bursts (about 7,300 → 3,200 a second) and the submitting thread's time applying the title's page mappings (about 20 → 12 ms a frame). Most of the gain is `VICTORY_PAGES=0` (already on `main`); this switch's own share is the difference between the second and fourth rows, with one run of the former. No broken image seen in those runs. More context in #636. Please measure on your own streaming scenes before trusting it. ## Checks - [x] One subject - [x] Off by default; off = `main` - [x] Docs: `docs/SETTINGS.md` and `run.conf.default`, both saying it only acts with `VICTORY_BVH_HARDWARE=0` - N/A: unit test (see above) - [x] Queue checked: #596 changes `um/residency.rs`, not lazy binding; independent - [x] `cargo xtask policy`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 22:39:25 +00:00
Author
Owner

@⁠Milkhaus-tech on GitHub · 2026-12-06 03:52 UTC · original

Test results on RDNA 4. With VICTORY_LAZY_HIDDEN=1 the frame rate goes up, but the world does not load, and 1 run of 3 crashed.

Setup: RX 9060 XT 16 GB (Navi 44, 1002:7590), Ryzen 7 5800X, 32 GB RAM, Ubuntu 26.04 (kernel 7.0.0-44), repo Mesa 26.3.1 RADV, GE-Proton11-11, resizable BAR on. Build: main @ 8c4e663 with #596, #637 and this PR merged, so the other switches were off unless listed. Series X profile, potato preset, 1920x1080 output, VICTORY_FSR_4K=balanced, ML frame generation (FRAMEGEN=4), ray tracing off (preset BVH_BUILDER=0).

Method: VICTORY_BENCH_ROUTE=downtown with the same save restored before every run. I measured route start +30 s to +330 s from the stats: frame 5 s windows (about 59 windows per run). I took a screenshot at +150 s.

Arm Runs avg fps (rendered) frames >100 ms per min Picture
default 6 31.6 to 33.4 2.4 to 5.1 normal
BVH_HARDWARE=0 only 2 30.6, 31.1 6.1, 4.1 normal
LAZY_HIDDEN=1 + BVH_HARDWARE=0 3 39.8, 39.1, crash 1.4, 3.6 broken
  • The picture is broken. The log confirms the switch was active (lazy pages: the card is shown a mapping of the title's when something it runs reads the memory by address). At the +150 s point, where the BVH_HARDWARE=0-only run shows the bay, the island and the city, the lazy run shows a flat grey slab with water at one edge. The route car is a black silhouette: its body panels are missing, and only the chassis, wheels and frame bars draw. The cranes in the sky draw. So the ~25% fps gain comes from not drawing most of the world, not from cheaper mappings.
  • One of three runs crashed about 80 s into the route: first-chance exception 0xc0000005 at victory-image-…dll+0x50e732e (read 0x70: nothing mapped there), and then the title's breakpad report. None of the ~30 other runs on this build crashed.

My guess, untested: on this card something reaches some of those pages without going through the path that shows them, so they stay hidden. I have the logs and screenshots, and can run a debug build or extra logging if that helps.

**@⁠Milkhaus-tech** on GitHub · 2026-12-06 03:52 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/639#issuecomment-7451055500) Test results on RDNA 4. With `VICTORY_LAZY_HIDDEN=1` the frame rate goes up, but the world does not load, and 1 run of 3 crashed. **Setup:** RX 9060 XT 16 GB (Navi 44, `1002:7590`), Ryzen 7 5800X, 32 GB RAM, Ubuntu 26.04 (kernel 7.0.0-44), repo Mesa 26.3.1 RADV, GE-Proton11-11, resizable BAR on. Build: `main` @ `8c4e663` with #596, #637 and this PR merged, so the other switches were off unless listed. Series X profile, potato preset, 1920x1080 output, `VICTORY_FSR_4K=balanced`, ML frame generation (`FRAMEGEN=4`), ray tracing off (preset `BVH_BUILDER=0`). **Method:** `VICTORY_BENCH_ROUTE=downtown` with the same save restored before every run. I measured route start +30 s to +330 s from the `stats: frame` 5 s windows (about 59 windows per run). I took a screenshot at +150 s. | Arm | Runs | avg fps (rendered) | frames >100 ms per min | Picture | |---|---|---|---|---| | default | 6 | 31.6 to 33.4 | 2.4 to 5.1 | normal | | `BVH_HARDWARE=0` only | 2 | 30.6, 31.1 | 6.1, 4.1 | normal | | `LAZY_HIDDEN=1` + `BVH_HARDWARE=0` | 3 | 39.8, 39.1, crash | 1.4, 3.6 | **broken** | - **The picture is broken.** The log confirms the switch was active (`lazy pages: the card is shown a mapping of the title's when something it runs reads the memory by address`). At the +150 s point, where the `BVH_HARDWARE=0`-only run shows the bay, the island and the city, the lazy run shows a flat grey slab with water at one edge. The route car is a black silhouette: its body panels are missing, and only the chassis, wheels and frame bars draw. The cranes in the sky draw. So the ~25% fps gain comes from not drawing most of the world, not from cheaper mappings. - **One of three runs crashed** about 80 s into the route: `first-chance exception 0xc0000005 at victory-image-…dll+0x50e732e (read 0x70: nothing mapped there)`, and then the title's breakpad report. None of the ~30 other runs on this build crashed. My guess, untested: on this card something reaches some of those pages without going through the path that shows them, so they stay hidden. I have the logs and screenshots, and can run a debug build or extra logging if that helps.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/639/head:github-bot/gh-639'
git switch 'github-bot/gh-639'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-639'
git switch 'github-bot/gh-639'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-639'
git switch 'github-bot/gh-639'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-639'
git switch 'main'
git merge --squash 'github-bot/gh-639'
git switch 'main'
git merge --ff-only 'github-bot/gh-639'
git switch 'main'
git merge 'github-bot/gh-639'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.