Skip to content

Memory: skip VirtualQuery on committed coherent UMA windows in cpu_writes and kernelx - #1005

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
raylitebull:pr/vq-coherent-window
Nov 24, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
raylitebull:pr/vq-coherent-window

Conversation

@raylitebull

Copy link
Copy Markdown
Member

Avoid kernel VirtualQuery calls on committed coherent UMA windows in cpu_writes, kernelx, and list_x. On Windows, calling VirtualQuery on a 4 GiB OpenExistingHeapFromAddress coherent window walks the whole region (~75-80 ms) while holding MmLockAddressSpace, stalling GetWriteWatch on other threads. eh::is_writable already checks uma.in_committed_window() first; this extends the same fast path to the remaining call sites.

What is in it

  • crates/xcl/src/hle/d3d12x/cpu_writes.rs: fast-path write_now, write_u64_now, and writable when [va, va + bytes) lies inside a committed coherent UMA window.
  • crates/xcl/src/hle/kernelx.rs: export VirtualQuery and VirtualQueryEx, fast-path them plus XMemVirtualQuery, committed_range, and committed_page_in on committed coherent UMA windows, and add a unit test (virtual_query_fastpath_covers_committed_coherent_window).
  • crates/xcl/src/hle/d3d12x/list_x.rs: route the XCL_TRACE_FRAME vertex-buffer VirtualQuery through kernelx::VirtualQuery.

Tested

  • AMD Radeon RX 9070 XT (driver 32.0.32015.2008), Intel Core i5-13600KF, Windows 11 Pro 22631, rustc 1.99.1 (58cf8f9c3 2026-10-13), release + test profiles
  • cargo test --workspace -- --test-threads=4: 728 passed, 0 failed, 41 ignored (0 SKIPPED GPU tests)

Regression run

main:

xcl-smoke v1
commit: 6efdabcdaac93ce5cc123a85e85deba5d49cb294
gpu: AMD Radeon RX 9070 XT
title: Game Assets
seconds: 60
exit: 0x0
frames shown: 1512 (PresentX 1512)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14852 MB

PR:

xcl-smoke v1
commit: c1a9b5245380b46276e71d7cba3412ef7464c7f0
gpu: AMD Radeon RX 9070 XT
title: Game Assets
seconds: 60
exit: 0x0
frames shown: 1575 (PresentX 1575)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14901 MB

Not tested

  • NVIDIA GPUs, Intel Arc GPUs, Linux / Wine, other retail titles beyond the 60 s smoke run and unit/GPU test suite.

AI use

  • Antigravity (Gemini 4 Neon): audited local branch changes against origin/main, ported and refined the coherent-window fast path and unit test, ran the full test suite and smoke runs, and drafted this description.

…ites and kernelx

A kernel VirtualQuery on a 4 GiB OpenExistingHeapFromAddress coherent UMA window walks the entire region (~75-80 ms) while holding MmLockAddressSpace, stalling GetWriteWatch on other threads.

eh::is_writable already checks uma.in_committed_window() first; extend the same fast path to cpu_writes (write_now, write_u64_now, writable), kernelx (VirtualQuery, VirtualQueryEx, XMemVirtualQuery, committed_range, committed_page_in), and list_x frame-trace diagnostics.
@poucosaudavel

Copy link
Copy Markdown

Test report for the exact head c1a9b5245380b46276e71d7cba3412ef7464c7f0, since Not tested lists NVIDIA GPUs.

Tested

  • NVIDIA GeForce RTX 5060 Ti (8 GB, 32-lane waves), driver 610.88; Intel Core Ultra 7 265KF; Windows 11 (build 26200)
  • Rust 1.100.0 (stable-x86_64-pc-windows-msvc), MSVC 14.44, Windows SDK 10.0.26100, debug build
  • Clean worktrees, no local changes: the PR head, and its merge base on main (6efdabcdaac93ce5cc123a85e85deba5d49cb294) as the baseline
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4:
    • PR head: 728 passed, 0 failed, 41 ignored
    • merge base: 727 passed, 0 failed, 41 ignored
  • The one extra pass is the new hle::kernelx::tests::virtual_query_fastpath_covers_committed_coherent_window; no test present on the base is missing or failing on the PR.
  • The GPU tests ran on the NVIDIA adapter (the log shows backend real on the RTX 5060 Ti).
  • SKIPPED on both, same reason: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask and gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)

Not tested

  • No scripts/smoke.ps1 regression run on a retail title: this covers the test suite only, so it says nothing about the VirtualQuery savings on a running title.
  • Release build of the PR head; AMD, Intel; Linux / Wine.

AI use

  • Claude Code (Claude Opus 5.5) ran the builds and tests and wrote this report from their output.

