D3D12.X: compute pipelines not used for a while are released on NVIDIA #2526

Open
github-bot wants to merge 2 commits from github-bot/gh-2526 into main AGit
Owner

@⁠veyn-sudo on GitHub · 2026-11-25 21:37 UTC · original
veyn-sudo:pr/release-unused-shader-code → main · +699 −28 · 7 files · 2 commits · draft

Stacked on #2422; only the top commit belongs here.

NVIDIA's driver keeps the compiled code of the pipelines in use in a heap of at most 512 MB and removes the device when a submission needs more (#2403). Code counts from a pipeline's first use until it is released, so this releases compute pipelines that are not in use and builds them again at their next bind. Part of #2403.

It is not enough by itself. With the translations of the default path one command allocator's recordings use 289 MB here, and nothing a recording uses can be released: the device was still removed (132 s and 200 s into a run, 134-141 s without). With XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 the code is about 40 % smaller. CharlyRien has a version of this of their own and reports no removal in 480 s with it and the direct path (#2403).

What is in it

  • hle/d3d12x/shader_code.rs (new): which pipelines count, what recordings hold, what to release. XCL_SHADER_CODE_MB is the code to keep in use (GetCachedBlob sizes): 320 on NVIDIA, no limit elsewhere, 0 for none.
  • pso_async.rs: a build can run again (Job is FnMut); past the limit the compute pipelines bound longest ago are released, none used in the last second. Their next bind builds them itself: a turn in the workers' queue behind first builds took minutes.
  • A dispatch put off to the submit (list_x::record_deferred) hands its pipelines to its segment's allocator too: its segment is reset without cl_reset (found by KDenKC).
  • What a recording uses stays: resolving gives the thread a reference, a bind hands it to the allocator the list records on, and that allocator's Reset (or the pool knowing that no list is on it and the GPU is done, alloc_pool::when_done, which checks and takes under one lock) gives it back.
  • real/dispatch_chain.rs: all pieces of a split program count, and its recordings let go of them in the same step.
  • Only compute pipelines behind shared stand-ins: XCL owns those, and their bind waits for them. Graphics code counts but stays, as it would flicker.
  • Tests: the choice of what to release, a bound pipeline living until its allocator's reset, release and rebuild with and without a wait budget, when_done taking under the lock, a split program's recordings and pieces, a dispatch put off to the submit keeping its pipeline with its segment.

699 added lines, 58 of them #2422's and 81 the deferred-dispatch fix and its test. I did not find a smaller part that does anything alone: releasing is unsafe without the references, and they do nothing without it. #2417 keeps resolved pipelines alive too; if it goes in, the references here can use it.

Tested

  • RTX 2070 SUPER (driver 617.14), i7-9700K, 32 GB, Windows 11 26300, Rust 1.99.0, debug for the tests, release for the title.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 0fd22d04: 1441 passed, 0 failed, 47 ignored.
  • 25 SKIPPED lines: 21 no wave64, 3 f16 forms refused, 1 no heap windows.
  • In some runs of one test group a_dispatch_with_a_pipeline_still_building_waits_at_the_submit fails; it does on main e1d84b7 too (4 of 12). execute_indirect_reads_the_arguments_written_before_it failed once with out of memory, not in 8 repeats.
  • The title on a local tree with an earlier version of this and other open PRs, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_DIRECT_SPLIT_INSTRUCTIONS=0: six runs reached the world and were stopped by low memory after 158-170 s, without a removal, the one with XCL_SHADER_CODE_MB=0 too. In the two where it was measured at most 116 and 132 MB of code was in use, far under 320. With XCL_SHADER_CODE_MB=60 45 pipelines were released and 121 MB stayed in use.

Regression run

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 404998dc
seconds: 60
exit: 0x0
frames shown: 1485 (PresentX 1485)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14603 MB

this PR:

xcl-smoke v1
commit: 0fd22d04dc7931066a8560fe178119a2040d0da9
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 404998dc
seconds: 60
exit: 0x0
frames shown: 1549 (PresentX 1549)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14416 MB

Not tested

  • The smoke run does not reach the limit. The fixed version in the world. Split programs in the title. AMD and Intel (off there by default). Whether 320 MB is the best value on other cards. A long world run that has to release with the direct path. Pipelines bound on a list that the pool does not know (a fresh split segment) stay until #2333 is in.

AI use

  • Claude Code with Claude Opus 5.5 wrote the code and the tests, ran everything on my PC and wrote this description.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WStEFektfHt5AEbK6Wupac

**@⁠veyn-sudo** on GitHub · 2026-11-25 21:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526) `veyn-sudo:pr/release-unused-shader-code` → `main` · +699 −28 · 7 files · 2 commits · draft Stacked on #2422; only the top commit belongs here. NVIDIA's driver keeps the compiled code of the pipelines in use in a heap of at most 512 MB and removes the device when a submission needs more (#2403). Code counts from a pipeline's first use until it is released, so this releases compute pipelines that are not in use and builds them again at their next bind. Part of #2403. **It is not enough by itself.** With the translations of the default path one command allocator's recordings use 289 MB here, and nothing a recording uses can be released: the device was still removed (132 s and 200 s into a run, 134-141 s without). With `XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1` the code is about 40 % smaller. CharlyRien has a version of this of their own and reports no removal in 480 s with it and the direct path (#2403). **What is in it** - `hle/d3d12x/shader_code.rs` (new): which pipelines count, what recordings hold, what to release. `XCL_SHADER_CODE_MB` is the code to keep in use (`GetCachedBlob` sizes): 320 on NVIDIA, no limit elsewhere, 0 for none. - `pso_async.rs`: a build can run again (`Job` is `FnMut`); past the limit the compute pipelines bound longest ago are released, none used in the last second. Their next bind builds them itself: a turn in the workers' queue behind first builds took minutes. - A dispatch put off to the submit (`list_x::record_deferred`) hands its pipelines to its segment's allocator too: its segment is reset without `cl_reset` (found by KDenKC). - What a recording uses stays: resolving gives the thread a reference, a bind hands it to the allocator the list records on, and that allocator's `Reset` (or the pool knowing that no list is on it and the GPU is done, `alloc_pool::when_done`, which checks and takes under one lock) gives it back. - `real/dispatch_chain.rs`: all pieces of a split program count, and its recordings let go of them in the same step. - Only compute pipelines behind shared stand-ins: XCL owns those, and their bind waits for them. Graphics code counts but stays, as it would flicker. - Tests: the choice of what to release, a bound pipeline living until its allocator's reset, release and rebuild with and without a wait budget, `when_done` taking under the lock, a split program's recordings and pieces, a dispatch put off to the submit keeping its pipeline with its segment. 699 added lines, 58 of them #2422's and 81 the deferred-dispatch fix and its test. I did not find a smaller part that does anything alone: releasing is unsafe without the references, and they do nothing without it. #2417 keeps resolved pipelines alive too; if it goes in, the references here can use it. **Tested** - RTX 2070 SUPER (driver 617.14), i7-9700K, 32 GB, Windows 11 26300, Rust 1.99.0, debug for the tests, release for the title. - `cargo test --workspace --no-fail-fast -- --test-threads=4` on `0fd22d04`: 1441 passed, 0 failed, 47 ignored. - 25 `SKIPPED` lines: 21 no wave64, 3 f16 forms refused, 1 no heap windows. - In some runs of one test group `a_dispatch_with_a_pipeline_still_building_waits_at_the_submit` fails; it does on `main` `e1d84b7` too (4 of 12). `execute_indirect_reads_the_arguments_written_before_it` failed once with out of memory, not in 8 repeats. - The title on a local tree with an earlier version of this and other open PRs, `XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_DIRECT_SPLIT_INSTRUCTIONS=0`: six runs reached the world and were stopped by low memory after 158-170 s, without a removal, the one with `XCL_SHADER_CODE_MB=0` too. In the two where it was measured at most 116 and 132 MB of code was in use, far under 320. With `XCL_SHADER_CODE_MB=60` 45 pipelines were released and 121 MB stayed in use. **Regression run** main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 2070 SUPER title: 404998dc seconds: 60 exit: 0x0 frames shown: 1485 (PresentX 1485) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14603 MB ``` this PR: ``` xcl-smoke v1 commit: 0fd22d04dc7931066a8560fe178119a2040d0da9 gpu: NVIDIA GeForce RTX 2070 SUPER title: 404998dc seconds: 60 exit: 0x0 frames shown: 1549 (PresentX 1549) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14416 MB ``` **Not tested** - The smoke run does not reach the limit. The fixed version in the world. Split programs in the title. AMD and Intel (off there by default). Whether 320 MB is the best value on other cards. A long world run that has to release with the direct path. Pipelines bound on a list that the pool does not know (a fresh split segment) stay until #2333 is in. **AI use** - Claude Code with Claude Opus 5.5 wrote the code and the tests, ran everything on my PC and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WStEFektfHt5AEbK6Wupac
pso_release dropped what XCL keeps of a pipeline after the driver had freed it. A pipeline made by
another thread in between could get the same address and lose its own entries: a translated compute
program then counts as untranslated and its dispatches are skipped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WStEFektfHt5AEbK6Wupac
NVIDIA's driver keeps the code of the pipelines in use in a heap of at most 512 MB and removes the
device (0x887a0005, nothing in DRED, no event) when a submission needs more. With more than
XCL_SHADER_CODE_MB of compiled code in use (320 on NVIDIA, no limit elsewhere) the compute
pipelines bound longest ago are released, but none a recording holds; their next bind builds them
again from the driver's cache.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WStEFektfHt5AEbK6Wupac
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:32:57 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 21:54 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. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 21:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7175685541) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠pvfreis on GitHub · 2026-11-25 21:58 UTC · original

By reading only, at 5b59fe4 (not run). Three points before the long direct-path run:

  1. Split programs (default with XCL_DIRECT_DXIL=1; your run had =0): count sees piece 0 only. dispatch_chain::RECORDINGS keeps piece 0 and the chain until Reset, so after let_go_done a release can free nothing, and the next bind builds a second set.
  2. let_go_done checks, then removes, with no lock across. If another thread records on a in between, its references go too; a pass over a second later can free a pipeline still in flight. Checking and removing under one lock closes it.
  3. Until #2333 is in, pipelines bound on a fresh split segment are never released. list_x::split without an idle spare makes a list alloc_pool does not know: bound gets 0, which is never reset, so they stay in in_recordings(), also after the title releases them. #2333 (a7b93a8) registers the segment and merges cleanly with this.

AI use: Claude Code (Claude Opus 5.5) found this; a second Claude Opus 5.5 re-derived it; Claude Fable 5.2 reviewed the text; checked by a person before posting.

**@⁠pvfreis** on GitHub · 2026-11-25 21:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7175768267) By reading only, at `5b59fe4` (not run). Three points before the long direct-path run: 1. **Split programs** (default with `XCL_DIRECT_DXIL=1`; your run had `=0`): `count` sees piece 0 only. `dispatch_chain::RECORDINGS` keeps piece 0 and the chain until `Reset`, so after `let_go_done` a release can free nothing, and the next bind builds a second set. 2. **`let_go_done`** checks, then removes, with no lock across. If another thread records on `a` in between, its references go too; a pass over a second later can free a pipeline still in flight. Checking and removing under one lock closes it. 3. **Until #2333 is in, pipelines bound on a fresh split segment are never released.** `list_x::split` without an idle spare makes a list `alloc_pool` does not know: `bound` gets 0, which is never reset, so they stay in `in_recordings()`, also after the title releases them. #2333 (`a7b93a8`) registers the segment and merges cleanly with this. **AI use:** Claude Code (Claude Opus 5.5) found this; a second Claude Opus 5.5 re-derived it; Claude Fable 5.2 reviewed the text; checked by a person before posting.
Author
Owner

@⁠veyn-sudo on GitHub · 2026-11-25 22:11 UTC · original

Thanks, checked against the code: all three are right. 2 is a real race, and I'm fixing it here by checking and removing under one lock. 1 and 3 I'm fixing too; until then please don't read results on 5b59fe4 as final, and run it with XCL_DIRECT_SPLIT_INSTRUCTIONS=0. 2 can free a pipeline that is still in flight.

AI use: Claude Code (Claude Opus 5.5) wrote this.

**@⁠veyn-sudo** on GitHub · 2026-11-25 22:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7176059031) Thanks, checked against the code: all three are right. 2 is a real race, and I'm fixing it here by checking and removing under one lock. 1 and 3 I'm fixing too; until then please don't read results on `5b59fe4` as final, and run it with `XCL_DIRECT_SPLIT_INSTRUCTIONS=0`. 2 can free a pipeline that is still in flight. AI use: Claude Code (Claude Opus 5.5) wrote this.
Author
Owner

@⁠veyn-sudo on GitHub · 2026-11-25 22:36 UTC · original

1 and 2 are fixed in the new head. For 3 I was too quick: #2333 already fixes the split segments, so I'm not duplicating it here, and the two conflict in dispatch_chain.rs. Until it is in, those pipelines stay: in one run here 62 of 524 bound pipelines were only under allocator 0.

AI use: Claude Code (Claude Opus 5.5) wrote this.

**@⁠veyn-sudo** on GitHub · 2026-11-25 22:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7176567612) 1 and 2 are fixed in the new head. For 3 I was too quick: #2333 already fixes the split segments, so I'm not duplicating it here, and the two conflict in `dispatch_chain.rs`. Until it is in, those pipelines stay: in one run here 62 of 524 bound pipelines were only under allocator 0. AI use: Claude Code (Claude Opus 5.5) wrote this.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 23:07 UTC · original

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of the compute-pipeline lifetime tests (a_pipeline_is_forgotten_before_its_address_is_free, an_unused_compute_pipeline_is_released_and_built_again, the_longest_unused_go_first_and_only_as_many_as_it_takes, a_bound_pipeline_lives_until_its_allocator_is_reset, a_chains_recordings_let_go_of_every_piece): 5 passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-25 23:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7177181732) **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). `gpu_` suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Targeted run of the compute-pipeline lifetime tests (`a_pipeline_is_forgotten_before_its_address_is_free`, `an_unused_compute_pipeline_is_released_and_built_again`, `the_longest_unused_go_first_and_only_as_many_as_it_takes`, `a_bound_pipeline_lives_until_its_allocator_is_reset`, `a_chains_recordings_let_go_of_every_piece`): 5 passed. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Author
Owner

@⁠KDenKC on GitHub · 2026-11-26 00:22 UTC · original

