D3D12.X: preserve a replacement PSO blob when an older read is rejected #2601

Open
opened 2026-11-26 05:34:41 +00:00 by github-bot · 1 comment
Owner

@⁠KOLESNiii on GitHub · 2026-11-26 01:18 UTC · original

Part of #2508 (Pipeline Rebuild). Reviewed on main at b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7.

The runtime reads a driver blob, calls native PSO creation, and on refusal removes the cache filename. The removal is tied to the path. Another caller can replace that path after the read and before the refusal, so the delayed refusal can delete the replacement. This can leave later creates without the blob that was just published. Compute caller · Disk read, delete and publish helpers

An extracted-helper Linux probe reproduced read A → publish B at the same path → reject A → B gone. The probe simulates the driver refusal. Add a deterministic regression test that preserves B after rejection of A and still invalidates A if the file has not changed. Account for concurrent processes because offline warming and the runtime can share the cache directory. Check both the runtime invalidation helper and the offline over-cap removal. Offline removal · Original umbrella comment

#2426 covers which HRESULTs count as refusal. This issue concerns what happens after a refusal has been established. Windows reproduction, race frequency and timing remain unmeasured.

AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for static review the Linux probe, and drafting.

**@⁠KOLESNiii** on GitHub · 2026-11-26 01:18 UTC · [original](https://github.com/xcl-dev/xcl/issues/2601) Part of #2508 (Pipeline Rebuild). Reviewed on `main` at `b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7`. The runtime reads a driver blob, calls native PSO creation, and on refusal removes the cache filename. The removal is tied to the path. Another caller can replace that path after the read and before the refusal, so the delayed refusal can delete the replacement. This can leave later creates without the blob that was just published. [Compute caller](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/hle/d3d12x/real.rs#L4424-L4454) · [Disk read, delete and publish helpers](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/hle/d3d12x/real.rs#L4533-L4588) An extracted-helper Linux probe reproduced `read A → publish B at the same path → reject A → B gone`. The probe simulates the driver refusal. Add a deterministic regression test that preserves B after rejection of A and still invalidates A if the file has not changed. Account for concurrent processes because offline warming and the runtime can share the cache directory. Check both the runtime invalidation helper and the offline over-cap removal. [Offline removal](https://github.com/xcl-dev/xcl/blob/b49be18/crates/xcl/src/shaders.rs#L1544-L1555) · [Original umbrella comment](https://git.gtahub.st/github/xcl-dev--xcl/issues/2508) #2426 covers which HRESULTs count as refusal. This issue concerns what happens after a refusal has been established. Windows reproduction, race frequency and timing remain unmeasured. AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for static review the Linux probe, and drafting.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:34:41 +00:00
Author
Owner

@⁠mokkamokacaffe on GitHub · 2026-11-26 02:26 UTC · original

I independently prepared a fix for #2601 before noticing this PR had opened concurrently, so I will not open a competing PR.

One generation-identity edge remains in invalidate_if_unchanged: byte equality does not prove that the pathname still names the generation that was read. If replacement B is byte-for-byte identical to A, rejection of A still deletes B. The protection also depends on every writer using the new .lock protocol, which mixed XCL versions do not guarantee.

An alternative is to retain the exact file handle used to read A through PSO creation, opened with delete access and FILE_SHARE_DELETE, then invalidate that file object with FileDispositionInfoEx and POSIX delete semantics. This remains correct for identical replacements and non-cooperating writers and does not add persistent lock files.

I have an unsubmitted reference implementation and an identical-byte cross-process regression here: github.com/mokkamokacaffe/xcl@06d08685e6

That branch has only passed Windows-target compilation from Linux, whereas this PR has real Windows/AMD execution, so I am offering it as a design/test contribution rather than claiming it is better validated.

AI-assisted review: OpenAI Codex (GPT-6.2 Astra, Ultra reasoning).

**@⁠mokkamokacaffe** on GitHub · 2026-11-26 02:26 UTC · [original](https://github.com/xcl-dev/xcl/issues/2601#issuecomment-7180807299) I independently prepared a fix for #2601 before noticing this PR had opened concurrently, so I will not open a competing PR. One generation-identity edge remains in `invalidate_if_unchanged`: byte equality does not prove that the pathname still names the generation that was read. If replacement B is byte-for-byte identical to A, rejection of A still deletes B. The protection also depends on every writer using the new `.lock` protocol, which mixed XCL versions do not guarantee. An alternative is to retain the exact file handle used to read A through PSO creation, opened with delete access and `FILE_SHARE_DELETE`, then invalidate that file object with `FileDispositionInfoEx` and POSIX delete semantics. This remains correct for identical replacements and non-cooperating writers and does not add persistent lock files. I have an unsubmitted reference implementation and an identical-byte cross-process regression here: https://github.com/mokkamokacaffe/xcl/commit/06d08685e60b37a38728c6caf9b1f103995bf468 That branch has only passed Windows-target compilation from Linux, whereas this PR has real Windows/AMD execution, so I am offering it as a design/test contribution rather than claiming it is better validated. AI-assisted review: OpenAI Codex (GPT-6.2 Astra, Ultra reasoning).
This discussion has been locked. Commenting is limited to contributors.
No description provided.