Skip to content

HLE: optionally back physical page pools with temporary sparse files - #2519

Open
yyc160 wants to merge 3 commits into
Marvisak:mainfrom
yyc160:pr/sparse-physical-pools
Open

yyc160 wants to merge 3 commits into
Marvisak:mainfrom
yyc160:pr/sparse-physical-pools

Conversation

@yyc160

@yyc160 yyc160 commented Nov 25, 2026 •

Copy link
Copy Markdown

When Windows commit is tight, let the user back XMem physical page pools with sparse, delete-on-close files instead of mapping them against the system pagefile. Views of a physical page still alias the same section. The default Windows path (SEC_RESERVE) and Wine path (SEC_COMMIT) are unchanged. This trades commit for disk space and possible I/O; it is not a GPU residency or frame-rate change.

Configuration and review changes

Set [paths].physical_pages_dir in victory.toml to a directory on a local sparse-capable volume with room for the pages the title writes. Leave it unset to use the system pagefile. For existing launchers, VICTORY_FILE_BACKED_PAGES=1 uses the configured path or <cache_dir>/physical-pages; =0 disables it even when configured. victory config shows the resolved choice. The directory is checked against the asset policy before use.

  • No new runtime crate: the backing file is created exclusively with create_new and FILE_FLAG_DELETE_ON_CLOSE. An existing file is never opened or truncated. tempfile is dev-only.
  • The README explanation is now two sentences. The example TOML documents the setting and override.

Title startup at the submitted head (646c17c)

Four launches of the same Windows diagnostics binary built directly from this PR head, not a previous integration build. Series S title, 32 GiB host with an RTX 5070 Ti, fresh cache and private save copy for each launch. The env switch was unset throughout; only the presence of the TOML setting selected the backing. Each run was stopped after present 64.

Launch order Backing System commit headroom consumed, start to minimum Peak process private bytes
1 TOML sparse 5.48 GiB 4.58 GiB
2 Default 9.17 GiB 4.57 GiB
3 Default 9.20 GiB 4.73 GiB
4 TOML sparse 4.80 GiB 4.73 GiB

All four reported four successful allocations totaling 74,864 logical 64 KiB pages. The first file-backed allocation was 3,520 pages (220 MiB); both sparse launches left the backing directory empty after exit. The default launches did not create it. The source title executable and seed save were unchanged. Commit headroom is system-wide, not a per-process saving; these are short startup samples, not gameplay or steady-state benchmarks.

Validation

AI-assisted by GPT-6.2 Astra.

Preserve the title's shared section offsets and alias/remap behaviour. On constrained Windows hosts this trades pagefile commit for disk space; enable only with VICTORY_FILE_BACKED_PAGES=1. Exercise a placeholder and a storage view of the same page, including cleanup after the last view closes.
juanfariasdev pushed a commit to juanfariasdev/VIctory that referenced this pull request Nov 25, 2026
# Conflicts:
#	crates/victory-hle/Cargo.toml
#	crates/victory-hle/src/modules/xmem.rs

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Thanks for the rebase. Reviewed at b081ccf, which merges cleanly. CI: passing.

The mechanics in crates/victory-hle/src/modules/xmem.rs read correctly. Section::new makes a sparse temporary file with FSCTL_SET_SPARSE and maps it without SEC_RESERVE. commit_view skips VirtualAlloc commits only for those file-backed sections. The default path keeps SEC_RESERVE, or SEC_COMMIT under Wine.

The points from the earlier note are still open:

  • crates/victory-hle/Cargo.toml moves tempfile from dev-dependencies into the runtime dependencies. No other crate ships it at runtime, so this needs the maintainer's decision.
  • The switch is still the VICTORY_FILE_BACKED_PAGES env var read in apps/victory/src/run.rs. A victory.toml setting would fit the other paths better.
  • The README paragraph could be cut to one or two sentences.
  • The only measurement is from an earlier integration build. A run of the title with the switch on, at this head, would help.

