XCL_DXC_ARGS never reaches the cached compile path; the DXIL cache key also omits the optimisation level #559
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#559
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@sub-north on GitHub · 2026-11-24 01:47 UTC · original
XCL_DXC_ARGS never reaches the cached compile path; the DXIL cache key also omits the optimisation level
Line numbers are
85bdf21(origin/main), paths undercrates/xcl/src/gpu/recomp/.What an operator expects
XCL_DXC_ARGSis the documented way to pass arguments to DXC — "XCL_DXC_ARGS="-O1 …": extra DXCarguments (comparing optimisation levels)" (
tests.rs:4882-4884), "XCL_DXC_ARGSpasses DXCarguments in the survey" (
HANDOFF.md:922).compile()takes exactly that list asextra: &[&str](dxc.rs:460-461), and the disk cache exists to hand back DXIL for programs DXC alreadycompiled. So the expectation is two-fold:
hit.
Neither holds.
What actually happens
The variable is never consulted on the cached path
compile_cached_in— the entry point everything uses (dxc.rs:887-889) — hardcodes an emptyargument list:
XCL_DXC_ARGSis read in exactly three places, all intests.rs, all ignored helpers, and all ofthem call the uncached
dxc::compile:So in a normal run the variable has no effect at all: nothing reads it, and even if something
did, the cached path drops the list on the floor. It only ever reaches DXC through the two survey
helpers, which bypass the cache entirely — which is also why nobody noticed: the survey reports DXC
times and DXIL sizes that look like the flag worked.
The key omits the argument list
Package version, toolchain identity, profile, entry, source. Not the arguments.
The optimisation level is decided somewhere else entirely, after the key is computed, from the
source size only:
Two separate problems from one omission:
extra— lands on the same key as one that supplies none, so the second caller gets the firstcaller's DXIL. This is dormant today only because no caller passes arguments (
pso.rs:771,pso.rs:865pass none, andcompile_cached_inhardcodes&[]); it is armed, not harmless.-O0/-O1is not keyed either. Onlysrc.len()is keyed, not the ruleapplied to it. Change a threshold, or the flags injected above it, and a build that keeps
CARGO_PKG_VERSION(dxc.rs:541— it only moves on a version bump) keeps hitting artifactscompiled under the old rule. This is the specific hazard for development builds: same version
string, different optimiser decisions, one cache.
What is not wrong
Worth stating so the report is not overclaimed: lookup, the in-process flight, the cross-process
mutex, and the atomic write-then-rename all derive from that one key, so there is no
lookup/store mismatch:
And because today's size rule is a pure function of
src.len(), andsrcis keyed, anargument-less cache cannot collide with itself yet. The defect is an omission in the key, not a
mis-computed one.
Reproduction
No GPU or display needed; the compile helper and its disk cache are exercised on their own
(
cache_tests,dxc.rs:891).1. The variable is inert on the cached path. With
XCL_DXC_ARGS="-O1"set, rundxil_cache_round_trip(dxc.rs:991-1003) twice, or callcompile_cached_intwice on the samesource:
Unset the variable, repeat into a fresh
dir: byte-identical DXIL. DXC is not invoked on the secondrun and
compilationcounters do not move, so the flag had no path to the compiler.2. The key is blind to arguments. Change nothing but the hardcoded
&[]atdxc.rs:632to passa list through, and compile the same source twice into the same
dir, second time with differentflags (
["-O0"], then["-O1"]): the second is a hit, returns the first-O0DXIL, and thedirectory holds a single
.dxil. That is exactly what any caller threadingextrathrough will get.Proposed fix
Thread the list into the cached path and hash it.
Each part is already followed by a NUL (
part.bytes().chain([0u8])), so the appended argumentsinherit the separator for free:
["-O1","-O2"]hashes as-O1\0-O2\0and["-O1 -O2"]as-O1 -O2\0— a different digest. Two arguments never alias one argument containing a space.Plumb it through without churning the existing call sites:
Test, next to
cache_key_tracks_the_dxc_toolchain(dxc.rs:1005-1011):Optional, if you would rather key the rule than only the caller's list: hash the resolved argument
vector (
-E/-T/-HVplus the size-derived-O0/-O1) instead ofextra. That closes thethreshold-change hole above, at the cost of invalidating existing entries for sources over the
thresholds once.
Migration
The arguments are appended after
src, so an empty list leaves the digest unchanged: existingentries keep hitting, only argument-carrying compiles get new keys. No forced invalidation, no loss
of a warm cache.
Environment
Windows;
dxcompiler.dllanddxil.dlllocated throughXCL_DXC_DIRand hashed by name, size andmtime into
toolchain_identity(dxc.rs:507-536); cache folder fromXCL_DXIL_CACHE, else%LOCALAPPDATA%\xcl\dxil(dxc.rs:554-559).github-bot referenced this issue2026-11-26 04:26:34 +00:00
github-bot referenced this issue2026-11-26 04:59:09 +00:00
@alpz1000 on GitHub · 2026-11-24 02:49 UTC · original
Independent check of both cache layers for #559 on Windows 11 Home 26200.9974, Core i5-8400, Rust 1.100.0 x86_64-pc-windows-msvc, SDK DXC 1.9.2602.17, debug.
6c68cc703df3e2d75d5820ee594a4a155ce3ee9e: its three focused compiler-cache tests passed with one test thread (argument key separation, cached explicit arguments, andXCL_DXC_ARGSon the cached path).920c3807df84c7b9cd9ab7be1ea0122c2199f02d:cargo test --locked -p xcl --lib cached_compiler_arguments_reach_dxc_with_warm_caches -- --nocapturepassed.pso.rsfrom its parente10c3e4(the rebased #591 change): the test failed withinvalid arguments reused a cached translation, exit 101. The edit was reverted afterward.This independently reproduces the upper-cache problem and validates the follow-up alongside the lower-level argument-keyed cache. Not tested: the whole suite, parallel behavior of #591's environment fixture, or retail titles. No game data used.
AI use: OpenAI Codex (GPT-6) ran the tests and drafted the report from their output.