[pr-fix][shaders][memory][NVIDIA] Add an opt-in NVIDIA shader heap profile #164

Open
umcakatabla wants to merge 1 commit from umcakatabla/Darner:codex/nvidia-shader-heap into main
Contributor

Refs #4

Contributor role (optional)

  • Fluxer ID:

What it changes

Adds darner nvidia-shader-heap status, install [one-gib|two-gib], and remove as explicit commands. An install checks the selected profile, stores the shader-heap reservation in a profile tied to the executable's full path, and verifies the value in a fresh NVAPI session. Removal checks ownership before deleting the profile. The command runs separately from gameplay.

The troubleshooting guide documents installation and removal. The approach is adapted from XCL PR #2590 for XCL issue #2403.

How it was tested

  • Tested revision: e6e599e. Gameplay used a release build with the same executable code.
  • Commands and results:
    • cargo clippy --workspace --all-targets --locked -- -D warnings, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings, and cargo xtask policy --staged passed.
    • cargo test --workspace --locked hit ask_once_by_res_splits_reservations_without_refusals once. That test passed on clean main and on the retry.
    • cargo test --workspace --locked -- --skip oracle64::legacy_mul_forms_are_exact hit the same two shader test failures as clean main 57dea7f. The failing tests were sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders and lds_shared_atomic_add_producer_executes_wave32_on_hardware.
  • Gameplay: RTX 4070 Ti SUPER, NVIDIA 621.40, Windows 11 build 26300, Series X, 1080-to-1440 output, DLSS Quality, 2x frame generation and hardware RT.
  • Before and after: Same executable, save, scripted route and initial pipeline library. The default profile hit 0x887A0005 at 24.1 seconds in the world (2,133 distinct pipelines). The 2 GiB profile reached the scheduled 1,200-second limit without a device removal (2,483 pipelines). An earlier default run reached its 360-second limit. A fresh NVAPI query verified 2 GiB after installation and the absence of the override after removal.
  • Coverage gaps: 1 GiB was outside the local gameplay test. The exhaustive legacy_mul_forms_are_exact test was excluded from the workspace retry. Both timed gameplay runs logged a Rust TLS teardown panic after reaching their limits.

Please review the NVAPI profile ownership and cleanup checks. If #4 reproduces on your NVIDIA system, please test a matched default-profile run and a one-gib or two-gib run. Include the GPU, driver, time to removal or test duration, and whether remove restored the original setting.

Checklist

  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #146, #140, #130, #48 and #47 share apps/darner/src/main.rs.
Refs #4 ## Contributor role (optional) - Fluxer ID: ## What it changes Adds `darner nvidia-shader-heap status`, `install [one-gib|two-gib]`, and `remove` as explicit commands. An install checks the selected profile, stores the shader-heap reservation in a profile tied to the executable's full path, and verifies the value in a fresh NVAPI session. Removal checks ownership before deleting the profile. The command runs separately from gameplay. The troubleshooting guide documents installation and removal. The approach is adapted from [XCL PR #2590](https://git.gtahub.st/github/xcl-dev--xcl/pulls/2590) for [XCL issue #2403](https://git.gtahub.st/github/xcl-dev--xcl/issues/2403). ## How it was tested - Tested revision: `e6e599e`. Gameplay used a release build with the same executable code. - Commands and results: - `cargo clippy --workspace --all-targets --locked -- -D warnings`, `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`, and `cargo xtask policy --staged` passed. - `cargo test --workspace --locked` hit `ask_once_by_res_splits_reservations_without_refusals` once. That test passed on clean main and on the retry. - `cargo test --workspace --locked -- --skip oracle64::legacy_mul_forms_are_exact` hit the same two shader test failures as clean main `57dea7f`. The failing tests were `sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders` and `lds_shared_atomic_add_producer_executes_wave32_on_hardware`. - Gameplay: RTX 4070 Ti SUPER, NVIDIA 621.40, Windows 11 build 26300, Series X, 1080-to-1440 output, DLSS Quality, 2x frame generation and hardware RT. - Before and after: Same executable, save, scripted route and initial pipeline library. The default profile hit `0x887A0005` at 24.1 seconds in the world (2,133 distinct pipelines). The 2 GiB profile reached the scheduled 1,200-second limit without a device removal (2,483 pipelines). An earlier default run reached its 360-second limit. A fresh NVAPI query verified 2 GiB after installation and the absence of the override after removal. - Coverage gaps: 1 GiB was outside the local gameplay test. The exhaustive `legacy_mul_forms_are_exact` test was excluded from the workspace retry. Both timed gameplay runs logged a Rust TLS teardown panic after reaching their limits. Please review the NVAPI profile ownership and cleanup checks. If #4 reproduces on your NVIDIA system, please test a matched default-profile run and a `one-gib` or `two-gib` run. Include the GPU, driver, time to removal or test duration, and whether `remove` restored the original setting. ## Checklist - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #146, #140, #130, #48 and #47 share `apps/darner/src/main.rs`.
First-time contributor

Tested on an RTX 4090: install one-gib holds for 38.9 min (control lost after 2 min 7 s); remove not tested

A matched pair as asked, on the 1 GiB value the description lists as a coverage gap. Built from e6e599e (cargo build --release --locked -p darner, version line v2026.12.03.01-23), copied beside the title as darner.pr164-e6e599e.exe. Same exe, save and area for both runs: Series X, 1440p, DLSS Quality, DLSS frame generation x2, HDR, hardware RT, no test switches.

System: Intel Core i9-13900K · 32 GB DDR5-6400 (2 sticks) · NVIDIA GeForce RTX 4090 24 GB, driver 621.40 · Windows 11 Pro build 26300

Run status before the run Result, from the first TLAS build Distinct pipelines first bound (compute)
control NVAPI exposes no shader-heap override (the measured D3D12 driver default is 512 MiB) lost (0x887A0005) after 2 min 7 s; a pipeline first bound 2 ms before; no nvlddmkm event 2,482 (1,035)
after install one-gib NVIDIA shader heap 1024 MiB from the application profile no loss, closed by hand at 38 min 51 s 3,819 (1,278)
  • In the second run the count passed the control's 2,482 two minutes in. Committed memory peaked at 41.1 GB, the card's own at 20.3 GB.
  • The first start of this build spent about 19 minutes before the world (the library was saved with made=1644); the second start was quick.

The commands

install one-gib from an elevated PowerShell in the exe's folder (path shortened by me):

Close NVIDIA Control Panel and profile editors while this command saves its one setting.
<game folder>\darner.pr164-e6e599e.exe: NVIDIA shader heap 1024 MiB from the application profile
Profile "Darner (TrustNo1) ac282ab2f6a5" saved. Newly started Darner processes use it.

status right after, and again from a terminal without administrator rights after the run, gave the same 1024 MiB line.

Next to a profile made by hand. This PC already had a profile "Darner" made with NVIDIA Profile Inspector (0x001ABC0F = 0x80000000) that lists other exe names, from my runs in #4. The install left it alone. status, run from copies of this build under three names in the same folder, without administrator rights:

Exe name Covered by status
darner.pr164-e6e599e.exe this PR's profile 1024 MiB from the application profile
a name listed in the hand-made profile "Darner" (Profile Inspector) 2048 MiB from the application profile
a name in neither nothing no shader-heap override, default 512 MiB

So status also reads a profile the command does not manage, and it answers by exe. That makes it a quick check for anyone who set the value with Profile Inspector and wants to know whether the driver picks it up for the exe they start; a profile attached to the wrong exe name, as reported in #84 (comment), would show here as "no shader-heap override".

Not tested: remove (the profile is still installed here), two-gib through this command, and install run for an exe name that a foreign profile already lists.

Seen in the long run, probably unrelated: driving very fast on the highway, other cars showed as low-detail models and disappeared before a collision. I have not checked whether the release exe does the same, so I am not attributing it to this change.

Log reading and this write-up were done with AI assistance.