Verdict: needs work (needs the maintainer's decision). CI: passing.


Generated by Claude Code

Leave the allocator diagnostics tests together, including upstream Marvisak#1720. This moves the existing test unchanged so both additions merge without touching the allocator or rewriting the published PR branch.
An optional [paths].physical_pages_dir selects a sparse-capable volume. Check the path outside source trees before execution and keep it absolute if the title changes directories. Keep the existing env switch as an override, and leave pagefile sections unchanged by default.

Open each backing file exclusively with create_new and FILE_FLAG_DELETE_ON_CLOSE. The kernel handles cleanup on last close, including on setup failures and process exit. tempfile remains test-only.

AI-assisted by GPT-6.2 Astra.
@pickles976

pickles976 commented Nov 26, 2026 •

Copy link
Copy Markdown

Offscreen Wine/NVIDIA verification of 646c17cc666f7f92464768cb8de45ac814558820 (production unchanged; local fail-closed/test-only probes). This verifies part of the file-backed mechanism, not a title-RAM/OOM fix.

Tested — Linux 6.17, Wine 11.0, Intel i7-13620H / 16 GiB RAM, RTX 4060 Laptop 8 GiB, NVIDIA 590.48.01, Rust 1.98.1, Windows MSVC target. NVIDIA masking disabled (DXVK_CONFIG='dxgi.hideNvidiaGpu = False'). GPU runs used our diagnostic relaxed-vtable vkd3d-proton 2576c0b4adfae4a+, not stock certification. Fresh compilation from this exact checkout was recorded. External 9 GiB/512 MiB scope, 2 GiB global available-RAM floor, 6000 MiB GPU ceiling and 10 GiB disk floor retained.

  • victory-hle::modules::xmem::tests::file_backed_pages_alias_across_a_placeholder_and_storage_view: 1/1 pass, replacing its unsupported-sparse-volume early return with a hard failure. Real sparse-file storage/placeholder aliases agree in both directions; the surviving view remains usable and the file disappears after the last view.
  • victory-core, filter page_file: 2/2 pass (opt-in/override policy and refusing the repo directory).
  • A local 128 KiB production-XMem/copy-only GPU probe ran in separate processes with file backing enabled and with the same head's default pagefile path as control: both fail at the same later cross-alias write, described below. Before that assertion, both pass every-word initial CPU→GPU refresh, GPU→guest production copy-back (including the second CPU alias), and another CPU→GPU refresh through the original mapping. The selected adapter was explicitly checked as NVIDIA RTX 4060; GPU commands were real CopyBufferRegion submissions/fence completion, not shader dispatch.

Shared coherence failure, not a demonstrated #2519 regression

Reproducer sequence:

  1. Allocate two physical pages through XMemAllocatePhysicalPages; map both at A and map page 1 again at B through XMemMapPhysicalPages.
  2. Register A's 128 KiB range with the existing GPU shadow path. Require a real shared host buffer distinct from A (this head's path is copy-only).
  3. Fill A with word pattern i * 0x9e3779b9 ^ 1, refresh and GPU-copy the shadow to a separate readback buffer; verify every word.
  4. GPU-copy pattern salt 2 into the shadow, declare its GPU write, execute the normal production copy-back; verify every word at A and B.
  5. Write salt 3 through A; normal refresh/readback matches.
  6. Write the second page's salt-4 pattern through B, then refresh/readback the shadow addressed through A. At word 16384, GPU output remains 3731767299 (salt 3), expected 3731767300 (salt 4).

Exactly the same failure occurs with PAGE_FILES unset and with use_page_files pointing at an ext4-backed directory. Thus this does not isolate a sparse-file defect. Source inspection shows the old write-watch/guard bookkeeping here is virtual-address keyed; cross-alias invalidation is the likely missing contract, not a proven new regression. Suggested follow-through: add this dual-mapping GPU regression to the current XMem/shadow tracking stack and ensure writes through one physical-page alias invalidate copies addressed through another. A current-base integration should retain its newer tracking/lifetime fixes rather than assume this older head is sufficient.

Commands (wrapper supplies --locked --target x86_64-pc-windows-msvc):

cargo test -p victory-hle --features diagnostics --lib file_backed_pages_alias_across_a_placeholder_and_storage_view -- --nocapture --test-threads=1
cargo test -p victory-core --lib page_file -- --nocapture --test-threads=1
# Local ignored probe; separate process for each of VICTORY_LAB_PAGE_MODE=pagefile,file:
cargo test -p victory-hle --features diagnostics --lib lab_physical_copy_coherence -- --ignored --nocapture --test-threads=1

Local evidence directories under .compat-runtime/logs/:
verify-pr2519-owner-20261126T234642Z, verify-pr2519-gpu-pagefile-20261126T234724Z, verify-pr2519-gpu-file-20261126T234726Z (console, exact provenance, command/environment and guard samples retained). Local probe changes are retained in VIctory-pr2519 for reproduction. The failed GPU assertion occurs before the probe's later token-free/cleanup checks, so those checks are not claimed to pass; the separate owner alias/lifetime fixture did pass.

Not tested: native GPU imports of file-backed memory, a multi-GB allocation, actual RAM reclamation/peak RSS, disk-pressure behavior, a current-main integration, the full suite, title loading/gameplay or performance. No title launched.

AI-assisted verification/report: omp, OpenAI GPT-6 Astra. Results above are from executed local commands, not inferred test outcomes.


27 November: mixed-stack follow-through reaches the prologue card, not gameplay