@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti (8 GiB); Rust stable MSVC, debug.

  • cargo test -p xcl --lib kernelx: 33 passed, 0 failed, 1 ignored — covers the new committed-coherent-window path in kernelx.
  • cargo test -p xcl --lib cpu_writes: 3 passed, 0 failed — writes_land_after_the_queue, readback_u64_lands_after_the_queue, gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes all exercise the real UMA backend on this adapter.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

@thehollowedone

Copy link
Copy Markdown

Independent timing for c1a9b52 applied to 930e8b4. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, release.

On the same 4095 MiB coherent window imported with OpenExistingHeapFromAddress, native VirtualQuery took 17.5–22.3 ms at the median across three passes (p95 23.8–28.0 ms). XCL’s fast path took about 0.1 µs at the median (p95 0.2 µs). All eight compared MEMORY_BASIC_INFORMATION fields matched at offsets near the start, middle, and end of the window.

A second thread probed GetWriteWatch on a separate dirty 4 KiB page. Its p95 was 7.4–8.6 µs during repeated native queries and 5.1–7.5 µs during fast-path queries. Neither condition produced a millisecond-scale stall. The stock query and GPU mirror readback tests also passed. Synthetic workloads only. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote and ran the scratch benchmark and drafted this report.

@thaqiart139-alt

Copy link
Copy Markdown

Test report for this PR's head c1a9b52, merged into main 689f2db (no conflicts), on AMD RDNA2 with native 64-lane waves and on a 32-lane NVIDIA card.

Tested

  • GPUs: AMD Radeon(TM) Graphics, the RDNA2 iGPU of a Ryzen 7 7800X3D (native wave64, driver 32.0.21045.29003), and NVIDIA GeForce RTX 5070 (driver 32.0.16.2101), chosen with XCL_ADAPTER.
  • System: 32 GB, Windows 11 Home build 26300, Rust 1.100.0, debug, DXC 1.9.2602.17.
  • cargo test --workspace --no-fail-fast -- --test-threads=4:
main 689f2db with this PR
RTX 5070 971 passed, 4 failed, 45 ignored 972 passed, 4 failed, 45 ignored
Radeon iGPU 974 passed, 1 failed, 45 ignored 975 passed, 1 failed, 45 ignored
SKIPPED tests (the same on main and with this PR)
  • RTX 5070:
    • no wave64:
      • gpu::recomp::lower::tests: a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu
      • gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu, and the wave64 cases of its f16 / f32 / f64 / integer_programs_on_the_gpu
      • gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware
    • the wave32 per-lane cases of lower_dxil's f16 arithmetic, f16 packed and f32 conversions: refused ("its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's")
    • heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
    • pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode is off)
  • Radeon iGPU:
    • no mesh shaders: gpu::dxil::geometry_tests::gpu_geometry_direct_records, emitted_ms_primitive_attribute_reaches_the_pixel_shader, emitted_ms_ps_draw_a_triangle, gpu_geometry_mode_es_gs_strip, gpu_geometry_mode_es_gs_strip_with_branches, gpu_mesh_mode_two_passes
    • the wave32 and wave64 per-lane cases of lower_dxil's f16 arithmetic, f16 packed and f32 conversions: refused, as above
    • heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
    • pso_measurement_compiles_an_exact_synthetic_record (Developer Mode is off)

Not tested

  • a title run, Intel Arc, Linux / Wine; other GPUs.

AI use

  • Claude Code (Claude Opus 5.5) ran the builds and tests and wrote this report.

@raylitebull
raylitebull merged commit a713101 into xcl-dev:main Nov 24, 2026
2 checks passed
anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 25, 2026
, xcl-dev#1876, xcl-dev#1866)

Brings main to full parity with upstream/main (62265d3):
- xcl-dev#1005: skip VirtualQuery on committed coherent UMA windows in cpu_writes and kernelx
- xcl-dev#1053: opt-in fast-boot env vars (Bink intro skip, frame interval override, device type, TTS mute)
- xcl-dev#1876: float v_cmpx through xcl-dev#1426 lowering keeps lanes outside EXEC out
- xcl-dev#1866: track SCC of mixed mask and number operations

Conflict in crates/xcl/src/hle/xgameruntime/api.rs resolved by keeping both the
in-process Wine XAsync path and upstream's XCL_MUTE_TTS XAccessibility path.

Assisted-by: Antigravity (Gemini 4)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
Pulls in xcl-dev#1836 (graphics and two-pass PSO disk cache + lazy MS/GS + shader build coalescing), xcl-dev#1930 (DXIL CSE across discard), xcl-dev#1900, xcl-dev#1005, xcl-dev#1053, xcl-dev#1864, xcl-dev#1866, xcl-dev#1869, xcl-dev#1876, and xcl-dev#1898 while keeping our RDNA4 MSAA clamp (xcl-dev#1908), wave64 graphics Direct DXIL guard (xcl-dev#1913), atomic writable-range tracking, static-sampler cache keys, and 4M-group indirect dispatch clamp.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants