xmem: opt-in lazy/file-backed physical pages for 1455 commit limit #297
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!297
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-297"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Adika713 on GitHub · 2026-11-26 19:27 UTC · original
Adika713:fix/lazy-physical-pages-rx9070xt→rx9070xt· +3552 −444 · 55 files · 73 commits · open## What and why
On a 32 GB Windows 11 host with a small pagefile (2688 MB, unchanged), Belobug
rx9070xt/cd8dfc06exits at ~4s before any frame presentation with:Windows commit limit reached while committing 6538919936 bytes of physical pages ... (os error 1455)This PR adds opt-in mitigations in
victory-hlexmem physical-page allocation:VICTORY_LAZY_PHYSICAL=1: for large reserved physical-page views, commit a 64 MiB prefix and register the rest for demand-commit via a vectored exception handler (64 KiB page granularity). Ranges are tracked and split/removed on unmap. Before kernel-write paths (ReadFile,fread, DirectStorage raw destination writes), lazy pages in the target range are explicitly committed.VICTORY_FILE_PHYSICAL=1: back physical-page sections with a temporary file inVICTORY_CACHE_DIR, else%LOCALAPPDATA%\victory\cache, elseTEMP, else cwd. Windows usesFILE_FLAG_DELETE_ON_CLOSE; file is also removed on section free. Falls back to normal section on failure.Both default off. Wine/file-backed whole-commit paths are preserved.
What is in it
crates/victory-hle/src/modules/xmem.rs: section backing metadata, lazy range tracking, VEH demand commit, explicit lazy pre-commit for kernel writes, file-backed section creation/cleanup, lazy cleanup on unmap, commit bookkeeping fixes.crates/victory-hle/src/modules/files.rs:ensure_lazy_committedbeforeReadFile/freadkernel writes.crates/victory-hle/src/modules/dstorage.rs:ensure_lazy_committedbefore raw DirectStorage destination kernel writes.lazy_range_tracking_splits_on_remove.Tested
Hardware: Windows 11, AMD Radeon RX 6950 XT 16 GB, Ryzen 5 3600, 32 GB RAM, 2688 MB pagefile unchanged. Game files supplied locally; not included.
Commands/tests (F: target dir):
cargo build -p victory -p victory-hle- OK.cargo test -p victory-hle --lib xmem -- --test-threads=1- 18 passed, 0 failed, 1 ignored.cargo test -p victory-hle --lib lazy_range_tracking_splits_on_remove -- --test-threads=1- 1 passed.Measured monitored runs (
_agent_reports/test-story-belobug-rx9070xt.ps1, series-x, 1280x720,VICTORY_WINDOW_BUDGET_MB=64,VICTORY_TEXTURE_MAX=128, no RT, DRED light where noted):20261126-193000elapsed_s=4 stop=exited, 0 frames. 1455 6.1 GiB physical-page commit, then0x80000003.20261126-195526199s exited, 11 presented/max1024. No 1455. 0x887A0007 device removed after 28 submissions (RELAY=1).20261126-200207264s exited, 11 presented/max1024. No 1455. 0x887A0007 after 18 submissions. User observed cutscene audio further and "directed by" on black screen (user observation; not FPS/visual proof).20261126-202519300s timeout_killed, 12 presented/max2048,world_entry=Falseheuristic. No 1455/0x887A0007/0x8007000E markers. Shots non-black but not render proof.20261126-203609300s timeout_killed, 22 presented/max1024. No 1455/0x887A0007/0x8007000E.20261126-204416a202dc8a)300s timeout_killed, 24 presented/max2048. No 1455/0x887A0007/0x8007000E.20261126-205115301s timeout_killed, 24 presented/max2048. No 1455/0x887A0007/0x8007000E.20261126-205650189s exited, 12 presented/max2048. No 1455/0x887A0007 marker found; many0x8007000Eshared-buffer/memory allocation failures. Single run.Caveat:
frame_presented_log_countcomes from power-of-twoframe presentedlogs and harness lacksinterval_us; it is not FPS proof.Not tested
victory-hletest suite beyond xmem module tests above.ReadFile,fread, DirectStorage raw destination path; other kernel-write APIs not exhaustively audited.AI use
OpenCode / opencode/big-pickle (AI-assisted). I reviewed code changes and ran the commands/tests listed above; results are reported only where measured.
@Adika713 on GitHub · 2026-11-26 19:31 UTC · original
## Measured run update (same WIP branch, local test PC)
Hardware: Win11 / RX 6950 XT 16 GB / Ryzen 5 3600 / 32 GB RAM / 2688 MB pagefile unchanged.
Build:
1be739a5(fix/lazy-physical-pages-rx9070xt),cargo build -p victory -p victory-hleOK.Test:
cargo test -p victory-hle --lib xmem -- --test-threads=1=> 18 passed, 0 failed, 1 ignored.New run:
test-belobug-rx9070xt-series-x-20261126-202519Config: series-x, 1280x720,
VICTORY_WINDOW_BUDGET_MB=64,VICTORY_TEXTURE_MAX=128, no RT,VICTORY_LAZY_PHYSICAL=1,VICTORY_FILE_PHYSICAL=1,VICTORY_RELAY=0,VICTORY_RELAY_COPY=0,VICTORY_CARD_STEPS=0,VICTORY_D3D12_DRED=light.Measured summary:
elapsed_s=300 stop=timeout_killedframe_interval_count=0max_frame_logged=2048frame_presented_log_count=12world_entry_candidate=False(insufficient_present_samples)os error 1455/ physical-page commit-limit failure observed.0x887A0007device-removed /0x8007000EOOM markers observed in notable scan.This is better than the 4s 1455 baseline and better than earlier 171-264s device-removal runs with RELAY=2, but it is not stable ingame/FPS proof. Frame-present logs stop at frame 2048 around 19:26:35 while process continues; needs investigation (present pacing/logging/black-screen path).
AI-assisted: OpenCode / opencode/big-pickle.
@MamaLeVrai on GitHub · 2026-11-26 19:34 UTC · original
Tested on an RX 6950 XT (RDNA2), Windows 11 build 26300, Rust 1.98.1, head
1be739aonrx9070xtcd8dfc0.cargo test --release -p victory-hle --lib, twice: 160 passed, 0 failed, 2 ignored. The newlazy_range_tracking_splits_on_removepasses too.Reading the change, I see four things. The first matters for the lazy mode in the game:
ReadFilestraight into title memory, the call fails withERROR_NOACCESS(998) and no exception is raised. I checked this on this machine:ReadFileof 4 KiB into a freshSEC_RESERVEview returns998; afterVirtualAlloc(MEM_COMMIT)of the page it reads 92 bytes.files::ReadFilepasses title buffers straight to the kernel, and its comment says the title's synchronous reads "retry a failedReadFileforever". WithVICTORY_LAZY_PHYSICAL=1, a read into a page past the 64 MiB prefix would then hang the title. One way out: commit the lazy pages of[buffer, buffer + len)infiles::ReadFile, infreadand in DirectStorage's reads before the kernel call. Thekernel_writingcall already marks that spot.lazy_hasusestry_lock. If another thread holdsLAZY(register_lazyorlazy_removeon a map or an unmap) when a lazy page faults, the handler returns "continue search". The access violation then goes unhandled and the title crashes. ARwLockread, or a plainlock()(no thread faults while holding it), avoids that.Section::commit_runs/Section::commit,lazy_partialdepends only onlazy_physical_enabled() && len > LAZY_PREFIX, not on whethercommit()took the lazy path. With the variable set and enough commit, the pages past 64 MiB stay unmarked and get committed again on each later request. That costs time but returns the right result.VICTORY_CACHE_DIRin the environment (victory.toml'scache_diris not read here), the files go to the current directory. That is the repository withscripts\play.ps1, whichPush-Locations there. They are removed only when theSectiondrops, so a crash or a killed run leaves multi-GiB files behind.FILE_FLAG_DELETE_ON_CLOSEon the file handle would remove them in every case.Side note from this machine: the same card here (RX 6950 XT) also loses the device with
0x887A0007a while after the world comes up, with DRED showing no list in flight, onmain-based builds. It happened with the commit limit nearly reached, and once with a 64 GiB paging file, though GPU tests of mine were running at the same time in that run. So the device loss you hit after getting past 1455 is probably not caused by this PR.AI-assisted (Claude Code); no game data.
@Adika713 on GitHub · 2026-11-26 19:44 UTC · original
## Update: 203609 A/B + WIP fix for review feedback (not runtime-validated yet)
Hardware: Win11 / RX 6950 XT 16 GB / Ryzen 5 3600 / 32 GB RAM / 2688 MB pagefile unchanged.
Branch:
Adika713:fix/lazy-physical-pages-rx9070xt(a202dc8apushed).Measured run
test-belobug-rx9070xt-series-x-20261126-203609Config: series-x 1280x720, budget 64, tex 128, no RT,
LAZY=1 FILE=1 RELAY=0 RELAY_COPY=0 CARD_STEPS=2 DRED=light.elapsed_s=300 stop=timeout_killedframe_presented_log_count=22 max_frame_logged=1024 frame_interval_count=0world_entry_candidate=False (insufficient_present_samples)Compared to 202519 (
CARD_STEPS=0): both survived 300s with no device removal/1455 in these runs; neither is FPS/world-entry proof. Frame-present logs are power-of-two only and harness lacksinterval_us.Code changes in
a202dc8a(addresses part of @MamaLeVrai review; not game-runtime tested yet)xmem::ensure_lazy_committed(base,len)and call it before kernel-write paths inReadFile,fread, and DirectStorage raw destination writes. Intended to avoid kernelERROR_NOACCESSon uncommitted lazy pages.lazy_hasto use blockingLAZY.lock()instead oftry_lock()to avoid VEH returning continue-search under lock contention.commit/commit_shownnow track actual committed page count; lazy partial commits mark only prefix committed (fixes repeated recommit bookkeeping).FILE_FLAG_DELETE_ON_CLOSE/ cache-dir source), and I have not yet audited every kernel-write destination path beyond the three above.Tests/build:
cargo test -p victory-hle --lib xmem -- --test-threads=1=> 18 passed, 0 failed, 1 ignored.cargo build -p victory -p victory-hleOK.AI-assisted: OpenCode / opencode/big-pickle. No game data included.
@Adika713 on GitHub · 2026-11-26 19:50 UTC · original
## Measured run: 204416 (
a202dc8abinary, runtime validation of kernel-write lazy commit fix)Hardware: Win11 / RX 6950 XT 16 GB / Ryzen 5 3600 / 32 GB RAM / 2688 MB pagefile unchanged.
Config: series-x 1280x720, budget 64, tex 128, no RT,
LAZY=1 FILE=1 RELAY=0 RELAY_COPY=0 CARD_STEPS=0 DRED=light, 300s max.elapsed_s=300 stop=timeout_killedframe_presented_log_count=24 max_frame_logged=2048 frame_interval_count=0world_entry_candidate=False (insufficient_present_samples)(heuristic)Compared to 202519 (same env, pre-a202dc8a): both 300s timeout_killed, no 1455/device-removal in these runs; 204416 had 24 frame-present log lines vs 12, but logging is power-of-two and not FPS proof.
Pushed
7aa13c7: file-backed physical sections now useFILE_FLAG_DELETE_ON_CLOSE(Windows) to avoid leaving temp files on crash. Still not a full fix for cache-dir selection fromvictory.toml.AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 19:56 UTC · original
## A/B: FILE_PHYSICAL only (205115,
7aa13c78binary)Config: series-x 1280x720, budget 64, tex 128, no RT,
LAZY=0 FILE_PHYSICAL=1 RELAY=0 RELAY_COPY=0 CARD_STEPS=0 DRED=light, 300s.elapsed_s=301 stop=timeout_killedframe_presented_log_count=24 max_frame_logged=2048 frame_interval_count=0world_entry_candidate=False (insufficient_present_samples)Similar survival to LAZY+FILE runs at this config; not an ingame/FPS proof. Next A/B: LAZY=1 FILE=0.
AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 20:00 UTC · original
## A/B: LAZY_PHYSICAL only (205650,
7aa13c78binary)Config: series-x 1280x720, budget 64, tex 128, no RT,
LAZY=1 FILE_PHYSICAL=0 RELAY=0 RELAY_COPY=0 CARD_STEPS=0 DRED=light, 300s.elapsed_s=189 stop=exited exit_code=frame_presented_log_count=12 max_frame_logged=2048 frame_interval_count=0world_entry_candidate=False (insufficient_present_samples)no shared buffer ... 0x8007000Eandmemory allocation of 7864416 bytes failed; final sample free phys ~8.2GB, commit headroom ~1.7GB (process already exited). No 1455/0x887A0007 device-removed marker found.This A/B is worse than FILE-only / LAZY+FILE on the same settings (early exit with host OOM/resource exhaustion), but it is only one run.
AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 20:11 UTC · original
## Code update (no new game run)
Pushed
d0a666a9: file-backed physical sections now preferVICTORY_CACHE_DIR, else%LOCALAPPDATA%\victory\cache, elseTEMP, before cwd fallback. This reduces risk of leaving large temp files in the repo/workdir when delete-on-close is not effective; still not readingvictory.tomlcache_dir directly from xmem.Per @MamaLeVrai review: kernel-write lazy commit pre-commit added for ReadFile/fread/DStorage raw dest (
a202dc8a), lazy_has uses blocking lock, lazy commit bookkeeping fixed, FILE_FLAG_DELETE_ON_CLOSE added for Windows. Remaining: audit other kernel-write paths (e.g. any other ReadFile/overlapped destinations into lazy pages), and ideally plumb configured cache_dir.No new game tests started (user requested pause).
AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 20:15 UTC · original
## Code update (no new game run)
Pushed
18c698f:ensure_lazy_committednow removes committed ranges fromLAZYtracking after explicit pre-commit for kernel-write paths. This avoids repeated VEH/range work on already-committed pages; section commit bitmaps are not updated there (VirtualAlloc MEM_COMMIT is idempotent; later paths self-heal).Validated locally (no game):
cargo test -p victory-hle --lib xmem -- --test-threads=1=> 18 passed, 0 failed, 1 ignored; build OK.Still not game-runtime tested per your pause request.
AI-assisted: OpenCode / opencode/big-pickle.
@JFIREonFIRE on GitHub · 2026-11-26 20:34 UTC · original
A measurement that may help here, from an RTX 3090 / 32 GB PC with a system-managed page file (details and the runs in #333): the process's private bytes track the card's memory in use one for one (fit over ~380 memory lines, R² ≈ 1.000), while the working set grows only 0.1–0.3 MB per MB of VRAM. Of ~38–42 GB private, about 20 GB was the commit charge of the card's own memory; the working set peaked at 21–25 GB. So on a 32 GB PC with a small page file, the commit limit runs out well before the RAM does, and VRAM use (the 10-minute texture cache in
vram_keepfills it to 88%) is a large part of it. Lazy or file-backed physical pages address the title's share; the card's share may need the page file or a lower VRAM ceiling.Measured and written with Claude Code (AI).
@Adika713 on GitHub · 2026-11-26 20:43 UTC · original
## Measured run (213626,
b82a5db8, no new code changes)Hardware: Win11, RX 6950 XT 16GB, Ryzen 5 3600, 32GB RAM, 2688MB pagefile unchanged.
LAZY=1 FILE=1 RELAY=0 RELAY_COPY=0 CARD_STEPS=0 DRED=light, 300s.elapsed_s=300 stop=timeout_killed.frame_presented_log_count=11 max_frame_logged=1024 frame_interval_count=0,present_log_span_s=63.608 present_frame_delta=1023 present_log_fps_estimate=16.083(heuristic from power-of-two present logs; not FPS proof).world_entry_candidate=False (insufficient_present_samples).victory_gpu::pool: no block of texture memory ... 0x8007000E; no 1455/commit-limit/device-removed marker found in summary.Also ran 213220 with harness-default RELAY=2/CARD_STEPS=2 (script args not honored by this harness version): 179s exited, device removed
0x887A0004after 2 submissions ahead; not a RELAY=0 A/B.AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 20:50 UTC · original
## Measured A/B: frame interval override (214521,
b82a5db8)Hardware: Win11, RX 6950 XT 16GB, Ryzen 5 3600, 32GB RAM, 2688MB pagefile unchanged.
LAZY=1 FILE=1 RELAY=0 RELAY_COPY=0 CARD_STEPS=0 DRED=light,VICTORY_FRAME_INTERVAL_MS=16.667,VICTORY_TIMER_LOG=1, 300s requested.elapsed_s=248 stop=exited exit_code=(early exit before 300s). No 1455/device-removed marker found in summary notable lines.frame_presented_log_count=12 max_frame_logged=2048 frame_interval_count=0,present_log_span_s=72.153 present_frame_delta=2047 present_log_fps_estimate=28.37(heuristic; not FPS proof).memory allocation of 71303184 bytes failed; final sample free phys ~4.7GB, commit headroom ~2.1GB.Comparison: 213626 (same base config, no frame interval override)
300s timeout_killed, 11 presented/max1024, heuristic 16.083,0x8007000Etexture-pool warning. 214521 did not improve stability; it exited early with large allocation failure and late pacing collapse.Harness note:
test-story-belobug-rx9070xt.ps1currently ignores-VictoryRelay/-VictoryLazyPhysical/...style args; overrides must be set via env vars before launch. I patched the local harness copy to preserveVICTORY_FRAME_INTERVAL_MS/TITLE_FPS/TIMER_LOG.AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 20:59 UTC · original
## Measured A/B: lower texture pressure (215349,
b82a5db8)Hardware: Win11, RX 6950 XT 16GB, Ryzen 5 3600, 32GB RAM, 2688MB pagefile unchanged.
LAZY=1 FILE=1 RELAY=0 RELAY_COPY=0 CARD_STEPS=0 DRED=light,TIMER_LOG=1, 300s.elapsed_s=295 stop=exited exit_code=.frame_presented_log_count=11 max_frame_logged=1024 frame_interval_count=0,present_log_span_s=62.547 present_frame_delta=1023 present_log_fps_estimate=16.356(heuristic; not FPS proof).os error 1450(insufficient system resources),0x8007000Etexture-pool/shared-buffer warnings, and finalmemory allocation of 1114112 bytes failed(process abort). No 1455/device-removed marker found.Comparison: 213626 budget64/tex128 LAZY+FILE RELAY=0 300s timeout_killed with texture-pool 0x8007000E; 214521 added FRAME_INTERVAL_MS and exited 248s with 71MB alloc failure. Lowering budget/tex did not remove resource pressure.
AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 21:06 UTC · original
## Measured run: lower pressure, file-only (220229,
b82a5db8)Hardware: Win11, RX 6950 XT 16GB, Ryzen 5 3600, 32GB RAM, 2688MB pagefile unchanged.
LAZY=0 FILE_PHYSICAL=1 RELAY=0 RELAY_COPY=0 CARD_STEPS=0 DRED=light TIMER_LOG=1, 180s.elapsed_s=180 stop=timeout_killed.frame_presented_log_count=12 max_frame_logged=2048 frame_interval_count=0,present_log_span_s=115.103 present_frame_delta=2047 present_log_fps_estimate=17.784(heuristic; not FPS proof).This is a better short-run survival signal than 214521/215349, but still not world-entry/visual-correctness/15-20fps proof.
AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 21:10 UTC · original
## Measured A/B: low pressure FILE-only vs LAZY+FILE (
b82a5db8)Hardware: Win11, RX 6950 XT 16GB, Ryzen 5 3600, 32GB RAM, 2688MB pagefile unchanged. 720p, budget 32, tex 64, no RT, RELAY=0, CARD_STEPS=0, DRED=light, TIMER_LOG=1, RUST_BACKTRACE=1, 180s.
Both survived 180s with no 1455/0x8007000E/os error 1450/device-removed/alloc-failure markers found by summary scan. Shots non-black, not render proof. Not world-entry/visual-correctness proof.
AI-assisted: OpenCode / opencode/big-pickle.
@MamaLeVrai on GitHub · 2026-11-26 21:34 UTC · original
Thanks, the four points look handled at
b82a5db:ensure_lazy_committedbefore the kernel writes infiles::ReadFile,freadand DirectStorage's raw reads;lazy_hasnow takes the lock (and returns early when nothing is lazy);FILE_FLAG_DELETE_ON_CLOSE; the cache folder by default.cargo test --release -p victory-hle --libon the RX 6950 XT: 160 passed, 0 failed, 2 ignored.AI-assisted (Claude Code); no game data.
@Adika713 on GitHub · 2026-11-26 21:44 UTC · original
## Measured run: low pressure FILE-only, 300s (223853,
b82a5db8)Hardware: Win11, RX 6950 XT 16GB, Ryzen 5 3600, 32GB RAM, 2688MB pagefile unchanged.
LAZY=0 FILE_PHYSICAL=1 RELAY=0 RELAY_COPY=0 CARD_STEPS=0 DRED=light TIMER_LOG=1 RUST_BACKTRACE=1, 300s.elapsed_s=300 stop=timeout_killed.frame_presented_log_count=11 max_frame_logged=1024 frame_interval_count=0,present_log_span_s=63.515 present_frame_delta=1023 present_log_fps_estimate=16.107(heuristic; not FPS proof).Compared to earlier collapsing runs (214521 early exit + alloc failure; 215349 os error 1450/0x8007000E/alloc failure), this lower-pressure FILE-only config is the most stable so far on this machine. Still not world-entry/visual-correctness/15-20fps proof.
AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 21:48 UTC · original
## Measured run: 540p low pressure FILE-only (224516,
b82a5db8)Hardware: Win11, RX 6950 XT 16GB, Ryzen 5 3600, 32GB RAM, 2688MB pagefile unchanged.
VICTORY_DISPLAY_MODE/Resolution 540p (-Resolution 540p), budget 32, tex 64, no RT,LAZY=0 FILE_PHYSICAL=1 RELAY=0 RELAY_COPY=0 CARD_STEPS=0 DRED=light TIMER_LOG=1 RUST_BACKTRACE=1, 180s.elapsed_s=182 stop=timeout_killed.frame_presented_log_count=12 max_frame_logged=2048 frame_interval_count=0,present_log_span_s=71.827 present_frame_delta=2047 present_log_fps_estimate=28.499(heuristic; not FPS proof).Compared to 720p/32/64 FILE-only 223853 (300s timeout_killed, heuristic 16.107, tight 0.25GB commit headroom), 540p gave a higher heuristic present-log rate and much more free physical RAM in this run. Still not world-entry/visual-correctness/15-20fps proof.
AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 21:49 UTC · original
Correction to previous comment (224516): the run was not 540p. I passed
-Resolution 540pbut the harness parameter is-DisplayMode; it defaulted todisplay=1280x720as shown in the summary. Treat 224516 as another 720p/32/64/FILE-only/LAZY=0 180s run (timeout_killed, heuristic 28.499, no 1455/0x8007000E/1450/device-removed/alloc-fail markers found). Sorry for the config labeling error.AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 21:51 UTC · original
Thanks for rechecking
b82a5db8on RX 6950 XT - appreciate the confirmation (160 passed, 0 failed, 2 ignored).I’ve continued measured A/Bs on the same class of machine (RX 6950 XT/32GB/2688MB pagefile unchanged). Best survival so far is low-pressure FILE-only (
LAZY=0 FILE=1, 720p budget32 tex64, RELAY=0, 300s timeout_killed), while higher-pressure/frame-interval runs still hit0x8007000E/os error 1450/alloc failures. No world-entry/FPS/visual-correctness proof yet; present-log FPS is heuristic only.AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 21:51 UTC · original
Thanks for the data point - this lines up with what we’re seeing on RX 6950 XT / 32GB / 2688MB pagefile.
On our 300s low-pressure FILE-only run (223853, 720p budget32 tex64 no RT,
LAZY=0 FILE=1 RELAY=0): survived to timeout_killed, final sample showed free phys ~2.8GB but commit headroom only ~0.25GB. Earlier collapsing runs hit0x8007000E, dstorageos error 1450, and alloc failures before/during exit (214521 had a 71MB alloc failure). We haven’t measured VRAM-vs-private-byte correlation here yet, but your R²≈1.000 finding is a useful explanation for why commit headroom collapses even when working set/free phys look less dire.Actionable takeaway for this PR: lazy/file-backed physical pages help title-side commit, but we likely still need VRAM/texture-pressure controls (budget/tex caps, cache behavior) on small-pagefile 32GB hosts. No pagefile changes made in our tests.
AI-assisted: OpenCode / opencode/big-pickle.
@Adika713 on GitHub · 2026-11-26 22:13 UTC · original
## Measured 300s A/B with E_OUTOFMEMORY/1450 diagnostics (local instrumented build,
b82a5db8base)Hardware: Win11, RX 6950 XT 16GB, Ryzen 5 3600, 32GB RAM, 2688MB pagefile unchanged.
Config: series-x 1280x720, budget 32, tex 64, no RT,
RELAY=0 RELAY_COPY=0 CARD_STEPS=0 DRED=light TIMER_LOG=1 RUST_BACKTRACE=1, 300s.Shots non-black, not render proof. No world-entry/visual-correctness/15-20fps proof.
Diagnostics added locally (not pushed):
residency::allocation_errorlogs commit headroom on E_OUTOFMEMORY + texture-upload pause;poolincludes block size on texture-block failure;hostreportsresidency::allocation_erroron shared-buffer failure; dstorage logsraw_os_erroron read failures.AI-assisted: OpenCode / opencode/big-pickle.
@adrianmjim on GitHub · 2026-11-26 22:45 UTC · original
Checked by reading the code on rx9070xt
cd8dfc0(headb82a5db); I did not build or run it. Lines inxmem.rsare atb82a5db, lines inwatch.rsatcd8dfc0. Nothing merged into a-publier since (4eb6cfd) changesxmem.rsor the cited parts ofwatch.rs.Lazy mode and the GPU write guards
XMemMapPhysicalPagescallsvictory_gpu::title_memory_remapping()(xmem.rs:1296), which installs the watch'son_writehandler withfirst=1(watch.rs:3577, 3857). Only after that does it reachshow->commit_shown->commit->register_lazy, and that first touch ofVEHinstallscommit_on_demand, also withfirst=1(xmem.rs:1884). Socommit_on_demandsits ahead of the watch's handler.register_lazy(base, len)(xmem.rs:2033) registers the whole view, including the 64 MiB prefix that was just committed.commit_on_demand(xmem.rs:1886-1896) never removes the page it commits; onlyensure_lazy_committedremoves what it commits (xmem.rs:1943). Solazy_hasis true for the prefix and for fault-committed pages, for as long as the view is mapped.PAGE_READONLY(watch.rs:3039, 3068-3072). It needs the write fault to reachon_writeso it can open the block and mark it written. WithVICTORY_LAZY_PHYSICAL=1, a title write to a guarded block inside a lazy range goes tocommit_on_demandfirst. That runsVirtualAlloc(MEM_COMMIT, PAGE_READWRITE)on a page that is already committed and returnsEXCEPTION_CONTINUE_EXECUTION. The watch's handler never sees the fault.VirtualAllocresets the protection. I have not tested this. If it resets it to read-write, the write goes through and the watch still counts the block as protected and clean. The copies of it keep the old bytes. The watch never guards the block again, because it already counts it as protected. If it does not reset it, the same write faults again forever on that thread.commit_on_demand, checkVirtualQueryand only act whenState == MEM_RESERVE(otherwise return 0). Alsolazy_removethe page after committing it, and register only[base + prefix, base + len).LAZYmutex before the watch sees it (xmem.rs:1899-1902). Committed pages that stay registered make that last as long as the view is mapped.The LAZY=1 FILE=1 runs
commitreturns before the lazy branch when the section is file-backed (xmem.rs:2012-2013). So withVICTORY_FILE_PHYSICAL=1, the lazy path only runs if creating the file-backed section failed and the code fell back to the pagefile (xmem.rs:782).Stale lazy ranges
View::map(xmem.rs:841) andSection::window(xmem.rs:447) can also take the lazy path, when their commit of more than 64 MiB hits 1455.View::drop(xmem.rs:857) andSection::drop(xmem.rs:495) unmap those views without callinglazy_remove. Their ranges stay inLAZY. If that address range is used for something else later, the handler orensure_lazy_committedwould commit it read-write.Not checked: what
VirtualAlloc(MEM_COMMIT)does to the protection of an already committed read-only page in a section view; the logs of any run.@Adika713 on GitHub · 2026-11-26 23:15 UTC · original
Measured update (local diag build, includes xmem VEH/watch hardening for adrianmjim review; not claiming stability/FPS/world-entry)
Hardware: Win11, RX 6950 XT 16GB, Ryzen 5 3600, 32GB RAM, 2688MB pagefile unchanged.
Config: series-x 720p, budget32, tex64, no RT,
LAZY=0 FILE=1 RELAY=0 RELAY_COPY=0 CARD_STEPS=0 JOIN_COPIES=0 INDIRECT_WINDOW=0 INDIRECT_BATCH=0 MAP_THREADS=0 WIDE_BACK=0 CARD_REHASH_RUNS=0 DRED=light,PIPELINE_BOOK=1,VICTORY_LIBRARY_DIR=F:\victory-cache-retail\pipelines-shared.memory allocation of 2162688 bytes failed, then18874368 bytes failed; “skipping backtrace printing to avoid potential recursion”. No scanned 1455/1450/0x8007000E/0x887A0007/E_OUTOFMEMORY/texture-upload-pause markers. Shared pipeline lib saved (host-pipelines.bin263672).RUST_BACKTRACE=fullhost pipeline library loaded bytes=263672 mapped=true. Heuristic present estimate 29.343 over 34s span only (frame_interval_count=0) - not FPS proof.RUST_BACKTRACE=fullmemory allocation of 71303184 bytes failedlogged; run still reached 180s timeout. Backtrace shows hashbrown/raw table resize invictory_shader::structure::*path (full symbol/name partially interleaved in stderr), so alloc pressure may be shader/structure-table related.host pipeline library loaded bytes=270826 mapped=true.Code update pushed:
ee1e2d80onAdika713:fix/lazy-physical-pages-rx9070xtaddresses adrianmjim’s review: VEH demand-commit only onMEM_RESERVEpages; committed lazy page removed fromLAZY; deferred tail only registered as lazy;View::drop/Section::dropcalllazy_remove.cargo test -p victory-hle --lib xmem -- --test-threads=1=> 18 passed, 0 failed, 1 ignored (F: target). Not game-tested in a LAZY=1 fallback case yet.Caveats: heuristic present-log estimate is not FPS/world-entry/visual proof. Rust alloc failures remain a blocker on this 32GB/2688MB-pagefile machine; 000852 shows they can be non-fatal in at least one run but still indicate pressure. No pagefile changes.
@adrianmjim on GitHub · 2026-11-26 23:29 UTC · original
Thanks. I checked
ee1e2d8(the two commits after it don't touchxmem.rs) and rancargo test -p victory-hle --lib xmem -- --test-threads=1: 18 passed here too.The VEH change does what I asked: pages that are already committed now fall through to the watch's handler. I also tested the open question from my last comment with a small standalone program. Two views of one
SEC_RESERVEsection:VirtualAlloc(MEM_COMMIT, PAGE_READWRITE)on an already committedPAGE_READONLYpage succeeds and sets it back to read-write. So the old handler would have silently dropped guards.MEM_COMMITinVirtualQuerythrough the other, so aliases are covered as well.Registering only the deferred tail, and removing pages once the fault commits them, also look right.
Two things still look wrong to me (both only with
LAZY=1):ensure_lazy_committeddoesn't roundendup to 64 KiB (let end = base.saturating_add(len)). TakeReadFile(P+0x100, 0x2000)into a lazy range:lazy_removethen leaves a range starting at the unaligned P+0x2100.commit_on_demandlooks up the page base P.lazy_has(P)is false. Even if it weren't,VirtualQueryat the 64 KiB base reportsMEM_COMMIT, because its first 4 KiB pages are committed (I checked this case too). So nobody handles the access violation.endup toPAGE, and querying the faulting address rather than the page base, would fix it.View::dropandSection::drop,lazy_removeruns after the unmap. Another thread'sView::mapcan get the same address back in between and register its deferred tail, and the latelazy_removethen deletes that registration. Its next write to the tail is an unhandled access violation. Callinglazy_removebefore the unmap, asunmap()already does, closes this.Smaller points:
NotLazythe stale entry stays registered, so every later fault on that page pays the mutex plus aVirtualQuery. A committed page of aSEC_RESERVEview can't go back to reserved, so it's safe tolazy_removeit there.info.Type == MEM_MAPPEDwould be cheap hardening.SEC_RESERVEview,register_lazyit, commit one page and make it read-only. Then check thatcommit_fault_pagereturnsNotLazyand leaves the protection alone.Still open from before: do the
LAZY=1 FILE=1logs show the "committed prefix and deferred" warning? If not, those runs never took the lazy path. As far as I can see,commitleaves before it for file-backed sections.@Adika713 on GitHub · 2026-11-27 01:41 UTC · original
Thanks for the detailed follow-up on
ee1e2d8.I pushed
66d859b9onAdika713:fix/lazy-physical-pages-rx9070xt(PR #297 head) to address the points you called out:ensure_lazy_committed: roundsendup to 64 KiB (PAGE) and advances by the aligned committed length, so kernel-write precommits do not leave an unaligned tail hole.commit_fault_page: when a page is alreadyMEM_COMMIT|MEM_MAPPEDinside lazy tracking, it returnsNotLazyand removes stale lazy tracking for that page; it also requiresMEM_MAPPEDbefore demand-committing a reserved page.View::drop/Section::drop:lazy_removenow runs beforeUnmapViewOfFile/UnmapViewOfFile2, matching theunmap()ordering.commit_fault_page_leaves_committed_guarded_page_alone: maps aSEC_COMMITview, registers lazy, protects one pagePAGE_READONLY, assertscommit_fault_pagereturnsNotLazyand protection staysPAGE_READONLY.Verified locally (Windows 11, no game run, F: target dir):
Open/remaining:
LAZY=1fallback case after this patch (user asked to pause game tests because Enter/input is unreliable).LAZY=1 FILE=1observation still looks right from code:commit()returns early for file-backed sections, so lazy demand-commit is only exercised when file-backed section creation falls back. I have not added new log-confirmed LAZY+FILE evidence in this turn.ReadFile(P+0x100,0x2000)then fault-at-P+0x8000case you described; the alignment fix is in place, but that specific regression test would be good follow-up.AI-assisted: OpenCode / opencode/big-pickle. No game data included.
@adrianmjim on GitHub · 2026-11-27 01:44 UTC · original
Checked
66d859b: the four changes are what I meant.ensure_lazy_committedroundsendup toPAGEand steps by the aligned length.commit_fault_pageneedsMEM_MAPPED, and drops the stale entry on a committed page.Drops now calllazy_removebefore the unmap.Since commits now cover whole 64 KiB pages, the base-address
VirtualQueryno longer sees the half-committed page from my example.cargo test -p victory-hle --lib xmem -- --test-threads=1gives 19 passed, 1 ignored here (Windows 11, RX 7900 XT machine, no game), including the newcommit_fault_page_leaves_committed_guarded_page_alone.No further points from me on the lazy path. The unaligned
ReadFile(P+0x100, 0x2000)regression test would still be a nice follow-up, as you say. It can stay game-free by callingensure_lazy_committedon a registeredSEC_RESERVEview and checkingVirtualQueryat P+0x8000.@Adika713 on GitHub · 2026-11-27 13:19 UTC · original
## Measured post-warm runs on
988d4796(no game input automation; game stopped after log capture)Hardware: Win11, RX 6950 XT 16GB, Ryzen 5 3600, 32GB RAM, 2688MB pagefile unchanged. Build from this PR worktree (
988d4796), debugvictory.exe. Cache:F:\victory-cache-retail, shared pipeline libF:\victory-cache-retail\pipelines-shared.Pipeline warm
victory warm --usedcompleted: 83598 pipelines known, 2581 to make, 8 processes, 2581 made in 36s (8 had no host pipeline, 0 ended process); median 15.7ms, p90 142.5ms, p99 543.7ms, max 9575ms. Log: localwarm-pr297-20261127-140100.log.Post-warm game run (stopped by request after capture)
Config:
--console series-s --execute, 960x540,VICTORY_WINDOW_BUDGET_MB=16,VICTORY_TEXTURE_MAX=16,VICTORY_LAZY_PHYSICAL=1,VICTORY_FILE_PHYSICAL=1,VICTORY_RELAY=0,VICTORY_RELAY_COPY=0,VICTORY_CARD_STEPS=0,VICTORY_JOIN_COPIES=0,VICTORY_INDIRECT_WINDOW=0,VICTORY_INDIRECT_BATCH=0,VICTORY_MAP_THREADS=0,VICTORY_WIDE_BACK=0,VICTORY_CARD_REHASH_RUNS=0,VICTORY_D3D12_DRED=light,VICTORY_PIPELINE_BOOK=1.Observed frame-summary snapshots (err log, not full-run proof):
30.0 fps, 33.3 ms/frame ... dropped 0 without a host pipeline0.3 fps, 3387.2 ms/frame (1131.2 preparing: copies 171.6 ms 234.0 MB, textures 826.9 ms 100.2 MB; 167.0 on the GPU; 2072.2 copying back 61.5 MB), 1800 draws/frame, dropped 1020 without a host pipeline (0 being made)913.9 ms, ... 13.9 ms waiting for title memory to hold still ...; another sample5623.5 ms ... 4045.0 ms waiting for title memory to hold stillBest-known Nxssie-style base (same config family, RELAY=0) rerun
Same machine/config as above (FILE+LAZY, RELAY=0), separate run. Snapshots degraded similarly:
0.2-0.4 fps, ~3160-4438 ms/frame, copies 50-197ms/110-259MB, textures 1085-1874ms/108-175MB, GPU 99-286ms, copy-back 1032-2250ms/32-55MB, 861-4830 draws/frame, 166-744 dropped without host pipeline (0 being made). Texture refreshes showed 1758-5624ms with 0-4045ms "waiting for title memory to hold still". No 1455/0x887A0007/0x8007000E markers found in scanned summary lines for this run.This is not a claim of world-entry/FPS/stability improvement; it’s an objective regression signal that prewarm alone didn’t address the dominant texture-refresh hold-still/copy-back/descriptor-heavy path in these captures. I’m investigating those hot paths next.
AI-assisted: OpenCode / opencode/big-pickle. No game data included.
@Adika713 on GitHub · 2026-11-27 13:52 UTC · original
## Aperture+TEXTURE_NO_WAIT A/B (commit
37c3928, 2026-11-27, stopped ~4.6 min, no auto-input)Same low-pressure base: Series S 960x540, budget16/tex16,
LAZY=1 FILE=1 RELAY=0 RELAY_COPY=0 CARD_STEPS=0 JOIN_COPIES=0 INDIRECT_WINDOW=0 INDIRECT_BATCH=0 MAP_THREADS=0 WIDE_BACK=0 CARD_REHASH_RUNS=0 DRED=light PIPELINE_BOOK=1, shared pipeline lib, plusVICTORY_TEXTURE_NO_WAIT=1. Win11/RX 6950 XT/R5 3600/32GB/2688MB pagefile unchanged.Takeaway:
TEXTURE_NO_WAITremoves remap hold-still but degradation remains dominated by copy-back, texture CPU work, and drops with 0 being made. Not a world-entry/FPS/stability proof. Investigating copy-back/pipeline-drop causes next; no new game run while user is on another game.AI-assisted: OpenCode / opencode/big-pickle.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.