This is not an exact-head retest or a retraction of the standalone alias failure above. I ported this PR's production mechanism at 646c17cc666f7f92464768cb8de45ac814558820 onto local VIctory-pr2945-fixed, base 3ed7d725f6895fe1a235eb6fa8ff2485261ca151, retaining its existing alias notifications/tracked-copy lifetime changes, #2112 GPU-write notification subset and #189 3e39e34037915da6d0f10b58b2872799bd9f3ca8. The integration also contains #2121 0bc5edbd2e1c5836bab00dc0af9f186bdd56c608 plus 0xkn0wh3r3#13 ba6e876944e14260fd5522f96b85b05aa0c1baad descriptor paging/stride fixes. Local test/census probes are present. Dirty mixed integration, not a clean upstream result.

Same Wine 11 / RTX4060 Laptop / 16 GiB host and diagnostic relaxed-vkd3d 2576c0b4adfae4a+ described above; not stock certification. NVIDIA masking disabled. No resource cutoff was raised.

Offscreen gates: 64 combined tests passed (including sparse-section lifetime, paging recovery, stride feedback, cache policy and 34 Wave64 cases), plus two config tests and one 64 MiB copy-only coherence fixture in each of scoped-file and default-tmpfs modes. Real GPU fixtures require the physical adapter. Wine's WARP-requested legs fall back to NVIDIA, not independent software coverage. Scoped backing retained correct CPU→GPU, GPU→guest, later CPU-write and second-mapping-alias data through production copy paths, checking every word after reclamation. At four active checkpoints, the selected disk file went from 64 MiB resident to zero; tmpfs retained 64 MiB. Normal final unmap/token release deleted the scoped file. These fixtures explicitly fsync/request cgroup reclaim; the title runs below did neither.

Runtime configuration: fresh diagnostics release (55.51 s compilation, intended worktree paths recorded), Series S, VICTORY_FILE_BACKED_PAGES=1, VICTORY_IN_PLACE=0, private tmpfs Wine /tmp, requested VICTORY_MODE=1920x1080, window limit1280x720, DXVK_CONFIG='dxgi.hideNvidiaGpu = False'. Native disk-backed GPU imports remain prohibited by the earlier integrity failure. The actual swapchain was still3840x2160: no1080p gameplay proof. Scope9 GiB/512 MiB; global available-RAM floor2048 MiB, GPU ceiling6000 MiB, free-disk floor10 GiB.

Trial Input / observed screen Minimum available RAM Peak GPU Peak scope Stop
30 s startup No input; account picker 7139.2 MiB 3323 MiB 3519.1 MiB Wall limit
90 s load A at20 s; loading artwork at85 s 6289.8 MiB 3363 MiB 7121.4 MiB Wall limit
180 s load A at20 s; “VICE CITY, TWO YEARS AGO” at120 s, black at175 s 3669.3 MiB 4557 MiB 8499.0 MiB Wall limit

All exit137 were deliberate guard time stops, not crashes or RAM stops. Initial available RAM and caches differed; these are sequential integration smoke tests, not matched A/B savings or loading-time benchmarks. No recognizable 3D world, controllable gameplay or FPS claim.

Snapshots identify four regular files under <cache>/physical-pages as the live XMem backing, while other Wine temporary storage stays on tmpfs. At175 s, those files had4121.02 MiB allocated blocks; the scope had8448.6 MiB total /5448.0 MiB anonymous /2846.7 MiB file, including only3.5 MiB shmem. Allocated blocks, residency and logical spans are different measures; do not sum file+shmem. This run passed the old loading RAM gate far enough to expose later rendering failures, but does not establish a universal OOM fix or attribute the entire improvement to this PR alone.

New cleanup finding: after killing the complete Wine scope, named backing files survived despite delete-on-close. Normal fixture cleanup therefore does not cover this Wine termination mode. Startup left779.67 MiB allocated; the90 s run left4039.27 MiB. I removed only exact device/inode-matched files from ended trials, after confirming inactive scopes and no open handles. The180 s run's files were handled the same way. Suggested owner follow-through: document/test Wine whole-scope/server termination and safe stale-file recovery; never unlink an active or unidentified backing object. Repeated killed runs otherwise consume disk and collide with reused names.

The later black frame has separate actionable findings:43 compute translation refusals (14 divergent64-lane ballots,23 split-wave LDS-without-uniform-fence,3 divergent reductions,3 divergent cross-lane reads), plus unsupported host texture formats67/115/86. Descriptor paging was active with zero title slot past the host heap warnings. These are next verification targets, not a demonstrated file-backing regression or proof of the black frame's sole cause. No unchanged black-screen retry planned.

Local evidence (no title assets or imagery published):

  • xmem-reclaim-scoped-copy-20261127T003149Z/, xmem-reclaim-tmpfs-copy-20261127T003358Z/
  • verify-scoped-integration-config-20261127T002321Z/, verify-scoped-paged-gates-20261127T003521Z/, verify-scoped-paged-release-20261127T003809Z/
  • 20261127T003957Z-{console.log,resources.csv}, 20261127T004204Z-{console.log,resources.csv}, 20261127T004545Z-{console.log,resources.csv}
  • scoped-paged-trial-<stamp>/: exact command/settings, captures, ownership snapshots and guard identity
  • scoped-backing-cleanup-20261127T004541Z.tsv, scoped-backing-cleanup-20261127T005248Z.tsv: identified orphan files, with separate empty open-handle checks.

Subsequent rendering gate, still no gameplay (27 November)

Same dirty scoped-backing/paging/copy-only integration, now with #2101 4d8c89a8 castable-format filter and #1701 fb27a56d reported-mode override. Five targeted checks pass; fresh release42.46s. Same machine/diagnostic-relaxed-vkd3d/guards above. 180s run 20261127T022056Z, A20s: prologue card120s, black150/175s, wall stop137. Minimum availableRAM4998.5MiB; GPUpeak4488MiB; scopepeak6248.9MiB; diskmin12.071GiB. No matched memory-saving claim: shader/cache/progress differ. Texture creation refusals now zero; translation/native pipeline failures remain. The native graphics log returns Vulkan -13 alongside NVVM compiler failures before the wrapper reports E_OUTOFMEMORY; this is not an OS OOM diagnosis.

Resolution correction: the earlier prologue stack ignored VICTORY_MODE and hardcoded its DXGI mode to4K. #1701 now passes an actual-output-interface1920×1080 probe, but title swapchain still4K. FSR context render1280×720/output1920×1080 was logged both before and after; neither setting nor window size proves gameplay resolution.

After the new scope became inactive, four backing files were removed only after exact snapshot device/inode checks and an empty lsof check:4115.14MiB allocated; user-available disk restored16.089GiB. Manifest scoped-backing-cleanup-20261127T022056Z.json; snapshots/captures scoped-paged-trial-20261127T022056Z/. No resource limits raised, no native file-backed GPU imports, no unchanged title retry planned. Detailed rendering follow-through: #2101 (comment) .

@pickles976

Copy link
Copy Markdown

Wine/RTX 4060 Laptop follow-through: the user observed correctly-looking rendered imagery, with severe lag, on a VIctory-NVIDIA integration using this PR's scoped-file policy. The credited code adaptation and full verification report are now public: trustno1-coder/VIctory-NVIDIA#1226 (head 72657763d96cd04fae7b0cc3e05e65fae5e43c3b, based on fork e7d8150defa7713b6f839561c45da9a26aa88620). This is not an exact #2519-head test, a matched savings comparison, or proof of controllable gameplay/30 FPS.

Wine 11, Linux 6.17, NVIDIA 590.48.1, physical RTX 4060 Laptop 8 GiB / 16 GiB system RAM, stock assertion-enabled vkd3d-proton 2576c0b4adfae4a. File-backed XMem is opt-in and excluded from native GPU import; CPU/GPU copies remain enabled. Retained fork rendering approximations/exclusions and compiler prerequisites are disclosed in the linked PR. Three stock-GPU scatter/import-generation/file-copy checks pass; the 128 KiB alias fixture verifies every word across three refresh/writeback/later-CPU-write rounds. No forced runtime fsync/reclaim.

The 2026-11-28 15:48:40 UTC run reached its 9,216 MiB scope cap (memory.events max=114, oom=0, oom_kill=0). Around 200 s, scope I/O pressure was full avg10=39.27; title and DirectStorage threads repeatedly blocked in folio_wait_bit_common and balance_dirty_pages. GPU peak was 5,903 MiB, minimum available RAM 2,349.6 MiB. These are real paging/writeback symptoms, not attribution to one backing inode or proof of the sole frame-time cause. The supervisor ended the run after its journal query timed out; kernel interval had no GPU fault/reset/OOM signature. A denied proc-syscall diagnostic produced audit messages and has been removed. Scheduled screenshots missed the scene the user saw.

Suggested next owner experiment, relevant to #3012: bound in-flight streaming/decompression demand (bytes as well as workers) and compare the same reached scene with memory.current, dirty/writeback, refault/reclaim counters, I/O PSI and frame times. Keep the external cap and RAM/GPU floors. File backing provides reclaimability, but this result does not make reclaim/refault traffic free or establish adequate throughput under pressure. Do not free GPU-pending data or raise limits to conceal the problem.

Raw mapping paths, game imagery/assets and saves remain local. The PR publishes the measured results and reproducible hardware fixtures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants