Skip to content

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

Open
ettehn wants to merge 2 commits into
xcl-dev:mainfrom
ettehn:codex/pso-manifest-sync-first-use
Open

ettehn wants to merge 2 commits into
xcl-dev:mainfrom
ettehn:codex/pso-manifest-sync-first-use

Conversation

@ettehn

@ettehn ettehn commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

Thanks!

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Anon64 and others added 2 commits November 26, 2026 16:08
…ines (xcl-dev#2088)

Part of xcl-dev#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 <noreply@anthropic.com>
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.
@ettehn
ettehn force-pushed the codex/pso-manifest-sync-first-use branch from cd9fb4d to 1ee46bd Compare November 26, 2026 08:23
@ettehn

ettehn commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants