D3D12.X: record first use of synchronously created compute PSOs #2409

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

@⁠ettehn on GitHub · 2026-11-25 18:02 UTC · original
ettehn:codex/pso-manifest-sync-first-use → main · +360 −11 · 6 files · 2 commits · open

Stacked on #2096. This PR's own commit is 1ee46bd, on top of b6a294d (the #2096 patch rebased onto main b49be183).

A synchronously created compute pipeline could miss its first-use record, leaving milestone precompilation with an incomplete prefix. The follow-up records first use for eager and ready compute pipelines while preserving the existing used-pipeline history.

What is in it

  • Record one use event per pipeline across repeated binds, including the current non-waiting SetPipelineState path.
  • Tie ready-pipeline cleanup to the registration observed before COM release, so an older release cannot erase a newer pipeline at the same address.
  • Cover output readback and first-use order with a GPU regression, and address reuse with a deterministic interleaving test.

Tested

  • Windows 11 25H2 (26200.9974), Ryzen 9 8945HX, RTX 5070 Ti Laptop, NVIDIA 621.24, Rust 1.97.1 MSVC, SDK DXC 1.8.2502.11.
  • cargo build --workspace --offline --locked -j 2 passed. cargo test --workspace --offline --locked -j 2 --no-fail-fast -- --test-threads=1 --nocapture: 1,436 passed, 4 failed, 47 ignored, with 25 explicit GPU skips in the pass count. The four DXIL fuzz seeds (70, 545, 1019, 1507) failed with CreateComputePipelineState returning 0x8007000E on both this branch and clean main b49be183.
  • The address-reuse test failed with address-only cleanup and passed with the registration check. All four manifest unit tests passed.
  • Release gpu_compute_e2e: seven ran and passed; one reported a heap-window skip. Separate release runs recorded one first-use event for cold eager, warm eager, and lazy creation. Tracing off produced no manifest.

Regression run
Windows release, same retail title and 20-second startup run, no scripted input. XCL networking was disabled. Each run used a fresh XCL data/cache directory.

Main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5070 Ti Laptop GPU
title: RetailTitle
seconds: 20
exit: 0x0
frames shown: 101 (PresentX 101)
presents per 2 s (last 3): 0 0 1
device removals: 0
crashes: 0
peak commit: 10971 MB

PR:

xcl-smoke v1
commit: 1ee46bda18efbc167f0dbaecc78a067766df2963
gpu: NVIDIA GeForce RTX 5070 Ti Laptop GPU
title: RetailTitle
seconds: 20
exit: 0x0
frames shown: 93 (PresentX 93)
presents per 2 s (last 3): 0 0 1
device removals: 0
crashes: 0
peak commit: 10881 MB

Not tested

  • In-world rendering and retail manifest recording (the smoke pair covers startup with tracing off), AMD, native wave64, and Linux/Wine.

AI use

  • OpenAI Codex (GPT-6.2 Sol) assisted with implementation, tests, and Windows verification.
**@⁠ettehn** on GitHub · 2026-11-25 18:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/2409) `ettehn:codex/pso-manifest-sync-first-use` → `main` · +360 −11 · 6 files · 2 commits · open Stacked on #2096. This PR's own commit is `1ee46bd`, on top of `b6a294d` (the #2096 patch rebased onto `main` `b49be183`). A synchronously created compute pipeline could miss its first-use record, leaving milestone precompilation with an incomplete prefix. The follow-up records first use for eager and ready compute pipelines while preserving the existing used-pipeline history. **What is in it** - Record one `use` event per pipeline across repeated binds, including the current non-waiting `SetPipelineState` path. - Tie ready-pipeline cleanup to the registration observed before COM release, so an older release cannot erase a newer pipeline at the same address. - Cover output readback and first-use order with a GPU regression, and address reuse with a deterministic interleaving test. **Tested** - Windows 11 25H2 (26200.9974), Ryzen 9 8945HX, RTX 5070 Ti Laptop, NVIDIA 621.24, Rust 1.97.1 MSVC, SDK DXC 1.8.2502.11. - `cargo build --workspace --offline --locked -j 2` passed. `cargo test --workspace --offline --locked -j 2 --no-fail-fast -- --test-threads=1 --nocapture`: 1,436 passed, 4 failed, 47 ignored, with 25 explicit GPU skips in the pass count. The four DXIL fuzz seeds (70, 545, 1019, 1507) failed with `CreateComputePipelineState` returning `0x8007000E` on both this branch and clean `main` `b49be183`. - The address-reuse test failed with address-only cleanup and passed with the registration check. All four manifest unit tests passed. - Release `gpu_compute_e2e`: seven ran and passed; one reported a heap-window skip. Separate release runs recorded one first-use event for cold eager, warm eager, and lazy creation. Tracing off produced no manifest. **Regression run** Windows release, same retail title and 20-second startup run, no scripted input. XCL networking was disabled. Each run used a fresh XCL data/cache directory. Main: ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 5070 Ti Laptop GPU title: RetailTitle seconds: 20 exit: 0x0 frames shown: 101 (PresentX 101) presents per 2 s (last 3): 0 0 1 device removals: 0 crashes: 0 peak commit: 10971 MB ``` PR: ``` xcl-smoke v1 commit: 1ee46bda18efbc167f0dbaecc78a067766df2963 gpu: NVIDIA GeForce RTX 5070 Ti Laptop GPU title: RetailTitle seconds: 20 exit: 0x0 frames shown: 93 (PresentX 93) presents per 2 s (last 3): 0 0 1 device removals: 0 crashes: 0 peak commit: 10881 MB ``` **Not tested** - In-world rendering and retail manifest recording (the smoke pair covers startup with tracing off), AMD, native wave64, and Linux/Wine. **AI use** - OpenAI Codex (GPT-6.2 Sol) assisted with implementation, tests, and Windows verification.
Part of #2088, workstream 1 (the recording only): which pipelines a title
needs before each point of its start, in the order it needs them, and which
it had to wait for.

With XCL_PSO_MANIFEST=1, pso-manifest.txt beside used-pipelines.txt (a new
file each run) gets one tab-separated event a line, numbered in file order
with the milliseconds since the first:
- use: a pipeline's first use (pso_async's note_use), its shader-set key,
  compute or graphics, and whether it was built by then (ready / cold);
- build: each driver compile (driver_compile_identified): kind, DXIL bytes,
  the console record's hash and whether a driver blob was supplied, time in
  the driver and time waiting for a compile slot;
- present: the title's presents at milestones (1, 2, 4 ... 1024, then every
  1024th), so a manifest shows where presents stop and whether they return.

A first use's line is written, under the manifest's lock, before the
pipeline is marked used: a second bind of it (and a present after that) comes
after the line in the file (found in review by ettehn).

Recording only, off by default: nothing is built, ordered or skipped
differently.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Track eager ready handles and first binds that skip a pending entry, so an ordered manifest can select the complete prefix through a Present event.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:30:08 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 19:28 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 19:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/2409#issuecomment-7172336171) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun. Thanks!
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 07:59 UTC · original · reviewed

At head cd9fb4d6bf752c655a196b4e573d21ae5c908537, READY_COMPUTE is keyed only by the raw PSO address. The final pso_release calls the original COM Release first (real.rs:1644-1648) and only then calls forget_pso, which removes the new ready entry (real.rs:1753-1754). If thread A's Release of PSO A returns zero and pauses, thread B can create a synchronous compute PSO B at the freed address and register its key (real.rs:5068-5073); A's late cleanup then erases B's key. B's first bind will be absent from the XCL_PSO_MANIFEST=1 output. Could cleanup be tied to the PSO generation/registration being released, or synchronized across final release and new registration so an older release cannot remove the newer entry? A small address-reuse interleaving test would cover the new map.

This is a source-derived, opt-in manifest race, not a native reproduction. The broader address-keyed cleanup pattern predates this PR; the missing ready-compute first-use event is new here. AI use: OpenAI Codex (GPT-6.2 Sol) found the interleaving; I checked the exact-head release, creation, and manifest paths before posting.

**@⁠luckyteagirl** on GitHub · 2026-11-26 07:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/2409#pullrequestreview-6070366266) · **reviewed** At head `cd9fb4d6bf752c655a196b4e573d21ae5c908537`, `READY_COMPUTE` is keyed only by the raw PSO address. The final `pso_release` calls the original COM `Release` first (`real.rs:1644-1648`) and only then calls `forget_pso`, which removes the new ready entry (`real.rs:1753-1754`). If thread A's `Release` of PSO A returns zero and pauses, thread B can create a synchronous compute PSO B at the freed address and register its key (`real.rs:5068-5073`); A's late cleanup then erases B's key. B's first bind will be absent from the `XCL_PSO_MANIFEST=1` output. Could cleanup be tied to the PSO generation/registration being released, or synchronized across final release and new registration so an older release cannot remove the newer entry? A small address-reuse interleaving test would cover the new map. This is a source-derived, opt-in manifest race, not a native reproduction. The broader address-keyed cleanup pattern predates this PR; the missing ready-compute first-use event is new here. AI use: OpenAI Codex (GPT-6.2 Sol) found the interleaving; I checked the exact-head release, creation, and manifest paths before posting.
github-bot force-pushed github-bot/gh-2409 from cd9fb4d6bf to 1ee46bda18 2026-11-26 08:29:33 +00:00 Compare
Author
Owner

@⁠ettehn on GitHub · 2026-11-26 08:30 UTC · original · edited 2026-11-26 10:23 UTC

@⁠Anon64 Thanks for offering to retest on your RTX 3060 in #2096. The updated head is 1ee46bda18efbc167f0dbaecc78a067766df2963. If you still have time to run it, a first-use check with XCL_LAZY_PSO=0 would help. The paired retail xcl-smoke runs are now in the PR description, and both required GitHub checks are green.

Thanks to luckyteagirl for spotting the address-reuse race. This head records the registration before COM release and removes it only if the same registration is still present. The deterministic regression fails with address-only cleanup and passes on this head. Windows CI also passed.

Assisted by OpenAI Codex (GPT-6.2 Sol).

**@⁠ettehn** on GitHub · 2026-11-26 08:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/2409#issuecomment-7186678421) · edited 2026-11-26 10:23 UTC @⁠Anon64 Thanks for offering to retest on your RTX 3060 in #2096. The updated head is `1ee46bda18efbc167f0dbaecc78a067766df2963`. If you still have time to run it, a first-use check with `XCL_LAZY_PSO=0` would help. The paired retail `xcl-smoke` runs are now in the PR description, and both required GitHub checks are green. Thanks to luckyteagirl for spotting the address-reuse race. This head records the registration before COM release and removes it only if the same registration is still present. The deterministic regression fails with address-only cleanup and passes on this head. Windows CI also passed. Assisted by OpenAI Codex (GPT-6.2 Sol).
This pull request can be merged automatically.
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/2409/head:github-bot/gh-2409'
git switch 'github-bot/gh-2409'

Merge

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