Skip to content

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

Draft
afpruivo wants to merge 1 commit into
xcl-dev:mainfrom
afpruivo:nvprofile
Draft

afpruivo wants to merge 1 commit into
xcl-dev:mainfrom
afpruivo:nvprofile

Conversation

@afpruivo

@afpruivo afpruivo commented Nov 26, 2026 •

Copy link
Copy Markdown

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 4096, 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.

  • cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4: 1431 passed, 0 failed, 47 ignored. (In the first run e2e failed only because cargo build --workspace had not run yet; after it, e2e: 4 passed.)

  • 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 NVIDIA: the device is removed when the pipelines in use need more than 512 MB of shader code (0x887a0005) #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 Shaders: --precompile --pipelines also builds a split program's whole form #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.

Regression run

main:

xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 3090
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 465 (PresentX 465)
presents per 2 s (last 3): 19 20 19
device removals: 0
crashes: 0
peak commit: 17267 MB

this PR:

xcl-smoke v1
commit: 4bf94d07c280c0adb9b00c2699b6972e64fed22d
gpu: NVIDIA GeForce RTX 3090
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1632 (PresentX 1632)
presents per 2 s (last 3): 59 60 60
device removals: 0
crashes: 0
peak commit: 16939 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.
  • 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

…ger shader heap (xcl-dev#2403)

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 <noreply@anthropic.com>
@DavidM1911

Copy link
Copy Markdown
Contributor

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

@GXLD-N

GXLD-N commented Nov 26, 2026

Copy link
Copy Markdown

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

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).

alex-IchiQ added a commit to alex-IchiQ/MrBigBalls_VI that referenced this pull request Nov 26, 2026
…or pipeline machine code

NVIDIA's D3D12 driver keeps 512 MB for the machine code of the pipelines in
use and removes the device (0x887a0005) past it. `victory nvprofile
[status | install [--mb N] | remove] [--exe NAME]` reads, or writes through
NVAPI's driver settings, setting 0x001ABC0F in a profile of its own holding
only that setting and the executable. Idea and setting from XCL
(xcl-dev/xcl#2590); the code is new.

Measured here (RTX 5070 Ti): the driver already ships a profile, "The
Culling", for another game's victory.exe, so status reports that profile
and install refuses for that name; another name goes with --exe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pvfreis

pvfreis commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

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.

@Anon64

Anon64 commented Nov 26, 2026

Copy link
Copy Markdown

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 NVIDIA: the device is removed when the pipelines in use need more than 512 MB of shader code (0x887a0005) #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.

Not tested: remove, --mb other than 1024, 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.

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

6 participants