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

Closed
ettehn wants to merge 2 commits from upstream-pr/2409 into main
ettehn commented 2026-11-25 18:02:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ettehn on 2026-11-25T18:02:04Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5496520934 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2409). Originally posted by [ettehn](https://github.com/ettehn) on 2026-11-25T18:02:04Z. --- 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.
DavidM1911 commented 2026-11-25 20:08:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T19:28:03Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7172336171 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2409#issuecomment-7172336171). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T19:28:03Z. --- 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!
luckyteagirl commented 2026-11-26 07:59:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T07:59:43Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ivall/xcl:review:6070366266 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2409#pullrequestreview-6070366266). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T07:59:43Z. **Review:** COMMENTED --- 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.
ettehn commented 2026-11-26 09:07:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ettehn on 2026-11-26T08:30:32Z.


@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).

<!-- greyfinch-sync:ivall/xcl:comment:7186678421 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2409#issuecomment-7186678421). Originally posted by [ettehn](https://github.com/ettehn) on 2026-11-26T08:30:32Z. --- @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).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2399
No description provided.