Wine/Proton: know placeholders from the runtime's own reservations #1601

Manually merged
github merged 1 commit from github-bot/gh-1601 into main 2026-11-29 08:20:40 +00:00 AGit
Owner

@⁠domx4q on GitHub · 2026-11-28 22:15 UTC · original
domx4q:fix/wine-placeholder-fallback → main · +65 −1 · 3 files · 1 commits · merged 2026-11-29 08:16 UTC

Follows #207, which was closed for conflicts; this is it rebased on current main.

What it changes

Under Wine and Proton, watch::placeholder() never recognises a hole as a placeholder:

  • Wine answers NtQueryVirtualMemory(MemoryRegionInformationEx) with STATUS_INVALID_INFO_CLASS (0xC0000003), so placeholder() always returns false.
  • VICTORY_KNOWN_HOLES therefore has no effect there. Every asking asks again about every hole.
  • That came to about 16,000 VirtualQuery calls a frame, under the guards' lock. Under Wine each one goes through ntdll's emulation.

The change:

  • After the first STATUS_INVALID_INFO_CLASS, placeholder() answers from the runtime's own placeholder reservations instead.
  • xmem.rs reports each MEM_RESERVE_PLACEHOLDER reservation through title_placeholder_reserved, and title_memory_freed forgets them.
  • Windows never takes the new path, because its first answer succeeds.

How it was tested

  • GPU and profile: RTX 4090 with i9-14900KF, Linux, Proton Experimental 11 with vkd3d-proton master. Series X, DLSS quality, 1440p, frame generation off, ray tracing off.
  • Before: prologue 18.6 fps, "preparing" about 45 ms a frame.
  • After: 20.5 fps, "preparing" about 31 ms a frame.
  • For shader changes, the wave sizes tested: not a shader change.
  • cargo test passed for the crates it touches: not run. victory-gpu and victory-hle only build for Windows here.
  • cargo xwin clippy -p victory --target x86_64-pc-windows-msvc: nothing in the changed files. The 13 warnings it reports are already on main.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #207. No open pull request changes placeholder().
**@⁠domx4q** on GitHub · 2026-11-28 22:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1601) `domx4q:fix/wine-placeholder-fallback` → `main` · +65 −1 · 3 files · 1 commits · merged 2026-11-29 08:16 UTC Follows #207, which was closed for conflicts; this is it rebased on current main. ## What it changes Under Wine and Proton, `watch::placeholder()` never recognises a hole as a placeholder: - Wine answers `NtQueryVirtualMemory(MemoryRegionInformationEx)` with `STATUS_INVALID_INFO_CLASS` (`0xC0000003`), so `placeholder()` always returns false. - `VICTORY_KNOWN_HOLES` therefore has no effect there. Every asking asks again about every hole. - That came to about 16,000 `VirtualQuery` calls a frame, under the guards' lock. Under Wine each one goes through ntdll's emulation. The change: - After the first `STATUS_INVALID_INFO_CLASS`, `placeholder()` answers from the runtime's own placeholder reservations instead. - `xmem.rs` reports each `MEM_RESERVE_PLACEHOLDER` reservation through `title_placeholder_reserved`, and `title_memory_freed` forgets them. - Windows never takes the new path, because its first answer succeeds. ## How it was tested - GPU and profile: RTX 4090 with i9-14900KF, Linux, Proton Experimental 11 with vkd3d-proton master. Series X, DLSS quality, 1440p, frame generation off, ray tracing off. - Before: prologue 18.6 fps, "preparing" about 45 ms a frame. - After: 20.5 fps, "preparing" about 31 ms a frame. - For shader changes, the wave sizes tested: not a shader change. - `cargo test` passed for the crates it touches: not run. victory-gpu and victory-hle only build for Windows here. - `cargo xwin clippy -p victory --target x86_64-pc-windows-msvc`: nothing in the changed files. The 13 warnings it reports are already on main. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #207. No open pull request changes `placeholder()`.
Wine answers NtQueryVirtualMemory(MemoryRegionInformationEx) with
STATUS_INVALID_INFO_CLASS, so watch::placeholder() never knew a hole was a
placeholder: ~16,000 VirtualQuery calls a frame under the guards' lock.
After the first such answer the runtime's MEM_RESERVE_PLACEHOLDER
reservations (xmem.rs) are taken instead. Prologue on Proton, 14900KF +
RTX 4090: 18.6 -> 20.5 fps. Windows never takes the new path.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 22:19:04 +00:00
Author
Owner

@⁠pickles976 on GitHub · 2026-11-29 06:54 UTC · original

Confirmed the Wine-side prerequisite on Wine11/Linux6.17: a standalone CPU probe creates its own placeholder and ordinary reservation, queries both, then frees them. Class7 returns STATUS_INVALID_INFO_CLASS for both; class0 and class3 metadata are indistinguishable. This agrees with the mechanism in this PR and rules out a generic MEM_RESERVE heuristic.

I adapted your ee85549b43c63317851bf6799a9285a3a6f5a4de mechanism onto our older Wine-support fork. The corrected adaptation is public at cb766636, with the original idea credited. It is not an exact-head test of your patch.

The additional lifetime contract matters: a late split/unmap/coalesce notification must not register a placeholder after another thread has released that identity and reused the address as ordinary memory. Origin-only ranges also need to exclude mapped/replaced portions and preserve exact identities for zero-size releases. The adaptation uses range transactions: overlapping transitions wait through publication, disjoint operations can proceed, queries over an in-flight transition conservatively report not-a-hole, and no registry mutex spans native calls or GUARDS acquisition. Failed calls do not publish a successful transition.

Two real-Win32 regressions are included:

  • watch::tests::runtime_placeholder_events_follow_win32_lifetime: failed operations, split/map/unmap/free, exact zero-size identity and ordinary same-address reuse.
  • watch::tests::structural_placeholder_publication_precedes_release_and_reuse: pause after the native split; a competing release and then ordinary reservation cannot overtake its publication. The final ordinary reservation is not a known placeholder.

The four placeholder/mapping fixtures that failed in our preserved baseline now pass. The selected group initially gave53passes/1fixture error: an already exact placeholder need not split again. Correcting that fixture's notification while retaining all replacement/data assertions passed its isolated rerun. Five existing HLE file/alias/window lifecycle cases and a real RTX4060 Laptop stock-vkd3d disk-backed alias/GPU-copy test also pass. Test allocation helpers report the same successful operations as HLE; no assertions were replaced with silent skips.

This supplies Wine correctness/lifetime evidence, not a measured title FPS gain or proof of fixing the separate native allocation/query stalls. The changed title build has not yet run. I would appreciate review of the transaction boundaries, especially the conservative extent used for zero-size releases. No assets, captures or raw mapping addresses are published.

**@⁠pickles976** on GitHub · 2026-11-29 06:54 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1601#issuecomment-7252144278) Confirmed the Wine-side prerequisite on Wine11/Linux6.17: a standalone CPU probe creates its own placeholder and ordinary reservation, queries both, then frees them. Class7 returns `STATUS_INVALID_INFO_CLASS` for both; class0 and class3 metadata are indistinguishable. This agrees with the mechanism in this PR and rules out a generic MEM_RESERVE heuristic. I adapted your `ee85549b43c63317851bf6799a9285a3a6f5a4de` mechanism onto our older Wine-support fork. The corrected adaptation is public at [cb766636](https://github.com/pickles976/VIctory-NVIDIA/commit/cb7666369ef7dca4a4b7f48ab251b56283dc0301), with the original idea credited. It is **not an exact-head test of your patch**. The additional lifetime contract matters: a late split/unmap/coalesce notification must not register a placeholder after another thread has released that identity and reused the address as ordinary memory. Origin-only ranges also need to exclude mapped/replaced portions and preserve exact identities for zero-size releases. The adaptation uses range transactions: overlapping transitions wait through publication, disjoint operations can proceed, queries over an in-flight transition conservatively report not-a-hole, and no registry mutex spans native calls or GUARDS acquisition. Failed calls do not publish a successful transition. Two real-Win32 regressions are included: - `watch::tests::runtime_placeholder_events_follow_win32_lifetime`: failed operations, split/map/unmap/free, exact zero-size identity and ordinary same-address reuse. - `watch::tests::structural_placeholder_publication_precedes_release_and_reuse`: pause after the native split; a competing release and then ordinary reservation cannot overtake its publication. The final ordinary reservation is not a known placeholder. The four placeholder/mapping fixtures that failed in our preserved baseline now pass. The selected group initially gave53passes/1fixture error: an already exact placeholder need not split again. Correcting that fixture's notification while retaining all replacement/data assertions passed its isolated rerun. Five existing HLE file/alias/window lifecycle cases and a real RTX4060 Laptop stock-vkd3d disk-backed alias/GPU-copy test also pass. Test allocation helpers report the same successful operations as HLE; no assertions were replaced with silent skips. This supplies Wine correctness/lifetime evidence, not a measured title FPS gain or proof of fixing the separate native allocation/query stalls. The changed title build has not yet run. I would appreciate review of the transaction boundaries, especially the conservative extent used for zero-size releases. No assets, captures or raw mapping addresses are published.
github manually merged commit 06585a0e86 into main 2026-11-29 08:20:40 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/trustno1-coder--VIctory-NVIDIA!1601
No description provided.