xcl run: xcl nvprofile puts xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2590

Open
github-bot wants to merge 1 commit from github-bot/gh-2590 into main AGit
Owner

@⁠afpruivo on GitHub · 2026-11-26 00:47 UTC · original
afpruivo:nvprofile → main · +362 −0 · 4 files · 1 commits · draft

NVIDIA's D3D12 driver reserves 512 MB of VA for the machine code of the pipelines in use and removes the device (0x887a0005) when a submission needs more (#2403). Setting 0x001ABC0F in a driver profile raises that reserve; NVIDIA's own profiles use 1 or 2 GiB for big titles. This adds xcl nvprofile, which writes that one setting for xcl.exe through NVAPI, so users don't have to find it in Profile Inspector. Part of #2403. The measurements are in my comment there.

It is opt-in and changes nothing at run time: nothing happens unless the user runs the command. It moves the wall and does not replace using less code (#2526, #1901, #2496).

What is in it

  • crates/xcl/src/gpu/nvprofile.rs (new): nvapi64.dll through nvapi_QueryInterface, NvAPI_DRS_*. install puts the exe into a profile of its own, XCL (xcl-dev), holding only this setting, so remove deletes exactly that. status reads what the driver will use. Tests: the NVAPI struct sizes, the command line.
  • crates/xcl/src/main.rs: the xcl nvprofile [status | install [--mb N] | remove] subcommand and its help text. --mb takes 512 to 4095 (4096 MB would not fit in the setting's u32), default 1024.
  • README.md: one line in the command list.

Writing needs an elevated prompt once: without it NvAPI_DRS_SetSetting returns -137 (NVAPI_INVALID_USER_PRIVILEGE) and nothing is saved, and the command says so. Later unelevated runs get the larger heap, because the driver matches the profile by exe name. Reading needs no elevation.

Tested

  • RTX 3090 24 GB, NVIDIA 621.40, i5-13600K, Windows 11 26300, Rust 1.99.1 (MSVC), debug for the suite, release for the runs.

  • At 004fa0f6 (rebased on main b49be18): cargo build --workspace + cargo test --workspace -- --test-threads=4: 1438 passed, 0 failed, 47 ignored; 28 SKIPPED (no wave64 and the like on this adapter).

  • Review fixes: --mb 4096 is refused (it wrapped to a 0-byte heap); only NVAPI's not-found codes (-160, -163, -166, checked against nvapi_lite_common.h) read as "no profile", any other status (e.g. NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS, -182) is an error in status, remove and install. Unit tests for both; the DRS calls themselves are not mocked.

  • 28 SKIPPED lines: the wave64 tests (no wave64 on this adapter), per-lane f16/f32 forms refused, and the const-mask case.

  • The new tests: gpu::nvprofile::tests::struct_sizes_match_nvapi, the_command_line_is_checked: pass.

  • xcl nvprofile unelevated: shows the default 512 MB for xcl.exe. xcl nvprofile install unelevated: refused with the elevation message, exit 1, nothing written.

  • The same module, from #2403's shader_code_limit.rs with its own exe put into the profile (elevated install, then an unelevated run): removal at 262 pipelines / 448 MB without the profile, 519 / 888 MB at 1 GiB, 1,028 / 1,760 MB at 2 GiB. Reading NVIDIA's own Fortnite profile gives 0x80000000, as Profile Inspector shows.

  • Retail 1.0.2.1 in the world, with and without the profile written by this (same binary 4bf94d0, one copy named xcl-noprofile.exe so the driver gives it no profile, back to back from the same caches; XCL_DIRECT_DXIL=1 XCL_DRED=1, 480 s, A pressed by script). Compute pipelines precompiled with --used-only using #2551's precompiler, so no compute pipeline was built cold at the world start:

    pair no profile (512 MB) xcl nvprofile install --mb 1024
    1 removed 28 s into the world (0x887a0005 at 102.5 s, DRED page fault at VA 0x0 with no allocations, then 0x80000003) not removed in 480 s
    2 (re-precompiled) removed 3 s into the world (87.9 s, the same signature), 0 cold builds in flight (148 compute pipelines from blobs) not removed in 480 s, exit 0x0

    With the profile the title showed the first in-world output on this machine: world audio and on-screen text. But frames were very slow (about 70 in the 400 s after the world start), with green flashes and 17 compute + 8 graphics pipelines still built cold. So this shows the device staying alive, not a playable world. The shader code in use was not counted in these runs.

  • On nvidia-dev af2cecc4 + #2551 (RTX 3090, same cache state), 1 GiB was not enough: the device was removed in 2 of 2 runs at --mb 1024 (341 s, 199.6 s) and in 0 of 2 at --mb 2048 (480 s each); details. @⁠Anon64 saw the same on that tree on an RTX 3060, so --mb 2048 may be the better choice on nvidia-dev.

Regression run

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3090
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1591 (PresentX 1591)
presents per 2 s (last 3): 46 60 60
device removals: 0
crashes: 0
peak commit: 18068 MB

this PR:

xcl-smoke v1
commit: 004fa0f61f9c9cf1d881386adbf00877d5d0571f
gpu: NVIDIA GeForce RTX 3090
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1610 (PresentX 1610)
presents per 2 s (last 3): 59 60 60
device removals: 0
crashes: 0
peak commit: 16946 MB

The main run was first after the build, and its lower frame count is most likely its cold caches. The code here is not called at run time.

Not tested

  • xcl nvprofile install and remove through xcl.exe itself, elevated. The same functions were tested elevated through the test above.
  • More than two retail pairs, and a count of the shader code in use in them.
  • A heap above 2 GiB: 4095 MB is only the largest value that fits, no run used it.
  • Whether code placed past 512 MB of the heap runs correctly. The limit test only dispatches each program once.
  • Other NVIDIA drivers. Machines without NVIDIA: there the command should fail with "no nvapi64.dll", which I could not check here.

AI use

  • Claude Code (Claude Opus 5.5) wrote the module, the subcommand and the tests, ran the suite, the limit tests and the smoke pair on my PC, and wrote this. I ran the elevated profile writes myself.

🤖 Generated with Claude Code

**@⁠afpruivo** on GitHub · 2026-11-26 00:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/2590) `afpruivo:nvprofile` → `main` · +362 −0 · 4 files · 1 commits · draft NVIDIA's D3D12 driver reserves 512 MB of VA for the machine code of the pipelines in use and removes the device (`0x887a0005`) when a submission needs more (#2403). Setting `0x001ABC0F` in a driver profile raises that reserve; NVIDIA's own profiles use 1 or 2 GiB for big titles. This adds `xcl nvprofile`, which writes that one setting for `xcl.exe` through NVAPI, so users don't have to find it in Profile Inspector. Part of #2403. The measurements are in [my comment there](https://git.gtahub.st/github/xcl-dev--xcl/issues/2403). It is opt-in and changes nothing at run time: nothing happens unless the user runs the command. It moves the wall and does not replace using less code (#2526, #1901, #2496). **What is in it** - `crates/xcl/src/gpu/nvprofile.rs` (new): `nvapi64.dll` through `nvapi_QueryInterface`, `NvAPI_DRS_*`. `install` puts the exe into a profile of its own, `XCL (xcl-dev)`, holding only this setting, so `remove` deletes exactly that. `status` reads what the driver will use. Tests: the NVAPI struct sizes, the command line. - `crates/xcl/src/main.rs`: the `xcl nvprofile [status | install [--mb N] | remove]` subcommand and its help text. `--mb` takes 512 to 4095 (4096 MB would not fit in the setting's u32), default 1024. - `README.md`: one line in the command list. Writing needs an elevated prompt once: without it `NvAPI_DRS_SetSetting` returns `-137` (`NVAPI_INVALID_USER_PRIVILEGE`) and nothing is saved, and the command says so. Later unelevated runs get the larger heap, because the driver matches the profile by exe name. Reading needs no elevation. **Tested** - RTX 3090 24 GB, NVIDIA 621.40, i5-13600K, Windows 11 26300, Rust 1.99.1 (MSVC), debug for the suite, release for the runs. - At `004fa0f6` (rebased on `main` `b49be18`): `cargo build --workspace` + `cargo test --workspace -- --test-threads=4`: 1438 passed, 0 failed, 47 ignored; 28 SKIPPED (no wave64 and the like on this adapter). - Review fixes: `--mb 4096` is refused (it wrapped to a 0-byte heap); only NVAPI's not-found codes (-160, -163, -166, checked against `nvapi_lite_common.h`) read as "no profile", any other status (e.g. `NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS`, -182) is an error in `status`, `remove` and `install`. Unit tests for both; the DRS calls themselves are not mocked. - 28 `SKIPPED` lines: the wave64 tests (no wave64 on this adapter), per-lane f16/f32 forms refused, and the const-mask case. - The new tests: `gpu::nvprofile::tests::struct_sizes_match_nvapi`, `the_command_line_is_checked`: pass. - `xcl nvprofile` unelevated: shows the default 512 MB for `xcl.exe`. `xcl nvprofile install` unelevated: refused with the elevation message, exit 1, nothing written. - The same module, from #2403's `shader_code_limit.rs` with its own exe put into the profile (elevated install, then an unelevated run): removal at 262 pipelines / 448 MB without the profile, 519 / 888 MB at 1 GiB, 1,028 / 1,760 MB at 2 GiB. Reading NVIDIA's own Fortnite profile gives `0x80000000`, as Profile Inspector shows. - **Retail 1.0.2.1 in the world, with and without the profile written by this** (same binary `4bf94d0`, one copy named `xcl-noprofile.exe` so the driver gives it no profile, back to back from the same caches; `XCL_DIRECT_DXIL=1 XCL_DRED=1`, 480 s, A pressed by script). Compute pipelines precompiled with `--used-only` using #2551's precompiler, so no compute pipeline was built cold at the world start: | pair | no profile (512 MB) | `xcl nvprofile install --mb 1024` | |---|---|---| | 1 | removed 28 s into the world (`0x887a0005` at 102.5 s, DRED page fault at VA 0x0 with no allocations, then `0x80000003`) | not removed in 480 s | | 2 (re-precompiled) | removed 3 s into the world (87.9 s, the same signature), 0 cold builds in flight (148 compute pipelines from blobs) | not removed in 480 s, exit 0x0 | With the profile the title showed the first in-world output on this machine: world audio and on-screen text. But frames were very slow (about 70 in the 400 s after the world start), with green flashes and 17 compute + 8 graphics pipelines still built cold. So this shows the device staying alive, not a playable world. The shader code in use was not counted in these runs. - On `nvidia-dev` `af2cecc4` + #2551 (RTX 3090, same cache state), 1 GiB was not enough: the device was removed in 2 of 2 runs at `--mb 1024` (341 s, 199.6 s) and in 0 of 2 at `--mb 2048` (480 s each); [details](https://git.gtahub.st/github/xcl-dev--xcl/issues/2403). @⁠Anon64 saw the same on that tree on an RTX 3060, so `--mb 2048` may be the better choice on `nvidia-dev`. **Regression run** main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 3090 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1591 (PresentX 1591) presents per 2 s (last 3): 46 60 60 device removals: 0 crashes: 0 peak commit: 18068 MB ``` this PR: ``` xcl-smoke v1 commit: 004fa0f61f9c9cf1d881386adbf00877d5d0571f gpu: NVIDIA GeForce RTX 3090 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1610 (PresentX 1610) presents per 2 s (last 3): 59 60 60 device removals: 0 crashes: 0 peak commit: 16946 MB ``` The `main` run was first after the build, and its lower frame count is most likely its cold caches. The code here is not called at run time. **Not tested** - `xcl nvprofile install` and `remove` through `xcl.exe` itself, elevated. The same functions were tested elevated through the test above. - More than two retail pairs, and a count of the shader code in use in them. - A heap above 2 GiB: 4095 MB is only the largest value that fits, no run used it. - Whether code placed past 512 MB of the heap runs correctly. The limit test only dispatches each program once. - Other NVIDIA drivers. Machines without NVIDIA: there the command should fail with "no nvapi64.dll", which I could not check here. **AI use** - Claude Code (Claude Opus 5.5) wrote the module, the subcommand and the tests, ran the suite, the limit tests and the smoke pair on my PC, and wrote this. I ran the elevated profile writes myself. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
NVIDIA's D3D12 driver reserves 512 MB of VA for the code of the pipelines in use and removes
the device past it. `xcl nvprofile install [--mb N]` writes setting 0x001ABC0F for xcl.exe into
a profile of XCL's own through NVAPI DRS (elevated, once); `status` reads it, `remove` deletes
the profile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:34:30 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 01:09 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 01:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/2590#issuecomment-7179495957) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 26 ignored. Thanks! — Devin
Author
Owner

