xcl run: xcl nvprofile puts xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) #2590
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2590
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2590"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@afpruivo on GitHub · 2026-11-26 00:47 UTC · original
afpruivo:nvprofile→main· +362 −0 · 4 files · 1 commits · draftNVIDIA'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). Setting0x001ABC0Fin a driver profile raises that reserve; NVIDIA's own profiles use 1 or 2 GiB for big titles. This addsxcl nvprofile, which writes that one setting forxcl.exethrough 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.dllthroughnvapi_QueryInterface,NvAPI_DRS_*.installputs the exe into a profile of its own,XCL (xcl-dev), holding only this setting, soremovedeletes exactly that.statusreads what the driver will use. Tests: the NVAPI struct sizes, the command line.crates/xcl/src/main.rs: thexcl nvprofile [status | install [--mb N] | remove]subcommand and its help text.--mbtakes 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_SetSettingreturns-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 onmainb49be18):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 4096is refused (it wrapped to a 0-byte heap); only NVAPI's not-found codes (-160, -163, -166, checked againstnvapi_lite_common.h) read as "no profile", any other status (e.g.NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS, -182) is an error instatus,removeandinstall. Unit tests for both; the DRS calls themselves are not mocked.28
SKIPPEDlines: 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 nvprofileunelevated: shows the default 512 MB forxcl.exe.xcl nvprofile installunelevated: refused with the elevation message, exit 1, nothing written.The same module, from #2403's
shader_code_limit.rswith 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 gives0x80000000, 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 namedxcl-noprofile.exeso 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-onlyusing #2551's precompiler, so no compute pipeline was built cold at the world start:xcl nvprofile install --mb 10240x887a0005at 102.5 s, DRED page fault at VA 0x0 with no allocations, then0x80000003)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-devaf2cecc4+ #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 2048may be the better choice onnvidia-dev.Regression run
main:
this PR:
The
mainrun 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 installandremovethroughxcl.exeitself, elevated. The same functions were tested elevated through the test above.AI use
🤖 Generated with Claude Code
xcl nvprofileputs xcl.exe in an NVIDIA profile with a bigger shader heap (#2403) 4bf94d07c2@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
@GXLD-N on GitHub · 2026-11-26 02:36 UTC · original
Tested on an RTX 4070 Ti SUPER (Ada, 16 GB):
xcl nvprofile installraises the shader-code limit from 446 MB to 885 MB, the same as the RTX 3090 in #2403.Setup
4bf94d0, release build for the runs, debug for the suite.Suite
cargo test --workspace -- --test-threads=4: 1431 passed, 0 failed, 48 ignored, 26SKIPPED(24 "no wave64", 1 "no heap windows", 1 Developer Mode for the driver cache). The 48 ignored include #2403'sshader_code_limit.rs, which I added locally for the runs below and is not in the PR. Bothgpu::nvprofiletests pass.The command
xcl nvprofile statusbefore:xcl.exe: the driver's default shader heap (512 MB on D3D12).xcl nvprofile installfrom an elevated prompt:xcl.exe is in the profile "XCL (xcl-dev)", thenxcl.exe: shader heap 1024 MB.xcl nvprofile statusafterwards 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)install(1024 MB)Both ended in
0x887a0005. The profile matches by executable name and only putsxcl.exein it, so for the second row I copied the test binary to a folder of its own asxcl.exeand 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),--mbother than the default, and a second install over an existing profile.nvapi64.dll; not checked).Tested and written with Claude Code (Claude Opus 5.5).
@pvfreis on GitHub · 2026-11-26 03:01 UTC · original
By reading only, not run, at
4bf94d07:xcl nvprofile install --mb 4096asks the driver for a shader heap of 0 bytes.parseaccepts 512–4096 (nvprofile.rs:264), then(mb as u32) << 20(:267) is 2^32 for 4096, which does not fit in au32: 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 toNvAPI_DRS_SetSetting(:217-218).u64and refusing what does not fit in theu32setting, 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 on GitHub · 2026-11-26 06:27 UTC · original · edited 2026-11-26 10:39 UTC
Tested
4bf94d0on an RTX 3060 12 GB (NVIDIA 581.80, i9-14900KF, Windows 11 26200), release build:xcl nvprofile installstopped the retail title's device removal.xcl nvprofile statusbefore:xcl.exe: the driver's default shader heap (512 MB on D3D12).install --mb 1024from an elevated prompt, then unelevatedstatus:xcl.exe: shader heap 1024 MB.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.nvidia-devc044dc6. The profile matches it because the launcher starts the title's host fromxcl.exe, with only the command line naming the title's exe.installwas given the title's exe name as a second entry next toxcl.exe, in case the driver matched on that. It turned out not to be needed for the reason above, and I did not testinstallwithout it.Update,
--mb 2048: onnvidia-devaf2cecc4with 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). Withinstall --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,--mbother 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.
@luckyteagirl on GitHub · 2026-11-26 06:31 UTC · original · reviewed
remove()treats every non-NVAPI_OKresult fromFindProfileByNameas “no XCL profile,” so a miscellaneous NVAPI failure can produce a successful exit even when the profile still exists. NVIDIA documents distinctNVAPI_PROFILE_NOT_FOUNDandNVAPI_ERRORresults for this call. The same error-as-absence pattern instatus()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 toNone/false, with the other statuses propagated throughcheck()? Mocking the DRS calls to return not-found versusNVAPI_ERROR(and ambiguous executable path forstatus) 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.@Raul-Paiva on GitHub · 2026-11-26 07:41 UTC · original · edited 2026-11-26 09:10 UTC
Tested
4bf94d0on an RTX 3070 Laptop 8 GB: withxcl nvprofile install --mb 1024the retail title's0x887a0005at 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:
TdrDelay= 10 (set for an earlier test, see #505).mainb49be18+ this PR + #684, #751, #2385, #2097d98d2d4, #240497a70a7, #2422, #2427 + #2428c6e5af8, #24962e8ff6b, #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.--precompile --only cs --pipelinesfor this tree.What I checked:
xcl nvprofileunelevated: the default 512 MB.xcl nvprofile install --mb 1024in an elevated prompt (run by the tester), thenxcl nvprofileunelevated:shader heap 1024 MB.Results:
551a75e)#101)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 event0x887a0006, with a Windows 4101 event and twonvlddmkm153GPU queue.Wait … did not complete within 5000 ms – released on CPUwarnings appear.TdrDelay.5 15 0 >5 15 0, on a pipeline logged as "a stand-in, or not translated".main6d12f58+ #24045ca9c23and others, see #505). So that part is not caused by the profile; the profile only lets this tree reach it.Not tested: more than one run with the profile;
--mb 2048;xcl nvprofile remove;TdrDelayunset 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
installwas run by the tester.Edit: two more runs with the 1 GiB profile, same build and settings, skip list empty.
0x887a0006, 4101 eventxcl.exe36.1 GB), no XCL error0x887a0006, 4101 event0x887a0005in any of them;TdrDelay= 10;Correction: the local compute skip switch I listed under the tree had a side effect, even with an empty list. On every dispatch
ExecuteIndirectit resolved the pipeline withpso_async::resolve_waitbefore 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:
device_x.rs, both sides kept) and #2691 (conflict inreal.rs's tests, both kept), fresh precompile. The skip switch was off, with no env var.cargo test --workspace --release -- --test-threads=4: 1 476 passed, 0 failed, 48 ignored, 24 SKIPPED.0x887a0006, with a 4101 event. DRED shows a compute list at 25 of 63 operations.So the world-start stall and the TDR after it do not come from that switch.
4bf94d07c2to004fa0f61f@afpruivo on GitHub · 2026-11-26 08:50 UTC · original
Thanks @pvfreis, confirmed:
4096 << 20wraps 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
Thanks @luckyteagirl, confirmed against
nvapi.h. A newfound()treats only NVAPI's three not-found codes (-160, -163, -166) as absent. Anything else, includingNVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS(-182), is now an error instatus,removeandinstall. The mapping has a unit test; the full DRS calls are not mocked (004fa0f6).AI use: Claude Code (Claude Opus 5.5).
@thehollowedone on GitHub · 2026-11-26 10:24 UTC · original
Independent Windows/NVIDIA check of #2590 head
004fa0fon currentmainb49be18.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 GPUSKIPPEDnotices; 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:34 UTC · original
One profile-ownership case remains on head
004fa0f.remove()looks upXCL (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 containingother.exeor another setting,removecan discard those entries even whenxcl.exewas never associated with it.install()can reuse the same profile, addxcl.exe, and change its shader setting for the other members. NVIDIA's DRS API documents profile-wide deletion/reset and persistentSaveSettings.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
installandremoveshould return an error without callingSaveSettings. 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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.