fix(dlss): DLSS 5 is let go before the process exits, so its exit no longer faults the GPU #2807
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2807
Loading…
Reference in a new issue
No description provided.
Delete branch "bulldogsajr22/Longshot:fix/dlss5-exit-release"
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?
Summary
With DLSS 5 (Neural Rendering) On, about one exit in ten ended in an NVIDIA GPU fault at the second the game closed: Windows' event log shows
nvlddmkmevent 13, "Graphics SM Warp Exception ... MMU Fault", then event 153, a GPU reset (the screens go black for a moment). Once, the reset never came back and the PC froze. With DLSS 5 Off, it never happened. It started with DLSS 5 (#2503, #2513, in nightly-835); nothing like it came before on the same PC and driver.The cause: DLSS 5's feature was never let go at the exit. Every exit goes through
mkwvk_close_askedand then ends the process (ExitProcess, orTerminateProcessfor Windows' stop requests). That close lets DLSS Frame Generation go (dlss_fg_close) but not DLSS 5. So the process ended with frames that used DLSS 5 still on the GPU, while the model's library (nvngx_dlssnr) freed its own memory as it was unloaded.To see it on
main: DLSS 5 On, at 5120x2160 on an RTX 5090, load a save, play a minute, quit (the window's close, the Insert menu's Quit or Restart now, or the control bridge'squit), and repeat. About one exit in ten logs the fault and the reset (Event Viewer, Windows Logs, System, sourcenvlddmkm).What changes:
mkwvk_close_askedcallsdlss_nr_closefirst, before Streamline's shutdown returns early. Every exit goes through it: the window's close, the Insert menu's Quit and Restart now, the control bridge's quit and relaunch, and Windows' stop requests (Ctrl+C, log-off, shut down). On Linux, the SDL window's close goes through it too.dlss_nr_closemarks the exit, and the recording thread lets DLSS 5 go the way it does in play (drop_nr, under the locks it takes in play). This happens from the chain, or from each present (temporal_idle) when no frame is upscaled (a menu, the title). Nothing of DLSS 5's is made again after that. The release itself (temporal_later) runs once the GPU is done with every frame that used the model.dlss_fg_closewaits for the queue: about 20 to 90 ms in the game. It stops waiting after 0.5 s with no frame presented (a hung renderer), and after 2 s at most; the model is then left to the process's end, as onmain, and the log says why. DLSS 5's lock is tried, never waited for, so a recording thread stalled inside NGX with it held (in the model's making or its run) can't hold the close past those limits. A minimised window keeps presenting, so it is let go as in play.rx_close_asked, which every exit goes through, now ends the hold (hos_background_close_asked) before the renderer's close, and the game is never held again while it closes: its frames come and DLSS 5 is let go as in play.nr_release_feature): NVIDIA's file through NGX, and the community FP16 file through the direct path. In play, nothing changes but one relaxed atomic load in the chain and at each present.Read first:
dlss_nr_closeand the closing branches ofdlss_nr_idleanddlss_nr_chainingpu/vk/vk_dlss.cpp, thentemporal_idleingpu/vk/vk_temporal.cpp,hos_background_close_askedinhost/background_pause.c, andtests/test_dlss_nr_exit.py.See #2503, #2513 (DLSS 5), #2786 (Pause in background).
Testing
Tested: Windows 11 Pro (26H2, build 26300), Ryzen 9 9950X3D, RTX 5090, NVIDIA 621.40, 5120x2160 (21:9), ultrawide, DLSS 5 On: NVIDIA's file through NGX, and the community FP16 file through the direct path (
RX_VK_DLSS_NR_MODEL=fp16, the known file by its SHA-256).In the game, driven through the game's control bridge (
HOS_CONTROL): launch, load the save, play 30 to 60 s, exit, then check Windows' event log fornvlddmkmfaults and resets. 172 exits with DLSS 5 On, no GPU fault (nonvlddmkmevent of any kind in that time). Every exit that had DLSS 5 made logsvk: DLSS 5 Neural Rendering: let go for the exit (N ms, its frames done on the GPU), then DLSS Frame Gen's own line, except the 4 held runs below, which ran before the hold change.6011e3f3f(the review's change: the close tries DLSS 5's lock, never waits for it), onmain@01d6878b3, headless: NVIDIA's file, 6 exits, 4 quits in play and 2 with the pause menu open, let go in 18 to 51 ms.388b97c29, onmain@01d6878b3;b6ac561c6after it changed onlytests/), headless:DLSS 5 runs the community FP16 file, direct): 6 exits, 4 in play and 2 in the pause menu, let go in 19 to 53 ms.ab5b52f74, the same change as this head, before the clean-up below), windowed:pause: the game is held), then closed: each logspause: the game goes on after 7.8 s held (the game is closing), then the release (50 to 54 ms).main@01d6878b3with the rest of this PR): 4 exits held and closed, DLSS 5 left after 0.5 s (no frame presented for 0.5 s), no fault.main@22d0d200(where the fault was measured), with this PR's DLSS 5 part (dd122933a): 130 exits, mixed:quit);WM_CLOSE);ShowWindow, thenWM_CLOSE). The game keeps presenting while minimised (about 90 fps by the bridge's status,IsIconictrue), so DLSS 5 is let go as in play; 3 more such exits checked that (let go in about 50 ms).relaunch(the same close as the Insert menu's Restart now): DLSS 5 let go (49 ms), no fault. The game started again did not come back in this headless test setup, the same onmain. Onmain@22d0d200with DLSS 5 On, that restart's exit faulted the GPU (nvlddmkm13, then 153).main@22d0d200, the same loop with DLSS 5 Off: 60 exits, no fault (DLSS 5 never loads). With it On, the day's exits: 7 faults in 62, the last at exit 11 of the loop (p = 0.013 against Off, Fisher's exact test, two-sided).ab5b52f74, a clean-up, the behaviour the same:nr_resourcesalone decides whether anything of DLSS 5's is made (the feature and its parameters are only made with it set);dlss_nr_chaintakes its lock once;temporal_idleno longer rewritesholding.Checks:
tests/test_dlss_nr_exit.py(new) fails onmainand passes here, with g++ and clang++ on Linux, and built by llvm-mingw's clang++ and run on Windows. It compiles the realdlss_nr_close,dlss_nr_idle, the start ofdlss_nr_chain,drop_nr's DLSS 5 part, and vk_temporal.cpp'slater,free_deadand the start oftemporal_idle, with a fake renderer whose GPU runs two submissions behind. It checks:mkwvk_close_askedcalls it before Streamline's shutdown returns.Undoing each part of the fix makes it fail:
temporal_idlewoken at closing;mkwvk_close_asked, or that call moved after Streamline's shutdown.A close with no time limit fails at 10 s of the test's clock rather than hanging the check.
tests/test_pause_background.pygains a check that fails onmain(the game is still held 100 looks after a close was asked) and passes here, with gcc and clang on Linux, and built by llvm-mingw's clang and run on Windows.background_pause.cfrom its state on andrx_close_asked, with stand-ins for Windows' window and event calls.rx_close_asked, or the call moved after the renderer's close.tests/test_dlss_nr_chain.pygains a check, failing onmain, that at the exit the chain makes and runs nothing and lets go what was made.tests/test_dlss_nr_actions.py's stand-ins now know the exit flag. Both pass with g++ and clang++.Builds of this PR's code:
longshot-builder dev compile --only renderer, system clang, without NGX: the stubs) buildslongshot_vk.so, 271 units, no warning in them.host/background_pause.candhost/rx_backend.cwith-fsyntax-only -Wall -Wextraon Linux, gcc and clang: the same warnings asmain.mise run teston the head: 853 passed, 33 failed, 10 skipped. The same 33 fail onmain@01d6878b3(852 passed there). Each fails onmainthe same way, none for this PR's code: several on fixtures behindmain's own code (pause_background_nowandmovie_nowundeclared, among themtest_crt_options.pyandtest_upscaler_round_trip.py, which readvk_dlss.cpp), andtest_screensaver.py, which stubsrx_close_asked, ondisplay.c'sshow_game_window.mise run lintpasses.The 37 checks that fail on main too
test_bug_report.py,test_cloth_kernels.py,test_control_picture.py,test_crash_record.py,test_crt_options.py,test_dav1d_av1.py,test_dev_update.py,test_framegen_hdr.py,test_framegen_resources.py,test_fsr3_shaders.py,test_fsr3fi_hud_layer.py,test_fsr3fi_hudless_colour.py,test_guest_holes.py,test_host_shaders.py,test_input_background.py,test_lifter.py,test_linux_pressure.py,test_loaded_modules_drop.py,test_log_levels.py,test_menu_keys.py,test_oot_cloth.py,test_option_ids.py,test_perf_send.py,test_pipeline_tour.py,test_present_source_crop.py,test_program_cache_cleanup.py,test_program_cache_one_variant.py,test_screensaver.py,test_switch_table.py,test_temporal_present_bandwidth.py,test_upscaler_round_trip.py,test_vcore_video_acquire.py,test_video_catchup.py,test_video_hold_early.py,test_video_input_limit.py,test_windows_on_linux.py,test_xinput_thread.pyStill to test:
RX_VK_DLSS_NR_LINUX=1, the experiment): quit in play and with the pause menu open, expecting the "let go for the exit" line and noNVRM: Xidfault indmesg(@Beanstalk DLSS 5 exit on Linux NVIDIA with RX_VK_DLSS_NR_LINUX=1: quit in play and in the pause menu, check the log line and dmesg)nvlddmkmevent (@Beanstalk DLSS 5 FP16 file exit on RTX 20-40: quit in play, check the log line and the event log)Measurements
Verdict: the exit's GPU fault with DLSS 5 On is gone: 0 in 172 exits here, against 7 in 62 on
main(p < 0.0001, Fisher's exact test, two-sided). The exit takes 17 to 88 ms more for the release; play is unchanged.Setup: Windows 11, RTX 5090, NVIDIA 621.40, 5120x2160 ultrawide, DLSS 5 On. Launch, load the save (Shadow Temple), play 30 to 60 s, exit, then check Windows' event log. The exit's time is from the game's log line. After: the head
6011e3f3f(6 exits),388b97c29, this PR's code before the review (12;b6ac561c6after it changed onlytests/),ab5b52f74(16, Pause in background On; 4 more before its hold change) and this PR's DLSS 5 part onmain@22d0d200(134: the 130, the 3 minimised checks and the relaunch), as Testing says.22d0d2006011e3f3fnvlddmkmMMU fault, DLSS 5 Ontest_dlss_nr_exit.pytest_pause_background.py01d6878b3In play, the cost is one relaxed atomic load per chain and per present; there is nothing to measure there.
Risks
main.main. By then no frame of it is on the GPU; that case (Pause in background's hold, before this PR ended it at the close) ran 4 times with no fault.gpu/vk/dlss_nr_model.h).Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11, RTX 5090, NVIDIA 621.40, 5120x2160, DLSS 5 On, Shadow Temple save: 165 exits (quit in play, pause menu, window close, minimised then closed, Pause in background held then closed, the bridge's relaunch; NVIDIA's file and the community FP16 file), no nvlddmkm fault, each logging DLSS 5 let go for the exit in 17 to 86 ms. main @
22d0d200: 7 faults in 62 exits.Possibly related, for context:
388b97c29cb6ac561c62Pushed
b6ac561c6(the test commit amended, the fix replayed on it;gpu/andhost/unchanged from388b97c29):tests/test_pause_background.py: the close fixture'srx_end_claimstand-in is declared off Windows only, as inrx_backend.c. On Windows it was unused, and-Werrorstopped the check from compiling. Both new checks now also build with llvm-mingw and run on Windows, and pass.tests/test_dlss_nr_exit.py: an unused field and include path removed; the docstring rewrapped.ab5b52f74, a window close there released in 88 ms), the medians recomputed, and both Fisher's p-values two-sided.mise run test: 849 passed, the same 37 failing as onmain.WIP: fix(dlss): DLSS 5 is let go before the process exits, so its exit no longer faults the GPUto fix(dlss): DLSS 5 is let go before the process exits, so its exit no longer faults the GPUOn the Measurements'
main(22d0d200against the base,01d6878b3): the numbers still hold.mkwvk_close_askedis the same in both, and nothing of DLSS 5's, Streamline's or the temporal chain's changed.01d6878b3too: this PR's code at388b97c29(12 exits, NVIDIA's file and the community FP16 file) and onab5b52f74(20, Pause in background On). No fault, and every release logged.01d6878b3itself: the same DLSS 5 On exits are not run again on purpose, since about one in ten resets the GPU, and once a reset never came back.@Beanstalk linux nvidia, and an RTX 20, 30 or 40 on Windows: this head (
b6ac561c), the two items of Still to test. Each needs a DLSS 5 file the farm PC has itself (Longshot doesn't download one, docs/user/dlss5.md); without it, say so, and that item stays open.RX_VK_DLSS_NR_LINUX=1. The native NGX must offer neural rendering: if the Graphics tab shows no DLSS 5 row, stop there and say so.Windows, RTX 20, 30 or 40: the community FP16 file as
nvngx_dlssnr.dllin%LOCALAPPDATA%\Longshot\ngx\fp16\. The game's log saysDLSS 5 runs the community FP16 file, direct.kokiri-startand play about 30 s.Expected at every exit: the game's log has
vk: DLSS 5 Neural Rendering: let go for the exit (N ms, its frames done on the GPU), and no GPU fault (Linux: noNVRM: Xidline indmesgfrom that time; Windows: nonvlddmkmevent in Event Viewer, Windows Logs, System).@bulldogsajr22 only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was for388b97c, and the PR has changed since (6011e3f), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.@review
Recommendation: Approve. The release substantially reduced exit faults in the reported RTX 5090 runs, but shutdown can wait indefinitely on the DLSS state lock before reaching its timeout. The Linux and older RTX paths also still need their requested game runs. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
The change retires DLSS 5 before process exit and wakes a game held in the background so it can present the frames needed for retirement. It adds a bounded intended wait to exit, but the lock acquisition itself is unbounded.
Should fix (1): not blocking, but worth doing before merging.
gpu/vk/vk_dlss.cpp:1643: The close takes the DLSS state mutex without a timeout before starting, and during, its timed wait. (more on the line) Do: Make observing retirement bounded without waiting indefinitely for s.mu, for example by publishing the retirement state separately and using a timed or nonblocking lock with the same close deadline.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes on the tested RTX 5090 setup: the author reports 0 faults in 166 exits with variants of the fix versus 7 in 62 on an earlier main commit; 32 after-side exits used the current base. Linux and RTX 20–40 remain untested.
Other systems: The DLSS release path affects NVIDIA on Windows and experimental Linux; the background-pause change affects close behavior independently of GPU. The reported runs cover Windows on RTX 5090, including both model paths and held closes; the requested Linux and older RTX runs remain outstanding.
Switches: None added, changed, or removed.
Reviewed:
b6ac561c62against01d6878b3f: Read the repository rules, contribution guide, PR template, standards, full production diff, commit messages, shutdown and retirement paths, background-pause implementation, and the new exit and pause test changes. Skimmed the remaining changed test fixtures and surrounding renderer code; the full changed renderer and host files were not read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, tests, or project scripts were run. The author reports 166 fault-free Windows exits and game-free checks against the base.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -1615,0 +1640,4 @@nr_closing.store(true, std::memory_order_release);State& s = st();const auto settled = [&s] {std::lock_guard lock(s.mu);L1 (should fix): The close takes the DLSS state mutex without a timeout before starting, and during, its timed wait. A stalled recording thread can therefore prevent the process from closing indefinitely.
When: If the driver or model stalls in feature creation or evaluation while dlss_nr_chain holds s.mu, settled() blocks on that mutex. Neither the 0.5-second no-present timeout nor the two-second limit can run, and the window close cannot reach the existing bounded renderer shutdown.
Do: Make observing retirement bounded without waiting indefinitely for s.mu, for example by publishing the retirement state separately and using a timed or nonblocking lock with the same close deadline.
b6ac561c626011e3f3f6Pushed
6011e3f3f(beb650823the test, then the fix), answering BeanBot's review (#2807 (comment)), asked for by @llun:main's exit never takes that lock.dlss_nr_closenow tries it (try_to_lock) at each look, between its 2 ms sleeps, and never waits for it: a recording thread stalled inside NGX with the lock held leaves the exit to the same 0.5 s and 2 s limits. When the lock is only busy at the first look (DLSS's upscale takes it each frame) and nothing of DLSS 5's was made, the close says nothing, as before.tests/test_dlss_nr_exit.py: a thread holds the lock with no frame presented; the close ends 0.5 s after the last frame and says why (a watchdog fails a close that waits, rather than hanging the check). And never made, the lock busy at the first look: no line.the close waits for DLSS 5's lock, held by a stalled recording thread); without the quiet return, the second. Both pass with gcc and clang on Linux, and built by llvm-mingw and run on Windows.vk_dlss.cppbuilt for Windows with the build's own flags and-Wall -Wextra: the same warnings as before the change, none new. Every test that readsvk_dlss.cppgives the same result as before it.b6ac561c, so it is asked again for this head in the next comment.In the game, this head: 6 exits with DLSS 5 On (4 quits in play, 2 with the pause menu open), each let go in 18 to 51 ms, no GPU fault; the description's Testing and Measurements include them.
mise run test: 853 passed, the same 33 failing as onmain@01d6878b3;mise run lintpasses.@Beanstalk linux nvidia, and an RTX 20, 30 or 40 on Windows: this head (
6011e3f, after the review), the two items of Still to test. (Asked again: the earlier request was forb6ac561.) Each needs a DLSS 5 file the farm PC has itself (Longshot doesn't download one, docs/user/dlss5.md); without it, say so, and that item stays open.RX_VK_DLSS_NR_LINUX=1. The native NGX must offer neural rendering: if the Graphics tab shows no DLSS 5 row, stop there and say so.Windows, RTX 20, 30 or 40: the community FP16 file as
nvngx_dlssnr.dllin%LOCALAPPDATA%\Longshot\ngx\fp16\. The game's log saysDLSS 5 runs the community FP16 file, direct.kokiri-startand play about 30 s.Expected at every exit: the game's log has
vk: DLSS 5 Neural Rendering: let go for the exit (N ms, its frames done on the GPU), and no GPU fault (Linux: noNVRM: Xidline indmesgfrom that time; Windows: nonvlddmkmevent in Event Viewer, Windows Logs, System).@bulldogsajr22 only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.@review
Recommendation: Approve. The code is ready: only testing is left. The close no longer waits on the DLSS mutex, and the reported Windows runs show the exit fault substantially reduced. Linux NVIDIA and RTX 20–40 FP16 exit runs are still outstanding. Recommend approval; not approved on the forge.
The change releases DLSS 5 after its GPU work finishes before exit, and resumes a background-held game so it can present the frames needed for release. It adds a bounded exit wait and close-path coordination.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
Since the last review (on
b6ac561c62)Resolved: L1 (The close takes the DLSS state mutex without a timeout before starting, and during, its ti…)
Still open: L2 (The experimental Linux NVIDIA release path has not yet been exercised in game.); L3 (The community FP16 direct path has only been run on RTX 50 hardware.)
Checks: Cancelled on this head (no result):
PR description / Title and description (pull_request_target). Still running: 10 checks.More: does it help, other systems, switches, what was read
Does it help: Yes: the author reports 0 faults in 172 exits after the change versus 7 in 62 on main, on an RTX 5090. Reported release waits were 17–88 ms before the latest fix and 18–51 ms for six exits on the latest head.
Other systems: The release path also affects experimental Linux NVIDIA and the community FP16 model on older RTX cards; both still need the requested game runs. The no-NGX build has no-op stubs, and background pause is resumed before renderer shutdown.
Switches: None added, changed or removed.
Reviewed:
6011e3f3f6against01d6878b3f: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the full diff since the ledger, the main diff and relevant close-path references; skimmed the longer test fixtures and pull request diff. The changed code files were not all read in full. Tooling's adjacent AGENTS.md and docs/review-checklist.md were not present.; nothing run (a code review).Checked and fine:
Testing: No commands that run project code or tests were executed. The author reports game-free checks and Windows and Linux builds; CI is still running.
Overlaps and merge order: None identified from the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.