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

Manually merged
github merged 1 commit from gh-pr/1005/head into gh-pr/1005/base 2026-11-26 04:40:02 +00:00
Owner

@⁠raylitebull on GitHub · 2026-11-24 10:19 UTC · original
raylitebull:pr/vq-coherent-window → main · +115 −15 · 3 files · 1 commits · merged 2026-11-24 23:41 UTC

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.
**@⁠raylitebull** on GitHub · 2026-11-24 10:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/1005) `raylitebull:pr/vq-coherent-window` → `main` · +115 −15 · 3 files · 1 commits · merged 2026-11-24 23:41 UTC 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.
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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:39:59 +00:00
github manually merged commit c1a9b52453 into gh-pr/1005/base 2026-11-26 04:40:02 +00:00
Author
Owner

@⁠poucosaudavel on GitHub · 2026-11-24 11:06 UTC · original

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.
**@⁠poucosaudavel** on GitHub · 2026-11-24 11:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/1005#issuecomment-7129657112) 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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 11:35 UTC · original

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.

**@⁠DavidM1911** on GitHub · 2026-11-24 11:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/1005#issuecomment-7130301940) 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.
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 14:00 UTC · original

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.

**@⁠thehollowedone** on GitHub · 2026-11-24 14:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/1005#issuecomment-7133679253) Independent timing for [`c1a9b52`](https://github.com/ivall/xcl/commit/c1a9b5245380b46276e71d7cba3412ef7464c7f0) applied to [`930e8b4`](https://github.com/ivall/xcl/commit/930e8b49c1c2ec683d22c724a398b39111cd0e56). 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.
Author
Owner

@⁠thaqiart139-alt on GitHub · 2026-11-24 22:49 UTC · original

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
  • This PR adds no failure. The failures are the same on main, from #1679's new fuzz tests, and both are already reported on #1679:
    • RTX 5070: fuzz_validate_and_gpu_0 to _3 (CreateComputePipelineState: 0x8007000E)
    • iGPU: fuzz_validate_and_gpu_1 (seed 540: res[833] = 0x7, CPU 0x6)
  • This PR's new tests pass on both GPUs: virtual_query_fastpath_covers_committed_coherent_window.
  • This is an NVIDIA run, which the description lists as not tested.
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 #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.
**@⁠thaqiart139-alt** on GitHub · 2026-11-24 22:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/1005#issuecomment-7146678203) 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 | - This PR adds no failure. The failures are the same on `main`, from #1679's new fuzz tests, and both are already reported on #1679: - RTX 5070: `fuzz_validate_and_gpu_0` to `_3` (`CreateComputePipelineState`: `0x8007000E`) - iGPU: `fuzz_validate_and_gpu_1` (`seed 540: res[833] = 0x7, CPU 0x6`) - This PR's new tests pass on both GPUs: `virtual_query_fastpath_covers_committed_coherent_window`. - This is an NVIDIA run, which the description lists as not tested. <details><summary>SKIPPED tests (the same on <code>main</code> and with this PR)</summary> - **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 #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) </details> **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.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 03:32 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 03:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/1005#issuecomment-7181803752) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
This discussion has been locked. Commenting is limited to contributors.
No description provided.