@⁠veyn-sudo, results for this PR at four budgets on the retail title, using its own count line (you asked @⁠Pipodi for counter runs in #2403; these bracket your NVIDIA default of 320): the removal at world start still comes in every arm, while the count is at or under ~370 MB. Results from one RTX 5090.

Setup

  • RTX 5090 32 GB, driver 621.24; Ryzen 7 9800X3D; 62 GB RAM; Windows 11 26200; release.
  • Tree db0e838 = main 08db802 + #684 e56dbc3 + #2333 a7b93a85 + #2404 809da30 + #2526 6d19dc0 + #2551 3567b2e. It includes a local merge resolution: #2333 and #2404 conflict in real/dispatch_chain.rs, and #2526 conflicts in appended tests. The resolution keeps both sides and was reviewed by a second person before the build. #2551 is in so the title reaches its world within the run: without it, cold whole forms of split programs hold it before world start.
  • One exe and one exe name for every arm. Every arm started from a fresh copy of the same cache: compute precompiled with #2551 (--used-only), graphics mostly warm.
  • XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_TRACE=1 XCL_NETWORK=0 plus XCL_SHADER_CODE_MB, 200 s per arm, the same scripted input, no driver profile changes.

Results

XCL_SHADER_CODE_MB compute PSOs released your count ("MB of shader code left in use") device removed (0x887a0005) peak commit
0 – – 138.0 s 36.7 GB
250 83 (126.5–131.5 s) 250 → 314 135.4 s 35.5 GB
340 19 (134.3–136.5 s) 340 → 368 136.6 s 36.5 GB
370 0 (never reached 370) < 370 134.6 s 35.2 GB

In every arm the world's work starts at ~126 s (200–770 draws and 2,000–8,000 dispatches per 2 s, 0–3 presents), and the device is removed 8–12 s later. No GPU-wait timeouts and no skipped draws in any arm; 0–128 skipped dispatches.

Observations

  • With a 370 MB limit nothing was released, and the device was still removed: the heap filled while the counted code was under 370 MB.
  • With 250 MB, 83 compute pipelines were released within 5 s, and the count still rose from 250 to 314 MB. The removal came at the same point as the other arms. It didn't thrash into waits; it ran out of heap.
  • From the PR's own doc, as we read it: the count is GetCachedBlob sizes, about 1/9 under what the code takes in the heap, and it covers lazily built pipelines. Graphics are counted but never released. Not counted: pipelines built in the call (outside pso_async), stand-ins, and the driver's own code. (@⁠Jonas-automated measured about 80 MB of the heap going to the driver's background work on a 4090: #2403.) So 340–370 MB counted is roughly 380–415 MB in the heap before those.
  • The margin is small to begin with: @⁠Kalmarv measured ~321 MiB bound within one second at world start (#2403), so any budget has to sit just under the limit.
  • Graphics are a sizable share. The cache's 276 graphics driver blobs alone are 87 MiB, a lower bound, since most of this title's graphics pipelines came from NVIDIA's own cache.

Possible next steps (not tested):

  • Release graphics pipelines not used lately too.
  • Count pipelines built outside pso_async (and stand-ins) toward the limit.
  • A log of the counted bytes split into graphics and compute at each release would show the split directly. We couldn't separate them from the current line.

Not measured: the graphics/compute split of the count at the removal; how many released pipelines were rebuilt; frame times; a second run of each arm (they ran once, in the order 0, 340, 370, 250, under one exe name, so NVIDIA's own cache warmed across arms); any other GPU or driver; the larger shader-heap driver setting.

Thanks to SlopTart for the RADV/Wine lifetime results (#2526), and for your correction on the pool race and split-tail accounting (#2526), which made this head the one to run.

AI use: Claude Code (Claude Opus 5.5) built the tree, ran the arms, measured the logs and wrote this comment.

**@⁠KDenKC** on GitHub · 2026-11-26 00:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7178686346) @⁠veyn-sudo, results for this PR at four budgets on the retail title, using its own count line (you asked @⁠Pipodi for counter runs in https://git.gtahub.st/github/xcl-dev--xcl/issues/2403; these bracket your NVIDIA default of 320): the removal at world start still comes in every arm, while the count is at or under ~370 MB. Results from one RTX 5090. **Setup** - RTX 5090 32 GB, driver 621.24; Ryzen 7 9800X3D; 62 GB RAM; Windows 11 26200; release. - Tree `db0e838` = `main` `08db802` + #684 `e56dbc3` + #2333 `a7b93a85` + #2404 `809da30` + #2526 `6d19dc0` + #2551 `3567b2e`. It **includes a local merge resolution**: #2333 and #2404 conflict in `real/dispatch_chain.rs`, and #2526 conflicts in appended tests. The resolution keeps both sides and was reviewed by a second person before the build. #2551 is in so the title reaches its world within the run: without it, cold whole forms of split programs hold it before world start. - One exe and one exe name for every arm. Every arm started from a fresh copy of the same cache: compute precompiled with #2551 (`--used-only`), graphics mostly warm. - `XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_TRACE=1 XCL_NETWORK=0` plus `XCL_SHADER_CODE_MB`, 200 s per arm, the same scripted input, no driver profile changes. **Results** | `XCL_SHADER_CODE_MB` | compute PSOs released | your count ("MB of shader code left in use") | device removed (`0x887a0005`) | peak commit | |---|---|---|---|---| | 0 | – | – | 138.0 s | 36.7 GB | | 250 | 83 (126.5–131.5 s) | 250 → **314** | 135.4 s | 35.5 GB | | 340 | 19 (134.3–136.5 s) | 340 → 368 | 136.6 s | 36.5 GB | | 370 | 0 (never reached 370) | < 370 | 134.6 s | 35.2 GB | In every arm the world's work starts at ~126 s (200–770 draws and 2,000–8,000 dispatches per 2 s, 0–3 presents), and the device is removed 8–12 s later. No GPU-wait timeouts and no skipped draws in any arm; 0–128 skipped dispatches. **Observations** - With a 370 MB limit nothing was released, and the device was still removed: the heap filled while the counted code was under 370 MB. - With 250 MB, 83 compute pipelines were released within 5 s, and the count still **rose from 250 to 314 MB**. The removal came at the same point as the other arms. It didn't thrash into waits; it ran out of heap. - From the PR's own doc, as we read it: the count is `GetCachedBlob` sizes, about 1/9 under what the code takes in the heap, and it covers lazily built pipelines. Graphics are counted but never released. Not counted: pipelines built in the call (outside `pso_async`), stand-ins, and the driver's own code. (@⁠Jonas-automated measured about 80 MB of the heap going to the driver's background work on a 4090: https://git.gtahub.st/github/xcl-dev--xcl/issues/2403.) So 340–370 MB counted is roughly 380–415 MB in the heap before those. - The margin is small to begin with: @⁠Kalmarv measured ~321 MiB bound within one second at world start (https://git.gtahub.st/github/xcl-dev--xcl/issues/2403), so any budget has to sit just under the limit. - Graphics are a sizable share. The cache's 276 graphics driver blobs alone are 87 MiB, a lower bound, since most of this title's graphics pipelines came from NVIDIA's own cache. **Possible next steps** (not tested): - Release graphics pipelines not used lately too. - Count pipelines built outside `pso_async` (and stand-ins) toward the limit. - A log of the counted bytes split into graphics and compute at each release would show the split directly. We couldn't separate them from the current line. **Not measured:** the graphics/compute split of the count at the removal; how many released pipelines were rebuilt; frame times; a second run of each arm (they ran once, in the order 0, 340, 370, 250, under one exe name, so NVIDIA's own cache warmed across arms); any other GPU or driver; the larger shader-heap driver setting. Thanks to SlopTart for the RADV/Wine lifetime results (https://git.gtahub.st/github/xcl-dev--xcl/pulls/2526), and for your correction on the pool race and split-tail accounting (https://git.gtahub.st/github/xcl-dev--xcl/pulls/2526), which made this head the one to run. **AI use:** Claude Code (Claude Opus 5.5) built the tree, ran the arms, measured the logs and wrote this comment.
Author
Owner

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

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 01:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7179944828) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
Author
Owner

@⁠itsSio on GitHub · 2026-11-26 03:24 UTC · original

Independent dual-PC NVIDIA full-workspace test report on clean head 6d19dc04d80f4f502de54d8aa6c1f714fb8c10d7.

Tested

  • Machine 1: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200.9974, rustc 1.97.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug build
    • cargo build --workspace: exit 0 (1 warning)
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1428 passed, 0 failed, 46 ignored (shader_code, pso_async::used_tests, dispatch_chain::tests, and fallback_stream_tests all passed)
    • SKIPPED: 26 (wave64-only GPU tests, #1426 wave32 f16/cvt refusals, no heap windows, pso_measurement driver-cache disable 0x887A002D)
  • Machine 2: NVIDIA GeForce RTX 2080 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200.8653, rustc 1.99.1 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC 1.8.2502.11, debug build
    • cargo build --workspace: exit 0 (3 warnings)
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1428 passed, 0 failed, 46 ignored
    • SKIPPED: 29 (same 26 as Machine 1 plus 3 requiring d3d12SDKLayers.dll)

Not tested

  • Retail title / scripts/smoke.ps1 runs
  • Release builds (--release)
  • AMD / Intel GPUs, native wave64, Linux / Wine / vkd3d-proton

AI use
Ran via Samaritan:

  • Google Antigravity CLI (Gemini 4 Hydrogen (High)): built the branch and ran the workspace test suite on both NVIDIA machines.
  • Google Antigravity CLI (Gemini 4 Neon (High)): coordinated the runs and wrote this test report.
**@⁠itsSio** on GitHub · 2026-11-26 03:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7181693719) Independent dual-PC NVIDIA full-workspace test report on clean head `6d19dc04d80f4f502de54d8aa6c1f714fb8c10d7`. **Tested** - **Machine 1:** NVIDIA GeForce RTX 5080 (driver `32.0.16.1088`), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200.9974, `rustc 1.97.0` (`stable-x86_64-pc-windows-msvc`), DXC `1.9.2609.5`, debug build - `cargo build --workspace`: exit 0 (1 warning) - `cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture`: **1428 passed, 0 failed, 46 ignored** (`shader_code`, `pso_async::used_tests`, `dispatch_chain::tests`, and `fallback_stream_tests` all passed) - `SKIPPED`: 26 (wave64-only GPU tests, `#1426` wave32 f16/cvt refusals, no heap windows, `pso_measurement` driver-cache disable `0x887A002D`) - **Machine 2:** NVIDIA GeForce RTX 2080 SUPER (driver `32.0.16.1088`), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200.8653, `rustc 1.99.1` (`stable-x86_64-pc-windows-msvc`), Windows SDK 10.0.26100 DXC `1.8.2502.11`, debug build - `cargo build --workspace`: exit 0 (3 warnings) - `cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture`: **1428 passed, 0 failed, 46 ignored** - `SKIPPED`: 29 (same 26 as Machine 1 plus 3 requiring `d3d12SDKLayers.dll`) **Not tested** - Retail title / `scripts/smoke.ps1` runs - Release builds (`--release`) - AMD / Intel GPUs, native wave64, Linux / Wine / vkd3d-proton **AI use** Ran via Samaritan: - Google Antigravity CLI (Gemini 4 Hydrogen (High)): built the branch and ran the workspace test suite on both NVIDIA machines. - Google Antigravity CLI (Gemini 4 Neon (High)): coordinated the runs and wrote this test report.
Author
Owner

@⁠pvfreis on GitHub · 2026-11-26 04:25 UTC · original

@⁠veyn-sudo a data point for "Graphics code counts but stays", and for the graphics share KDenKC raised above: on an RTX 3060, graphics and mesh pipelines fill the same shader-code reserve as compute, at about their blob size.

Tested

  • RTX 3060 (617.14), Ryzen 9 5900XT, Windows 11. Sandbox: non-interactive session, Low integrity, debug, --test-threads=4, NVIDIA 32-lane waves only. One run per mode, main b49be183 (this PR's code is not involved).
  • Your shader_code_limit.rs from #2403 with three modes added, each mode in its own process: unique synthetic programs of 500 statements, each used once and kept until the device is removed. Compute gets one dispatch each. Graphics get a unique VS + PS (the 500 statements are in the PS) and one draw covering a 4x4 offscreen target. Mesh gets the 500 statements in a one-thread mesh shader that outputs a full-screen triangle, a small unique PS, and one DispatchMesh each. Mixed alternates compute and graphics. GetCachedBlob sizes, summed up to the removal (MB = 10^6 bytes):
mode pipelines at removal compute graphics total
compute only 1,563 469.6 MB – 469.6 MB (447.8 MiB)
graphics only 1,498 – 462.7 MB 462.7 MB (441.3 MiB)
mesh only 1,564 – 464.0 MB (mesh) 464.0 MB (442.5 MiB)
mixed 758 compute + 754 graphics 227.8 MB 232.9 MB 460.6 MB (439.3 MiB)
  • All four modes ended in 0x887a0005, and no pipeline failed to create. Compute alone matches #2403's 446–449 (the test's "MB" is >> 20).
  • In mixed mode the device was removed when the sum of both reached the limit, with compute at 228 MB. Graphics only, mesh only and mixed ended 1.5 %, 1.2 % and 1.9 % under compute only: one run each, so I read that as the same limit, not as a difference.
  • So on this card counting graphics in the one budget (pso_async.rs:1143) is right, and graphics that stay take room from the same reserve: when they hold much of it, releasing compute alone can't keep the sum under it.
  • On the graphics / compute log split KDenKC suggested: the count is printed only when something was released (if n != 0, pso_async.rs:1192-1195), so a run that releases nothing shows no count. Printing the split there also when n == 0 would show in title runs how much of the reserve graphics and mesh hold.

(Posted here only; the limit data itself is the #2403 test's.)

Not tested: whether the title's own mix of programs behaves like these synthetic ones; whether the driver's background code and the heap-to-blob overhead apply to graphics the same way, amplification shaders, other GPUs and drivers, a larger reserve from a driver profile, a title run, this PR's code.

AI use: Claude Code. Claude Opus 5.5 wrote the three modes, ran them and wrote this; Claude Fable 5.2 rechecked it.

**@⁠pvfreis** on GitHub · 2026-11-26 04:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7182589600) @⁠veyn-sudo a data point for "Graphics code counts but stays", and for the graphics share KDenKC raised above: on an RTX 3060, graphics and mesh pipelines fill the same shader-code reserve as compute, at about their blob size. **Tested** - RTX 3060 (617.14), Ryzen 9 5900XT, Windows 11. Sandbox: non-interactive session, Low integrity, debug, `--test-threads=4`, NVIDIA 32-lane waves only. One run per mode, `main` `b49be183` (this PR's code is not involved). - Your `shader_code_limit.rs` from #2403 with three modes added, each mode in its own process: unique synthetic programs of 500 statements, each used once and kept until the device is removed. Compute gets one dispatch each. Graphics get a unique VS + PS (the 500 statements are in the PS) and one draw covering a 4x4 offscreen target. Mesh gets the 500 statements in a one-thread mesh shader that outputs a full-screen triangle, a small unique PS, and one `DispatchMesh` each. Mixed alternates compute and graphics. `GetCachedBlob` sizes, summed up to the removal (MB = 10^6 bytes): | mode | pipelines at removal | compute | graphics | total | |---|---:|---:|---:|---:| | compute only | 1,563 | 469.6 MB | – | 469.6 MB (447.8 MiB) | | graphics only | 1,498 | – | 462.7 MB | 462.7 MB (441.3 MiB) | | mesh only | 1,564 | – | 464.0 MB (mesh) | 464.0 MB (442.5 MiB) | | mixed | 758 compute + 754 graphics | 227.8 MB | 232.9 MB | 460.6 MB (439.3 MiB) | - All four modes ended in `0x887a0005`, and no pipeline failed to create. Compute alone matches #2403's 446–449 (the test's "MB" is `>> 20`). - In mixed mode the device was removed when the sum of both reached the limit, with compute at 228 MB. Graphics only, mesh only and mixed ended 1.5 %, 1.2 % and 1.9 % under compute only: one run each, so I read that as the same limit, not as a difference. - So on this card counting graphics in the one budget (`pso_async.rs:1143`) is right, and graphics that stay take room from the same reserve: when they hold much of it, releasing compute alone can't keep the sum under it. - On the graphics / compute log split KDenKC suggested: the count is printed only when something was released (`if n != 0`, `pso_async.rs:1192-1195`), so a run that releases nothing shows no count. Printing the split there also when `n == 0` would show in title runs how much of the reserve graphics and mesh hold. (Posted here only; the limit data itself is the #2403 test's.) **Not tested:** whether the title's own mix of programs behaves like these synthetic ones; whether the driver's background code and the heap-to-blob overhead apply to graphics the same way, amplification shaders, other GPUs and drivers, a larger reserve from a driver profile, a title run, this PR's code. **AI use:** Claude Code. Claude Opus 5.5 wrote the three modes, ran them and wrote this; Claude Fable 5.2 rechecked it.
Author
Owner

@⁠KDenKC on GitHub · 2026-11-26 06:06 UTC · original

Source review of head 6d19dc04, no run. I found one gap in how deferred dispatches keep their pipeline alive.

list_x::record_deferred (around list_x.rs:2716) records each deferred dispatch on its own segment with bind::dispatch / bind::execute_indirect. Those resolve through pso_async::resolve_wait, which calls Pending::take, which holds a Ref. The segment is then closed, but nothing in that loop calls shader_code::bound/bound_on for the segment's allocator, the way split does. So the reference stays in the thread's HELD:

  • With more than HELD_MAX (4) distinct pipelines in one submission's deferred dispatches, the earlier Refs are popped and dropped right away.
  • Otherwise they are drained into whichever allocator the thread binds on next, and that allocator's Reset drops them.

After that, only Pending.real holds the pipeline, and it is not in in_recordings(). Once used() > limit() and 1 s has passed since its last resolve (note_use), the next release_unused can release it while the segment may still be executing. This is the cold path: a pipeline still building at SetPipelineState (stand-in, nothing held), built by the submit. World load is also when the code budget is over and a submission can take more than a second.

A shader_code::bound_on(<the segment's allocator>) after the dispatch in record_deferred would tie the references to the segment. The inline bind::dispatch / execute_indirect and console_list::close take the same resolve_wait path without a bound. Those are usually drained by the next bind on the same list, so the deferred loop is the main window.

Not tested: we have not run this head. This is from reading the source only.

AI use: Gemini (Antigravity) flagged it in a first-pass review. Claude Code (Claude Opus 5.5) traced the path in the source at 6d19dc04 and wrote this.

**@⁠KDenKC** on GitHub · 2026-11-26 06:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7184093605) Source review of head `6d19dc04`, no run. I found one gap in how deferred dispatches keep their pipeline alive. `list_x::record_deferred` (around `list_x.rs:2716`) records each deferred dispatch on its own segment with `bind::dispatch` / `bind::execute_indirect`. Those resolve through `pso_async::resolve_wait`, which calls `Pending::take`, which `hold`s a `Ref`. The segment is then closed, but nothing in that loop calls `shader_code::bound`/`bound_on` for the segment's allocator, the way `split` does. So the reference stays in the thread's `HELD`: - With more than `HELD_MAX` (4) distinct pipelines in one submission's deferred dispatches, the earlier `Ref`s are popped and dropped right away. - Otherwise they are drained into whichever allocator the thread binds on next, and that allocator's `Reset` drops them. After that, only `Pending.real` holds the pipeline, and it is not in `in_recordings()`. Once `used() > limit()` and 1 s has passed since its last `resolve` (`note_use`), the next `release_unused` can release it while the segment may still be executing. This is the cold path: a pipeline still building at `SetPipelineState` (stand-in, nothing held), built by the submit. World load is also when the code budget is over and a submission can take more than a second. A `shader_code::bound_on(<the segment's allocator>)` after the dispatch in `record_deferred` would tie the references to the segment. The inline `bind::dispatch` / `execute_indirect` and `console_list::close` take the same `resolve_wait` path without a `bound`. Those are usually drained by the next bind on the same list, so the deferred loop is the main window. Not tested: we have not run this head. This is from reading the source only. AI use: Gemini (Antigravity) flagged it in a first-pass review. Claude Code (Claude Opus 5.5) traced the path in the source at `6d19dc04` and wrote this.
github-bot force-pushed github-bot/gh-2526 from 6d19dc04d8 to 0fd22d04dc 2026-11-26 08:47:12 +00:00 Compare
Author
Owner

@⁠veyn-sudo on GitHub · 2026-11-26 08:42 UTC · original

@⁠KDenKC thanks for both.

The review point was right: record_deferred resets each segment with the PC Reset directly, not through cl_reset, so nothing called shader_code::bound for it and the references stayed with the thread. Fixed in 0fd22d04: shader_code::bound(seg) after the dispatch ties them to the segment's allocator. The new test a_deferred_dispatch_keeps_its_pipeline_with_its_segment fails without it ("held by the segment's recording") and passes with it. The head is rebased onto main b49be183; the suite and both smoke runs are in the description.

Your budget runs match what I measured on a 2070 SUPER: in the world the code in use is the working set (~435 MB at the removal, all of it used within the last 2 s), so releasing what is idle cannot keep it under the heap. This PR stays useful for idle code, but on its own it does not prevent the removal at world start.

AI use: Claude Code (Claude Opus 5.5) checked the path, wrote the fix and the test, ran them on my PC and wrote this.

**@⁠veyn-sudo** on GitHub · 2026-11-26 08:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7186921221) @⁠KDenKC thanks for both. The review point was right: `record_deferred` resets each segment with the PC `Reset` directly, not through `cl_reset`, so nothing called `shader_code::bound` for it and the references stayed with the thread. Fixed in `0fd22d04`: `shader_code::bound(seg)` after the dispatch ties them to the segment's allocator. The new test `a_deferred_dispatch_keeps_its_pipeline_with_its_segment` fails without it ("held by the segment's recording") and passes with it. The head is rebased onto `main` `b49be183`; the suite and both smoke runs are in the description. Your budget runs match what I measured on a 2070 SUPER: in the world the code in use is the working set (~435 MB at the removal, all of it used within the last 2 s), so releasing what is idle cannot keep it under the heap. This PR stays useful for idle code, but on its own it does not prevent the removal at world start. AI use: Claude Code (Claude Opus 5.5) checked the path, wrote the fix and the test, ran them on my PC and wrote this.
Author
Owner

@⁠CryingLaughing on GitHub · 2026-11-26 11:05 UTC · original

Focused RTX 4080 readback on exact head 0fd22d04dc7931066a8560fe178119a2040d0da9 with a local test-only overlay on pso_async::used_tests::an_unused_compute_pipeline_is_released_and_built_again.

The first one-group compute dispatch wrote 0x13579bdf to a UAV. After allocator reset released the recording reference, idle reclamation cleared the real PSO. The next dispatch rebuilt it (build count 1 → 2) and wrote 0x89abcdef to the same UAV. Both values were read back after their submission fences. Different values verify that the command recorded after the rebuild ran on the GPU.

Tested

  • RTX 4080 driver 621.01, i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC, DXC 1.8.2502.11. XCL_ADAPTER=4080. Test overlay diff SHA-256 ddf8fee788507a89d8481bbe53638f9bd5d042d9270bfe40a193dcd02e1ebfcb.
  • cargo test -p xcl --lib --locked -j 4 --no-run --message-format=json, then the test executable with hle::d3d12x::pso_async::used_tests::an_unused_compute_pipeline_is_released_and_built_again --exact --test-threads=1 --nocapture. 1 passed, 0 failed, 0 ignored, 0 capability skips.

The synthetic test forces idle reclamation on a small pipeline. Retail workloads, driver shader-code capacity, and the workspace suite with this overlay remain untested.

**@⁠CryingLaughing** on GitHub · 2026-11-26 11:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/2526#issuecomment-7190262709) Focused RTX 4080 readback on exact head `0fd22d04dc7931066a8560fe178119a2040d0da9` with a local test-only overlay on `pso_async::used_tests::an_unused_compute_pipeline_is_released_and_built_again`. The first one-group compute dispatch wrote `0x13579bdf` to a UAV. After allocator reset released the recording reference, idle reclamation cleared the real PSO. The next dispatch rebuilt it (build count **1 → 2**) and wrote `0x89abcdef` to the same UAV. Both values were read back after their submission fences. Different values verify that the command recorded after the rebuild ran on the GPU. **Tested** - RTX 4080 driver 621.01, i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC, DXC 1.8.2502.11. `XCL_ADAPTER=4080`. Test overlay diff SHA-256 `ddf8fee788507a89d8481bbe53638f9bd5d042d9270bfe40a193dcd02e1ebfcb`. - `cargo test -p xcl --lib --locked -j 4 --no-run --message-format=json`, then the test executable with `hle::d3d12x::pso_async::used_tests::an_unused_compute_pipeline_is_released_and_built_again --exact --test-threads=1 --nocapture`. **1 passed, 0 failed, 0 ignored, 0 capability skips**. The synthetic test forces idle reclamation on a small pipeline. Retail workloads, driver shader-code capacity, and the workspace suite with this overlay remain untested.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2526/head:github-bot/gh-2526'
git switch 'github-bot/gh-2526'

Merge

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