@⁠GXLD-N on GitHub · 2026-11-26 02:36 UTC · original

Tested on an RTX 4070 Ti SUPER (Ada, 16 GB): xcl nvprofile install raises the shader-code limit from 446 MB to 885 MB, the same as the RTX 3090 in #2403.

Setup

  • RTX 4070 Ti SUPER 16 GB, driver 32.0.16.1088, Ryzen 7 7800X3D, 32 GB RAM, Windows 11 26300, Rust 1.100.0, DXC 1.8.2502.11.
  • This PR's head 4bf94d0, release build for the runs, debug for the suite.

Suite

  • cargo test --workspace -- --test-threads=4: 1431 passed, 0 failed, 48 ignored, 26 SKIPPED (24 "no wave64", 1 "no heap windows", 1 Developer Mode for the driver cache). The 48 ignored include #2403's shader_code_limit.rs, which I added locally for the runs below and is not in the PR. Both gpu::nvprofile tests pass.

The command

  • xcl nvprofile status before: xcl.exe: the driver's default shader heap (512 MB on D3D12).
  • xcl nvprofile install from an elevated prompt: xcl.exe is in the profile "XCL (xcl-dev)", then xcl.exe: shader heap 1024 MB.
  • xcl nvprofile status afterwards from a normal prompt: xcl.exe: shader heap 1024 MB. Reading needs no elevation, as the description says.

The limit (#2403's shader_code_limit.rs, unchanged, MODE=keep COUNT=600 STMTS=3000 THREADS=5)

removed at driver blobs
default (no profile) 261 pipelines 446 MB
install (1024 MB) 517 pipelines 885 MB

Both ended in 0x887a0005. The profile matches by executable name and only puts xcl.exe in it, so for the second row I copied the test binary to a folder of its own as xcl.exe and ran that copy. The first row is the binary under its own name. 885 MB is within 3 MB of the RTX 3090's 888 MB at 1 GiB in #2403, so the setting scales the same way on Ada.

Not tested

  • remove (I left the profile installed), --mb other than the default, and a second install over an existing profile.
  • The retail title with the profile: no world run here yet.
  • Other drivers, and AMD / Intel (the command should fail cleanly without nvapi64.dll; not checked).

Tested and written with Claude Code (Claude Opus 5.5).

**@⁠GXLD-N** on GitHub · 2026-11-26 02:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/2590#issuecomment-7180961070) **Tested on an RTX 4070 Ti SUPER (Ada, 16 GB): `xcl nvprofile install` raises the shader-code limit from 446 MB to 885 MB, the same as the RTX 3090 in #2403.** **Setup** - RTX 4070 Ti SUPER 16 GB, driver 32.0.16.1088, Ryzen 7 7800X3D, 32 GB RAM, Windows 11 26300, Rust 1.100.0, DXC 1.8.2502.11. - This PR's head `4bf94d0`, release build for the runs, debug for the suite. **Suite** - `cargo test --workspace -- --test-threads=4`: 1431 passed, 0 failed, 48 ignored, 26 `SKIPPED` (24 "no wave64", 1 "no heap windows", 1 Developer Mode for the driver cache). The 48 ignored include #2403's `shader_code_limit.rs`, which I added locally for the runs below and is not in the PR. Both `gpu::nvprofile` tests pass. **The command** - `xcl nvprofile status` before: `xcl.exe: the driver's default shader heap (512 MB on D3D12)`. - `xcl nvprofile install` from an elevated prompt: `xcl.exe is in the profile "XCL (xcl-dev)"`, then `xcl.exe: shader heap 1024 MB`. - `xcl nvprofile status` afterwards from a normal prompt: `xcl.exe: shader heap 1024 MB`. Reading needs no elevation, as the description says. **The limit** (#2403's `shader_code_limit.rs`, unchanged, `MODE=keep COUNT=600 STMTS=3000 THREADS=5`) | | removed at | driver blobs | |---|---:|---:| | default (no profile) | 261 pipelines | 446 MB | | `install` (1024 MB) | 517 pipelines | 885 MB | Both ended in `0x887a0005`. The profile matches by executable name and only puts `xcl.exe` in it, so for the second row I copied the test binary to a folder of its own as `xcl.exe` and ran that copy. The first row is the binary under its own name. 885 MB is within 3 MB of the RTX 3090's 888 MB at 1 GiB in #2403, so the setting scales the same way on Ada. **Not tested** - `remove` (I left the profile installed), `--mb` other than the default, and a second install over an existing profile. - The retail title with the profile: no world run here yet. - Other drivers, and AMD / Intel (the command should fail cleanly without `nvapi64.dll`; not checked). *Tested and written with Claude Code (Claude Opus 5.5).*
Author
Owner

@⁠pvfreis on GitHub · 2026-11-26 03:01 UTC · original

By reading only, not run, at 4bf94d07: xcl nvprofile install --mb 4096 asks the driver for a shader heap of 0 bytes.

  • parse accepts 512–4096 (nvprofile.rs:264), then (mb as u32) << 20 (:267) is 2^32 for 4096, which does not fit in a u32: the result is 0, in debug and release (<< only checks the shift amount).
  • install's only check of the value, the 64 KiB one (:185), passes 0, so 0 is what goes to NvAPI_DRS_SetSetting (:217-218).
  • Making 4095 the top of the range, or computing in u64 and refusing what does not fit in the u32 setting, would fix it. The test goes no higher than 2048 (:321).

AI use: Claude Code (Claude Opus 5.5) found this; Claude Fable 5.2 rechecked it; checked by a person before posting.

**@⁠pvfreis** on GitHub · 2026-11-26 03:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/2590#issuecomment-7181328961) By reading only, not run, at `4bf94d07`: **`xcl nvprofile install --mb 4096` asks the driver for a shader heap of 0 bytes.** - `parse` accepts 512–4096 (`nvprofile.rs:264`), then `(mb as u32) << 20` (`:267`) is 2^32 for 4096, which does not fit in a `u32`: the result is 0, in debug and release (`<<` only checks the shift amount). - `install`'s only check of the value, the 64 KiB one (`:185`), passes 0, so 0 is what goes to `NvAPI_DRS_SetSetting` (`:217-218`). - Making 4095 the top of the range, or computing in `u64` and refusing what does not fit in the `u32` setting, would fix it. The test goes no higher than 2048 (`:321`). **AI use:** Claude Code (Claude Opus 5.5) found this; Claude Fable 5.2 rechecked it; checked by a person before posting.
Author
Owner

@⁠Anon64 on GitHub · 2026-11-26 06:27 UTC · original · edited 2026-11-26 10:39 UTC

Tested 4bf94d0 on an RTX 3060 12 GB (NVIDIA 581.80, i9-14900KF, Windows 11 26200), release build: xcl nvprofile install stopped the retail title's device removal.

  • xcl nvprofile status before: xcl.exe: the driver's default shader heap (512 MB on D3D12). install --mb 1024 from an elevated prompt, then unelevated status: xcl.exe: shader heap 1024 MB.
  • With the default heap, the title lost the device (0x887a0005) at 81.6–84.4 s in 5 of 5 runs. With the profile, it ran to 274.8 s with no removal and reached its world, as described on #2403.
  • The runtime for those runs was nvidia-dev c044dc6. The profile matches it because the launcher starts the title's host from xcl.exe, with only the command line naming the title's exe.
  • One local change in my build: install was given the title's exe name as a second entry next to xcl.exe, in case the driver matched on that. It turned out not to be needed for the reason above, and I did not test install without it.

Update, --mb 2048: on nvidia-dev af2cecc4 with its shader preparation on (it builds the graphics and compute pipelines earlier runs used before the title starts), 1024 MB was not enough: the title lost the device (0x887a0005, empty DRED, video memory only ~270 MB over its budget) about 125 s in, with 3,569 pipelines built (675 of 256 KB or more). With install --mb 2048 (status: xcl.exe: shader heap 2048 MB) the same run built 3,934 (752 of 256 KB or more) with no removal and ended about 258 s in on the title's own watchdog while it waited for compute pipelines. One run each. So the more pipelines a run makes resident, the bigger the heap it needs; 1024 may be too small as a default once preparation is on.

Not tested: remove, --mb other than 1024 and 2048, the suite on this commit, AMD (the command should say there is no NVAPI).

AI use: Claude Code (Claude Opus 5.5) built it, ran the commands and the runs, and wrote this report.

**@⁠Anon64** on GitHub · 2026-11-26 06:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/2590#issuecomment-7184447776) · edited 2026-11-26 10:39 UTC **Tested `4bf94d0` on an RTX 3060 12 GB (NVIDIA 581.80, i9-14900KF, Windows 11 26200), release build: `xcl nvprofile install` stopped the retail title's device removal.** - `xcl nvprofile status` before: `xcl.exe: the driver's default shader heap (512 MB on D3D12)`. `install --mb 1024` from an elevated prompt, then unelevated `status`: `xcl.exe: shader heap 1024 MB`. - With the default heap, the title lost the device (`0x887a0005`) at 81.6–84.4 s in 5 of 5 runs. With the profile, it ran to 274.8 s with no removal and reached its world, as described on #2403. - The runtime for those runs was `nvidia-dev` `c044dc6`. The profile matches it because the launcher starts the title's host from `xcl.exe`, with only the command line naming the title's exe. - One local change in my build: `install` was given the title's exe name as a second entry next to `xcl.exe`, in case the driver matched on that. It turned out not to be needed for the reason above, and I did not test `install` without it. **Update, `--mb 2048`:** on `nvidia-dev` `af2cecc4` with its shader preparation on (it builds the graphics and compute pipelines earlier runs used before the title starts), 1024 MB was not enough: the title lost the device (`0x887a0005`, empty DRED, video memory only ~270 MB over its budget) about 125 s in, with 3,569 pipelines built (675 of 256 KB or more). With `install --mb 2048` (`status`: `xcl.exe: shader heap 2048 MB`) the same run built 3,934 (752 of 256 KB or more) with no removal and ended about 258 s in on the title's own watchdog while it waited for compute pipelines. One run each. So the more pipelines a run makes resident, the bigger the heap it needs; 1024 may be too small as a default once preparation is on. **Not tested:** `remove`, `--mb` other than 1024 and 2048, the suite on this commit, AMD (the command should say there is no NVAPI). AI use: Claude Code (Claude Opus 5.5) built it, ran the commands and the runs, and wrote this report.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 06:31 UTC · original · reviewed

remove() treats every non-NVAPI_OK result from FindProfileByName as “no XCL profile,” so a miscellaneous NVAPI failure can produce a successful exit even when the profile still exists. NVIDIA documents distinct NVAPI_PROFILE_NOT_FOUND and NVAPI_ERROR results for this call. The same error-as-absence pattern in status() makes an ambiguous basename match or a setting-read failure print the driver's default shader heap rather than an error. Could only the explicit profile/application/setting not-found codes map to None/false, with the other statuses propagated through check()? Mocking the DRS calls to return not-found versus NVAPI_ERROR (and ambiguous executable path for status) would verify the CLI exit and message without changing a real driver profile.

This is an exact-head source review of 4bf94d07c280c0adb9b00c2699b6972e64fed22d. I did not invoke NVAPI or modify driver settings. AI-assisted review with Codex.

**@⁠luckyteagirl** on GitHub · 2026-11-26 06:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/2590#pullrequestreview-6069526237) · **reviewed** `remove()` treats every non-`NVAPI_OK` result from `FindProfileByName` as “no XCL profile,” so a miscellaneous NVAPI failure can produce a successful exit even when the profile still exists. [NVIDIA documents](https://docs.nvidia.com/nvapi/group__drsapi.html) distinct `NVAPI_PROFILE_NOT_FOUND` and `NVAPI_ERROR` results for this call. The same error-as-absence pattern in `status()` makes an ambiguous basename match or a setting-read failure print the driver's default shader heap rather than an error. Could only the explicit profile/application/setting not-found codes map to `None`/`false`, with the other statuses propagated through `check()`? Mocking the DRS calls to return not-found versus `NVAPI_ERROR` (and ambiguous executable path for `status`) would verify the CLI exit and message without changing a real driver profile. This is an exact-head source review of `4bf94d07c280c0adb9b00c2699b6972e64fed22d`. I did not invoke NVAPI or modify driver settings. AI-assisted review with Codex.
Author
Owner

@⁠Raul-Paiva on GitHub · 2026-11-26 07:41 UTC · original · edited 2026-11-26 09:10 UTC

Tested 4bf94d0 on an RTX 3070 Laptop 8 GB: with xcl nvprofile install --mb 1024 the retail title's 0x887a0005 at world start is gone (removed at 281 s instead of 117 s). Behind it, though, the title is almost stopped from about 120 s, and the run ended in a TDR.

Setup:

  • RTX 3070 Laptop 8 GB, driver 621.24, i7-11800H, 32 GB RAM, Windows 10 19045, release build.
  • TdrDelay = 10 (set for an earlier test, see #505).
  • Tree: main b49be18 + this PR + #684, #751, #2385, #2097 d98d2d4, #2404 97a70a7, #2422, #2427 + #2428 c6e5af8, #2496 2e8ff6b, #2551, plus local diagnostics: a compute skip switch and Nsight Aftermath hooks. The skip list was empty in the 1 GiB run and in the default runs, except one default run noted below.
  • XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WINDOW_NO_CARRY=1 XCL_DRED=1, A pressed every 5 s, 600 s.
  • Compute precompiled with --precompile --only cs --pipelines for this tree.

What I checked:

  • xcl nvprofile unelevated: the default 512 MB.
  • xcl nvprofile install --mb 1024 in an elevated prompt (run by the tester), then xcl nvprofile unelevated: shader heap 1024 MB.

Results:

same build, same caches default (512 MB) 1 GiB profile
runs 1 (and 3 on the tree before, with #2404 551a75e) 1
world start (first #101) 105 s 102 s
presents per minute, 0–60 / 60–120 / 120–180 / 180–240 / 240–300 s 1 103 / 614 / 0 1 163 / 547 / 8 / 10 / 4
removed 116.7 s, 0x887a0005 (118.8 and 131.7 s in the others, and 124.8 s in one with 3 large compute programs left out by the skip switch), no 4101 event 280.9 s, 0x887a0006, with a Windows 4101 event and two nvlddmkm 153
  • So on this card the world-start removal was this limit, as for the 3060 and 4070 Ti SUPER above.
  • The run with the profile is not a working world:
    • From 120 s the title presents 4–10 frames per minute.
    • From 165 s, 164 GPU queue.Wait … did not complete within 5000 ms – released on CPU warnings appear.
    • At 281 s a submission ran over the 10 s TdrDelay.
    • DRED at that point: a compute list stopped at 6 851 of 15 360 operations, around 5 15 0 >5 15 0, on a pipeline logged as "a stand-in, or not translated".
  • The same near-stop from 120 s and the same queue-wait warnings show on an older tree with the default heap, where the device was not removed (main 6d12f58 + #2404 5ca9c23 and others, see #505). So that part is not caused by the profile; the profile only lets this tree reach it.
  • Peak memory with the profile: 13.2 GB local video memory, 33.4 GB committed by the process.

Not tested: more than one run with the profile; --mb 2048; xcl nvprofile remove; TdrDelay unset with the profile; a count of the shader code in use.

AI use: Claude Code (Claude Opus 5.5) built the tree, ran the runs, read the logs, DRED and the event log, and wrote this. The elevated install was run by the tester.

Edit: two more runs with the 1 GiB profile, same build and settings, skip list empty.

run presents per minute, 0–60 / 60–120 / 120–180 / 180–240 s last present end peak commit
1 (above) 1 163 / 547 / 8 / 10 270 s removed 280.9 s, 0x887a0006, 4101 event 33.4 GB
2 1 073 / 763 / 7 / 0 164.6 s process gone at ~171 s: Windows "virtual memory low" (2004 event: xcl.exe 36.1 GB), no XCL error 36.1 GB
3 (page file raised to 32 GB, commit limit ~63 GB) 1 104 / 736 / 8 / 4 198.2 s removed 221.5 s, 0x887a0006, 4101 event 34.6 GB
  • The profile keeps the device alive past the world start in 3 of 3 runs:
    • no 0x887a0005 in any of them;
    • every default-heap run on this build or the one before it was removed at 117 – 132 s.
  • What ends the runs is different:
    • two were a TDR with TdrDelay = 10;
    • one ran out of commit on a 32 GB machine with the default page file.
  • The world never runs: from ~114 s it presents about one frame every 6 – 8 s while it still records 300 – 2 600 dispatches per 2 s. The GPU queue-wait warnings (5 s) come before each TDR.
  • DRED differs between the two TDRs:
    • one stopped on a stand-in pipeline at 6 851 / 15 360 operations;
    • the other on a translated compute program at 53 / 4 671.
  • For other 8 GB / 32 GB machines: with the profile, the process can commit more than 32 GB here, so a default page file can end the run before anything else.

Correction: the local compute skip switch I listed under the tree had a side effect, even with an empty list. On every dispatch ExecuteIndirect it resolved the pipeline with pso_async::resolve_wait before the empty-list check, so a pending compute pipeline was waited for instead of put off to the submit. All runs above have that, on both sides of the comparison.

One more run without it:

  • Tree: this build + #2598, #2633, #2611 (conflict in device_x.rs, both sides kept) and #2691 (conflict in real.rs's tests, both kept), fresh precompile. The skip switch was off, with no env var.
  • Settings: the 1 GiB profile, same settings as above.
  • cargo test --workspace --release -- --test-threads=4: 1 476 passed, 0 failed, 48 ignored, 24 SKIPPED.
  • Presents per minute: 807 / 903 / 8 / 4. Last present at 200.6 s.
  • Removed at 216.0 s, 0x887a0006, with a 4101 event. DRED shows a compute list at 25 of 63 operations.
  • No queue-wait warnings this time. Peak commit 32.1 GB.

So the world-start stall and the TDR after it do not come from that switch.

**@⁠Raul-Paiva** on GitHub · 2026-11-26 07:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/2590#issuecomment-7185733717) · edited 2026-11-26 09:10 UTC **Tested `4bf94d0` on an RTX 3070 Laptop 8 GB: with `xcl nvprofile install --mb 1024` the retail title's `0x887a0005` at world start is gone (removed at 281 s instead of 117 s). Behind it, though, the title is almost stopped from about 120 s, and the run ended in a TDR.** **Setup:** - RTX 3070 Laptop 8 GB, driver 621.24, i7-11800H, 32 GB RAM, Windows 10 19045, release build. - `TdrDelay` = 10 (set for an earlier test, see #505). - Tree: `main` `b49be18` + this PR + #684, #751, #2385, #2097 `d98d2d4`, #2404 `97a70a7`, #2422, #2427 + #2428 `c6e5af8`, #2496 `2e8ff6b`, #2551, plus local diagnostics: a compute skip switch and Nsight Aftermath hooks. **The skip list was empty in the 1 GiB run and in the default runs, except one default run noted below**. - `XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WINDOW_NO_CARRY=1 XCL_DRED=1`, A pressed every 5 s, 600 s. - Compute precompiled with `--precompile --only cs --pipelines` for this tree. **What I checked:** - `xcl nvprofile` unelevated: the default 512 MB. - `xcl nvprofile install --mb 1024` in an elevated prompt (run by the tester), then `xcl nvprofile` unelevated: `shader heap 1024 MB`. **Results:** | same build, same caches | default (512 MB) | 1 GiB profile | |---|---|---| | runs | 1 (and 3 on the tree before, with #2404 `551a75e`) | 1 | | world start (first `#101`) | 105 s | 102 s | | presents per minute, 0–60 / 60–120 / 120–180 / 180–240 / 240–300 s | 1 103 / 614 / 0 | 1 163 / 547 / 8 / 10 / 4 | | removed | **116.7 s, `0x887a0005`** (118.8 and 131.7 s in the others, and 124.8 s in one with 3 large compute programs left out by the skip switch), no 4101 event | **280.9 s, `0x887a0006`**, with a Windows 4101 event and two `nvlddmkm` 153 | - So on this card the world-start removal was this limit, as for the 3060 and 4070 Ti SUPER above. - **The run with the profile is not a working world:** - From 120 s the title presents 4–10 frames per minute. - From 165 s, 164 `GPU queue.Wait … did not complete within 5000 ms – released on CPU` warnings appear. - At 281 s a submission ran over the 10 s `TdrDelay`. - DRED at that point: a compute list stopped at 6 851 of 15 360 operations, around `5 15 0 >5 15 0`, on a pipeline logged as "a stand-in, or not translated". - The same near-stop from 120 s and the same queue-wait warnings show on an older tree with the default heap, where the device was not removed (`main` `6d12f58` + #2404 `5ca9c23` and others, see #505). So that part is not caused by the profile; the profile only lets this tree reach it. - Peak memory with the profile: 13.2 GB local video memory, 33.4 GB committed by the process. **Not tested:** more than one run with the profile; `--mb 2048`; `xcl nvprofile remove`; `TdrDelay` unset with the profile; a count of the shader code in use. **AI use:** Claude Code (Claude Opus 5.5) built the tree, ran the runs, read the logs, DRED and the event log, and wrote this. The elevated `install` was run by the tester. **Edit: two more runs with the 1 GiB profile, same build and settings, skip list empty.** | run | presents per minute, 0–60 / 60–120 / 120–180 / 180–240 s | last present | end | peak commit | |---|---|---|---|---| | 1 (above) | 1 163 / 547 / 8 / 10 | 270 s | removed 280.9 s, `0x887a0006`, 4101 event | 33.4 GB | | 2 | 1 073 / 763 / 7 / 0 | 164.6 s | process gone at ~171 s: Windows "virtual memory low" (2004 event: `xcl.exe` 36.1 GB), no XCL error | 36.1 GB | | 3 (page file raised to 32 GB, commit limit ~63 GB) | 1 104 / 736 / 8 / 4 | 198.2 s | removed 221.5 s, `0x887a0006`, 4101 event | 34.6 GB | - **The profile keeps the device alive past the world start in 3 of 3 runs:** - no `0x887a0005` in any of them; - every default-heap run on this build or the one before it was removed at 117 – 132 s. - **What ends the runs is different:** - two were a TDR with `TdrDelay` = 10; - one ran out of commit on a 32 GB machine with the default page file. - **The world never runs:** from ~114 s it presents about one frame every 6 – 8 s while it still records 300 – 2 600 dispatches per 2 s. The GPU queue-wait warnings (5 s) come before each TDR. - **DRED differs between the two TDRs:** - one stopped on a stand-in pipeline at 6 851 / 15 360 operations; - the other on a translated compute program at 53 / 4 671. - **For other 8 GB / 32 GB machines:** with the profile, the process can commit more than 32 GB here, so a default page file can end the run before anything else. **Correction:** the local compute skip switch I listed under the tree had a side effect, even with an empty list. On every dispatch `ExecuteIndirect` it resolved the pipeline with `pso_async::resolve_wait` before the empty-list check, so a pending compute pipeline was waited for instead of put off to the submit. All runs above have that, on both sides of the comparison. **One more run without it:** - Tree: this build + #2598, #2633, #2611 (conflict in `device_x.rs`, both sides kept) and #2691 (conflict in `real.rs`'s tests, both kept), fresh precompile. The skip switch was off, with no env var. - Settings: the 1 GiB profile, same settings as above. - `cargo test --workspace --release -- --test-threads=4`: 1 476 passed, 0 failed, 48 ignored, 24 SKIPPED. - Presents per minute: 807 / 903 / 8 / 4. Last present at 200.6 s. - **Removed at 216.0 s, `0x887a0006`**, with a 4101 event. DRED shows a compute list at 25 of 63 operations. - No queue-wait warnings this time. Peak commit 32.1 GB. So the world-start stall and the TDR after it do not come from that switch.
github-bot force-pushed github-bot/gh-2590 from 4bf94d07c2 to 004fa0f61f 2026-11-26 08:52:59 +00:00 Compare
Author
Owner

@⁠afpruivo on GitHub · 2026-11-26 08:50 UTC · original

Thanks @⁠pvfreis, confirmed: 4096 << 20 wraps to 0 in a u32. The range is now 512–4095, with a test that 4096 is refused (004fa0f6).

AI use: Claude Code (Claude Opus 5.5).

**@⁠afpruivo** on GitHub · 2026-11-26 08:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2590#issuecomment-7187078642) Thanks @⁠pvfreis, confirmed: `4096 << 20` wraps to 0 in a u32. The range is now 512–4095, with a test that 4096 is refused (004fa0f6). AI use: Claude Code (Claude Opus 5.5).
Author
Owner

@⁠afpruivo on GitHub · 2026-11-26 08:50 UTC · original

Thanks @⁠luckyteagirl, confirmed against nvapi.h. A new found() treats only NVAPI's three not-found codes (-160, -163, -166) as absent. Anything else, including NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS (-182), is now an error in status, remove and install. The mapping has a unit test; the full DRS calls are not mocked (004fa0f6).

AI use: Claude Code (Claude Opus 5.5).

**@⁠afpruivo** on GitHub · 2026-11-26 08:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2590#issuecomment-7187079125) Thanks @⁠luckyteagirl, confirmed against `nvapi.h`. A new `found()` treats only NVAPI's three not-found codes (-160, -163, -166) as absent. Anything else, including `NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS` (-182), is now an error in `status`, `remove` and `install`. The mapping has a unit test; the full DRS calls are not mocked (004fa0f6). AI use: Claude Code (Claude Opus 5.5).
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-26 10:24 UTC · original

Independent Windows/NVIDIA check of #2590 head 004fa0f on current main b49be18.

Windows 11 build 26300, RTX 3080 Ti (12 GB, driver 621.35), rustc 1.99.1 MSVC. A clean exact-head checkout was used.

  • cargo build --offline --locked --workspace: passed.
  • cargo test --offline --locked -p xcl --lib gpu::nvprofile -- --nocapture --test-threads=1: 3 passed, 0 failed, 0 ignored. This includes the 4096 MB limit and unexpected-NVAPI-status cases.
  • target\debug\xcl.exe nvprofile status: exit 0, reports the driver's default 512 MB shader heap. A repeat after testing reported the same value.
  • target\debug\xcl.exe nvprofile install --mb 4096: rejected at argument parsing with exit 2 (expected 512 - 4095); this did not attempt a driver write.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --quiet: 1,438 passed, 0 failed, 47 ignored across 37 test executables. The output printed 25 GPU SKIPPED notices; those paths are not GPU coverage.

Not tested here: elevated install/remove, a profile change, a shader-heap limit probe, or a retail title run. These results verify the current head's build, tests, read-only status and input rejection on this adapter; they do not measure a larger heap or device-removal improvement.

AI use: Codex (GPT-6.2 Sol) ran the commands and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-26 10:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2590#issuecomment-7189321837) Independent Windows/NVIDIA check of [#2590 head `004fa0f`](https://github.com/xcl-dev/xcl/commit/004fa0f61f9c9cf1d881386adbf00877d5d0571f) on current [`main` `b49be18`](https://github.com/xcl-dev/xcl/commit/b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Windows 11 build 26300, RTX 3080 Ti (12 GB, driver 621.35), rustc 1.99.1 MSVC. A clean exact-head checkout was used. - `cargo build --offline --locked --workspace`: passed. - `cargo test --offline --locked -p xcl --lib gpu::nvprofile -- --nocapture --test-threads=1`: 3 passed, 0 failed, 0 ignored. This includes the 4096 MB limit and unexpected-NVAPI-status cases. - `target\debug\xcl.exe nvprofile status`: exit 0, reports the driver's default 512 MB shader heap. A repeat after testing reported the same value. - `target\debug\xcl.exe nvprofile install --mb 4096`: rejected at argument parsing with exit 2 (`expected 512 - 4095`); this did not attempt a driver write. - `cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --quiet`: 1,438 passed, 0 failed, 47 ignored across 37 test executables. The output printed 25 GPU `SKIPPED` notices; those paths are not GPU coverage. Not tested here: elevated `install`/`remove`, a profile change, a shader-heap limit probe, or a retail title run. These results verify the current head's build, tests, read-only status and input rejection on this adapter; they do not measure a larger heap or device-removal improvement. AI use: Codex (GPT-6.2 Sol) ran the commands and drafted this report.
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-26 10:34 UTC · original

One profile-ownership case remains on head 004fa0f. remove() looks up XCL (xcl-dev) by name, then deletes that entire profile and saves without checking its applications or settings. If a user already has a profile with that name containing other.exe or another setting, remove can discard those entries even when xcl.exe was never associated with it. install() can reuse the same profile, add xcl.exe, and change its shader setting for the other members. NVIDIA's DRS API documents profile-wide deletion/reset and persistent SaveSettings.

Could both commands refuse to alter an existing profile until XCL has verified it owns that profile and its contents? For example, mark XCL's application record at creation, then require a user-defined profile with only the expected marked application and profile-local shader setting before reuse or deletion. A focused DRS mock can supply a same-name profile with an unrelated app/setting, and one XCL-created profile later customized by the user; both install and remove should return an error without calling SaveSettings. This avoids changing a real driver profile to test the collision.

This is a source/API review; I did not create or change an NVIDIA profile to reproduce it. AI use: Codex (GPT-6.2 Astra) independently checked the NVAPI behavior; Codex (GPT-6.2 Sol) reviewed the code and drafted this comment.

**@⁠thehollowedone** on GitHub · 2026-11-26 10:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/2590#issuecomment-7189549068) One profile-ownership case remains on [head `004fa0f`](https://github.com/xcl-dev/xcl/commit/004fa0f61f9c9cf1d881386adbf00877d5d0571f). [`remove()`](https://github.com/xcl-dev/xcl/blob/004fa0f61f9c9cf1d881386adbf00877d5d0571f/crates/xcl/src/gpu/nvprofile.rs#L243-L255) looks up `XCL (xcl-dev)` by name, then deletes that entire profile and saves without checking its applications or settings. If a user already has a profile with that name containing `other.exe` or another setting, `remove` can discard those entries even when `xcl.exe` was never associated with it. [`install()`](https://github.com/xcl-dev/xcl/blob/004fa0f61f9c9cf1d881386adbf00877d5d0571f/crates/xcl/src/gpu/nvprofile.rs#L197-L239) can reuse the same profile, add `xcl.exe`, and change its shader setting for the other members. NVIDIA's [DRS API](https://docs.nvidia.com/nvapi/group__drsapi.html) documents profile-wide deletion/reset and persistent `SaveSettings`. Could both commands refuse to alter an existing profile until XCL has verified it owns that profile and its contents? For example, mark XCL's application record at creation, then require a user-defined profile with only the expected marked application and profile-local shader setting before reuse or deletion. A focused DRS mock can supply a same-name profile with an unrelated app/setting, and one XCL-created profile later customized by the user; both `install` and `remove` should return an error without calling `SaveSettings`. This avoids changing a real driver profile to test the collision. This is a source/API review; I did not create or change an NVIDIA profile to reproduce it. AI use: Codex (GPT-6.2 Astra) independently checked the NVAPI behavior; Codex (GPT-6.2 Sol) reviewed the code and drafted this comment.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2590/head:github-bot/gh-2590'
git switch 'github-bot/gh-2590'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2590'
git switch 'github-bot/gh-2590'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2590'
git switch 'github-bot/gh-2590'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2590'
git switch 'main'
git merge --squash 'github-bot/gh-2590'
git switch 'main'
git merge --ff-only 'github-bot/gh-2590'
git switch 'main'
git merge 'github-bot/gh-2590'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.