## Tested on an RTX 4090: `install one-gib` holds for 38.9 min (control lost after 2 min 7 s); `remove` not tested A matched pair as asked, on the 1 GiB value the description lists as a coverage gap. Built from `e6e599e` (`cargo build --release --locked -p darner`, version line `v2026.12.03.01-23`), copied beside the title as `darner.pr164-e6e599e.exe`. Same exe, save and area for both runs: Series X, 1440p, DLSS Quality, DLSS frame generation x2, HDR, hardware RT, no test switches. **System:** Intel Core i9-13900K · 32 GB DDR5-6400 (2 sticks) · NVIDIA GeForce RTX 4090 24 GB, driver 621.40 · Windows 11 Pro build 26300 | Run | `status` before the run | Result, from the first TLAS build | Distinct pipelines first bound (compute) | |---|---|---|---| | control | `NVAPI exposes no shader-heap override (the measured D3D12 driver default is 512 MiB)` | **lost (`0x887A0005`) after 2 min 7 s**; a pipeline first bound 2 ms before; no `nvlddmkm` event | 2,482 (1,035) | | after `install one-gib` | `NVIDIA shader heap 1024 MiB from the application profile` | **no loss, closed by hand at 38 min 51 s** | 3,819 (1,278) | - In the second run the count passed the control's 2,482 two minutes in. Committed memory peaked at 41.1 GB, the card's own at 20.3 GB. - The first start of this build spent about 19 minutes before the world (the library was saved with `made=1644`); the second start was quick. **The commands** `install one-gib` from an elevated PowerShell in the exe's folder (path shortened by me): ``` Close NVIDIA Control Panel and profile editors while this command saves its one setting. <game folder>\darner.pr164-e6e599e.exe: NVIDIA shader heap 1024 MiB from the application profile Profile "Darner (TrustNo1) ac282ab2f6a5" saved. Newly started Darner processes use it. ``` `status` right after, and again from a terminal without administrator rights after the run, gave the same 1024 MiB line. **Next to a profile made by hand.** This PC already had a profile "Darner" made with NVIDIA Profile Inspector (`0x001ABC0F` = `0x80000000`) that lists other exe names, from my runs in #4. The install left it alone. `status`, run from copies of this build under three names in the same folder, without administrator rights: | Exe name | Covered by | `status` | |---|---|---| | `darner.pr164-e6e599e.exe` | this PR's profile | 1024 MiB from the application profile | | a name listed in the hand-made profile | "Darner" (Profile Inspector) | 2048 MiB from the application profile | | a name in neither | nothing | no shader-heap override, default 512 MiB | So `status` also reads a profile the command does not manage, and it answers by exe. That makes it a quick check for anyone who set the value with Profile Inspector and wants to know whether the driver picks it up for the exe they start; a profile attached to the wrong exe name, as reported in https://git.gtahub.st/TrustNo1/Darner/issues/84#issuecomment-857948, would show here as "no shader-heap override". **Not tested:** `remove` (the profile is still installed here), `two-gib` through this command, and `install` run for an exe name that a foreign profile already lists. **Seen in the long run, probably unrelated:** driving very fast on the highway, other cars showed as low-detail models and disappeared before a collision. I have not checked whether the release exe does the same, so I am not attributing it to this change. *Log reading and this write-up were done with AI assistance.*
Owner

That's a strong result. Driver default (512 MiB) lost the device after 2 min 7 s at 2,482 pipelines; 1024 MiB ran 38 min 51 s with no loss at 3,819 pipelines. Together with the 4070 Ti SUPER run, it ties the hardware RT device losses to the driver's shader heap filling up.

Main already has the same lever since 86c393e8: darner nv-profile (default 2048 MiB, --mb 1024, --status, --remove, --exe for a renamed exe). Rather than carry two installers, the plan is to keep that command and take over what this PR does better: the full-path binding and the checks after install.

One run that would help: the same save and area on the 4090 with darner.exe nv-profile from current main (administrator prompt, then darner.exe nv-profile --status to confirm 2048 MiB). If 2 GiB also holds for 30+ minutes, that's the value players get pointed to.

That's a strong result. Driver default (512 MiB) lost the device after 2 min 7 s at 2,482 pipelines; 1024 MiB ran 38 min 51 s with no loss at 3,819 pipelines. Together with the 4070 Ti SUPER run, it ties the hardware RT device losses to the driver's shader heap filling up. Main already has the same lever since 86c393e8: `darner nv-profile` (default 2048 MiB, `--mb 1024`, `--status`, `--remove`, `--exe` for a renamed exe). Rather than carry two installers, the plan is to keep that command and take over what this PR does better: the full-path binding and the checks after install. One run that would help: the same save and area on the 4090 with `darner.exe nv-profile` from current main (administrator prompt, then `darner.exe nv-profile --status` to confirm 2048 MiB). If 2 GiB also holds for 30+ minutes, that's the value players get pointed to.
First-time contributor

@TrustNo1 wrote in #164 (comment):

One run that would help: the same save and area on the 4090 with darner.exe nv-profile from current main (administrator prompt, then darner.exe nv-profile --status to confirm 2048 MiB). If 2 GiB also holds for 30+ minutes, that's the value players get pointed to.

Working on this now.

@TrustNo1 wrote in https://git.gtahub.st/TrustNo1/Darner/pulls/164#issuecomment-858048: > One run that would help: the same save and area on the 4090 with `darner.exe nv-profile` from current main (administrator prompt, then `darner.exe nv-profile --status` to confirm 2048 MiB). If 2 GiB also holds for 30+ minutes, that's the value players get pointed to. Working on this now.
First-time contributor

@TrustNo1 the run you asked for: nv-profile from current main at 2048 MiB held for 42 min 36 s on the 4090, no device loss.

Built from main a361afe (cargo build --release --locked -p darner, version line v2026.12.03.01-80), copied beside the title as darner.main-a361afe.exe. Same save and area as the two #164 runs above: Series X, 1440p, DLSS Quality, DLSS frame generation x2, HDR, hardware RT, no test switches.

System: Intel Core i9-13900K · 32 GB DDR5-6400 (2 sticks) · NVIDIA GeForce RTX 4090 24 GB, driver 621.40 · Windows 11 Pro build 26300

Run Heap Result, from the first TLAS build Distinct pipelines first bound (compute)
#164 control (above) driver default, 512 MiB lost (0x887A0005) after 2 min 7 s 2,482 (1,035)
#164 install one-gib (above) 1024 MiB no loss, 38 min 51 s, ended by me 3,819 (1,278)
main nv-profile 2048 MiB no loss, 42 min 36 s, ended by me 3,969 (1,270)
  • Command: darner.main-a361afe.exe nv-profile from an administrator prompt, no arguments. It made its own profile for the renamed exe without --exe.

  • Status, read before the run and again after it:

    darner.exe: profile "Darner", shader heap 2048 MiB (0x80000000)
    darner.main-a361afe.exe: profile "Darner (shader heap)", shader heap 2048 MiB (0x80000000)
    

    The first line is my hand-made Profile Inspector profile from the earlier runs on #4, which nv-profile left alone; the second is the one the command made, and the one this run used.

  • Pipelines: 3,969 is the highest count I have reached on this PC, about 1,500 past where the default heap lost the device in the control.

  • Memory: committed peaked at 41,190 MB; the card's own peaked at 20,292 MB.

  • Frame rate (base, by quarter of the session): 37, 30, 32, 23 fps average. It falls as the session goes on, as in my earlier long runs with either heap size.

  • Log: 0x887A0005 does not appear; the session ends with host pipeline library saved … made=2385 loaded=5029.

Not tested: --mb 1024, --remove, and --exe. One run, one PC.

@TrustNo1 the run you asked for: **`nv-profile` from current main at 2048 MiB held for 42 min 36 s on the 4090, no device loss.** Built from main `a361afe` (`cargo build --release --locked -p darner`, version line `v2026.12.03.01-80`), copied beside the title as `darner.main-a361afe.exe`. Same save and area as the two #164 runs above: Series X, 1440p, DLSS Quality, DLSS frame generation x2, HDR, hardware RT, no test switches. **System:** Intel Core i9-13900K · 32 GB DDR5-6400 (2 sticks) · NVIDIA GeForce RTX 4090 24 GB, driver 621.40 · Windows 11 Pro build 26300 | Run | Heap | Result, from the first TLAS build | Distinct pipelines first bound (compute) | |---|---|---|---| | #164 control (above) | driver default, 512 MiB | **lost (`0x887A0005`) after 2 min 7 s** | 2,482 (1,035) | | #164 `install one-gib` (above) | 1024 MiB | no loss, 38 min 51 s, ended by me | 3,819 (1,278) | | main `nv-profile` | 2048 MiB | **no loss, 42 min 36 s, ended by me** | 3,969 (1,270) | - **Command:** `darner.main-a361afe.exe nv-profile` from an administrator prompt, no arguments. It made its own profile for the renamed exe without `--exe`. - **Status, read before the run and again after it:** ~~~~text darner.exe: profile "Darner", shader heap 2048 MiB (0x80000000) darner.main-a361afe.exe: profile "Darner (shader heap)", shader heap 2048 MiB (0x80000000) ~~~~ The first line is my hand-made Profile Inspector profile from the earlier runs on #4, which `nv-profile` left alone; the second is the one the command made, and the one this run used. - **Pipelines:** 3,969 is the highest count I have reached on this PC, about 1,500 past where the default heap lost the device in the control. - **Memory:** committed peaked at 41,190 MB; the card's own peaked at 20,292 MB. - **Frame rate** (base, by quarter of the session): 37, 30, 32, 23 fps average. It falls as the session goes on, as in my earlier long runs with either heap size. - **Log:** `0x887A0005` does not appear; the session ends with `host pipeline library saved … made=2385 loaded=5029`. Not tested: `--mb 1024`, `--remove`, and `--exe`. One run, one PC.
This pull request has changes conflicting with the target branch.
  • apps/darner/src/main.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'codex/nvidia-shader-heap:umcakatabla-codex/nvidia-shader-heap'
git switch 'umcakatabla-codex/nvidia-shader-heap'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'umcakatabla-codex/nvidia-shader-heap'
git switch 'umcakatabla-codex/nvidia-shader-heap'
git rebase 'main'
git switch 'main'
git merge --ff-only 'umcakatabla-codex/nvidia-shader-heap'
git switch 'umcakatabla-codex/nvidia-shader-heap'
git rebase 'main'
git switch 'main'
git merge --no-ff 'umcakatabla-codex/nvidia-shader-heap'
git switch 'main'
git merge --squash 'umcakatabla-codex/nvidia-shader-heap'
git switch 'main'
git merge --ff-only 'umcakatabla-codex/nvidia-shader-heap'
git switch 'main'
git merge 'umcakatabla-codex/nvidia-shader-heap'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!164
No description provided.