Repository navigation
Conversation
The translator annotates every instruction with a comment, and each console program starts with two v_nop whose 32-bit literal differs between programs with the same code. The DXC cache key hashed the full text, so those annotations alone gave identical code a new key and a new compile. On a retail game's 25,797 DXC sources (the DXIL cache of a full preparation), 9,876 compiles produced a byte-identical copy of another entry; every such pair differed only in comment lines. A key over the source without whole-line `//` comments gives 15,955 keys for 15,921 distinct DXIL (the rest are the linked and whole forms, which share the cache by design). Timing 150 + 150 sampled sources with dxc.exe puts the copies at ~17 % of a cold DXC pass. A translator change that only edits annotations no longer invalidates every DXC entry either. Comment lines that line splicing would turn into code (ending in `\`, or after a line that does) stay in the key, as does the optimisation level the source length selects (-O3 / -O1 / -O0). Entries written under the old key are adopted on a miss (hard-linked to the new name), so existing caches stay warm and the startup pack proof finds them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The DXC cache key hashed the full HLSL text, including the translator's per-instruction comments. Each console program starts with two
v_nopwhose 32-bit literal differs between programs with the same code, and the translator writes them as// 0000: v_nop ; lit 0x…. Those comment lines alone gave identical code a new key, so DXC compiled it again. The key now leaves out whole-line//comments; the source DXC compiles is unchanged. Part of #2088.Measured on a retail game's DXIL cache from a full preparation (25,797 DXC sources, dumped with a throwaway hook under their cache keys):
XCL_LINK_MEM,dxc.rs).dxc.exeon 150 random kept + 150 random redundant sources (one thread): 2.14 s vs 0.71 s mean, so the copies are about 17 % of a cold DXC pass. The driver blob store already dedups identical DXIL, so this saves DXC time only.What is in it
crates/xcl/src/gpu/recomp/dxc.rs:cache_key_for_toolchainhashes the source without whole-line//comments, plus the optimisation level the source length selects (-O3 / -O1 / -O0), so sources whose comments push them over a length threshold do not share an entry. A comment line ending in\, or following a line that does, stays in the key (line splicing makes it code). The key has a new domain tag.warm_pack), which checks<key>.dxil, finds them.Tested
cargo test -p xcl --lib gpu::recomp::dxc::: 37 passed, 0 failed, 0 ignoredcargo test --workspace --no-fail-fast -- --test-threads=4: 2621 passed, 0 failed, 49 ignoredRegression run
Retail game, 60 s,
XCL_PREPARE=0andXCL_PRESS_AT=25:Aon both sides, same DXIL cache.main (
d8bd9a38):this PR (
39d97735):DXIL cache in
report.json: main 107,906 hits / 7 misses, this PR 106,238 hits / 12 misses from the same cache (entries under the old key are adopted, nothing went cold).Not tested
dxc.exe, not from an XCL run.XCL_PREPARE=0).AI use
🤖 Generated with Claude Code