Shaders: a copied dxcompiler.dll misses the whole DXIL cache (the toolchain key uses its modification time) #2814

Open
opened 2026-11-26 15:03:16 +00:00 by hexgeon1 · 1 comment
hexgeon1 commented 2026-11-26 15:03:16 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by hexgeon1 on 2026-11-26T15:03:16Z.


dxc::toolchain_identity() hashes the size and modification time of dxcompiler.dll and dxil.dll (since #9). A copy of the same DLLs with a new modification time gets a different key. Every DXIL and translation cache entry written with the other copy is then missed, without any message. Copies made by Explorer, Copy-Item, robocopy or unzipping keep the time. Git Bash cp without -p does not, and neither do many scripts.

What it cost here: two worktrees of nvidia-dev af2cecc4 shared one XCL_DXIL_CACHE. The DLLs were byte-identical, but one copy was made with cp. In the other tree, the retail title's shader preparation ran as if nothing were cached: 3,758 records translated in its first 5 s. After matching the times with touch -r and changing nothing else, it translated 19,147 in the first 5 s and finished the compute pipelines in 35 s. The translator sources of the two trees were identical (diff -r of src/gpu).

Proposal: keep the key as cheap as now, but take it from the file instead of its file-system time. Read the first 4 KB of each DLL and hash the PE header's TimeDateStamp, SizeOfImage and CheckSum, plus the file size. These fields are set at link time, so they change with every DXC build and stay the same when the file is copied. Three copies of dxcompiler.dll 1.9.2602.17 here have modification times 10:10:35 and 14:30:15. All three have the same TimeDateStamp 0x6998e047, SizeOfImage 0xd9e000 and CheckSum 0xd9d0d9. There is no full-file hash, so the reason for #9's change still holds.

@ivall, you chose size + mtime in #9. If this fits, I'll send it as a small PR to dxc.rs with a test: a copy with a new modification time keeps the key, and a different header changes it. The cache key changes once with it, as it did in #9.

Workaround until then: copy the DLLs with their times (cp -p, Copy-Item), or touch -r <reference> dxcompiler.dll dxil.dll.

Tested: RTX 3090 24 GB (driver 617.14), Ryzen 7 5700X, Windows 10 22H2 (19045), release builds of nvidia-dev af2cecc4. The DLL header fields were read with a short script. main b49be183 has the same toolchain_identity, and I didn't run main for this.

AI use: Claude Code (Claude Opus 5.5) found the cause, ran the comparisons and wrote this. I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:issue:6629452188 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2824). Originally posted by [hexgeon1](https://github.com/hexgeon1) on 2026-11-26T15:03:16Z. --- `dxc::toolchain_identity()` hashes the size and **modification time** of `dxcompiler.dll` and `dxil.dll` (since #9). A copy of the same DLLs with a new modification time gets a different key. Every DXIL and translation cache entry written with the other copy is then missed, without any message. Copies made by Explorer, `Copy-Item`, robocopy or unzipping keep the time. Git Bash `cp` without `-p` does not, and neither do many scripts. **What it cost here:** two worktrees of `nvidia-dev` `af2cecc4` shared one `XCL_DXIL_CACHE`. The DLLs were byte-identical, but one copy was made with `cp`. In the other tree, the retail title's shader preparation ran as if nothing were cached: 3,758 records translated in its first 5 s. After matching the times with `touch -r` and changing nothing else, it translated 19,147 in the first 5 s and finished the compute pipelines in 35 s. The translator sources of the two trees were identical (`diff -r` of `src/gpu`). **Proposal:** keep the key as cheap as now, but take it from the file instead of its file-system time. Read the first 4 KB of each DLL and hash the PE header's `TimeDateStamp`, `SizeOfImage` and `CheckSum`, plus the file size. These fields are set at link time, so they change with every DXC build and stay the same when the file is copied. Three copies of `dxcompiler.dll` 1.9.2602.17 here have modification times 10:10:35 and 14:30:15. All three have the same `TimeDateStamp` `0x6998e047`, `SizeOfImage` `0xd9e000` and `CheckSum` `0xd9d0d9`. There is no full-file hash, so the reason for #9's change still holds. @ivall, you chose size + mtime in #9. If this fits, I'll send it as a small PR to `dxc.rs` with a test: a copy with a new modification time keeps the key, and a different header changes it. The cache key changes once with it, as it did in #9. **Workaround until then:** copy the DLLs with their times (`cp -p`, `Copy-Item`), or `touch -r <reference> dxcompiler.dll dxil.dll`. **Tested:** RTX 3090 24 GB (driver 617.14), Ryzen 7 5700X, Windows 10 22H2 (19045), release builds of `nvidia-dev` `af2cecc4`. The DLL header fields were read with a short script. `main` `b49be183` has the same `toolchain_identity`, and I didn't run main for this. **AI use:** Claude Code (Claude Opus 5.5) found the cause, ran the comparisons and wrote this. I checked it before posting.
CryingLaughing commented 2026-11-26 16:41:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by CryingLaughing on 2026-11-26T16:41:39Z.


Independent reproduction on exact main 8b957bec6f82495aec940944c6bf47faa02db590, RTX 4080 driver 621.01, Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and SDK DXC/DXIL 1.8.2502.11, debug. Five fresh xcl run processes used the same synthetic vertex shader, one private shared cache, and the same SDK copy and path. All five reached the native graphics PSO and exited 0, with zero preparation errors or skips.

  • Empty cache missed in both paths. The unchanged timestamp hit both.
  • Advancing only dxcompiler.dll's last-write time by one hour missed both. Repeating at the advanced time hit both. Restoring the original timestamp hit both original entries.
  • The HLSL cache names changed from c958ca51cd3512a7 to cf47ee3c5e61442a while the 3,268-byte shader stayed identical. The translated namespaces changed from 9c8b36e2c3b1b82f to ccffb6c13136d971. The 2,584-byte records differed only in the eight-byte cache identity, with identical 2,544-byte DXIL payloads.

The compiler and signing DLL SHA-256 and PE fields stayed constant. This confirms the cache split on current main with one synthetic input and provides no retail timing or proposed-fix measurement.

<!-- greyfinch-sync:ivall/xcl:comment:7197976054 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2824#issuecomment-7197976054). Originally posted by [CryingLaughing](https://github.com/CryingLaughing) on 2026-11-26T16:41:39Z. --- Independent reproduction on exact main `8b957bec6f82495aec940944c6bf47faa02db590`, RTX 4080 driver 621.01, Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 x64 MSVC and SDK DXC/DXIL 1.8.2502.11, debug. Five fresh `xcl run` processes used the same synthetic vertex shader, one private shared cache, and the same SDK copy and path. All five reached the native graphics PSO and exited 0, with zero preparation errors or skips. - Empty cache missed in both paths. The unchanged timestamp hit both. - Advancing only `dxcompiler.dll`'s last-write time by one hour missed both. Repeating at the advanced time hit both. Restoring the original timestamp hit both original entries. - The HLSL cache names changed from `c958ca51cd3512a7` to `cf47ee3c5e61442a` while the 3,268-byte shader stayed identical. The translated namespaces changed from `9c8b36e2c3b1b82f` to `ccffb6c13136d971`. The 2,584-byte records differed only in the eight-byte cache identity, with identical 2,544-byte DXIL payloads. The compiler and signing DLL SHA-256 and PE fields stayed constant. This confirms the cache split on current main with one synthetic input and provides no retail timing or proposed-fix measurement.
Sign in to join this conversation.
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#2814
No description provided.