D3D12.X: charge the compute-blob budget once per cache entry #820
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/826"
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?
Imported from ivall/xcl. Originally posted by mikebuckets171 on 2026-11-24T06:12:17Z.
What
keep_compute_blobcharges a driver blob's size to theCOMPUTE_BLOBS_MAXtotal and then inserts it.Two calls for the same key can pass the
compute_blob(key).is_some()guard above before either hasstored its result (the guard and the insert are not one step): both charge, only one entry ends up in
the map, and the discarded charge is never taken back —
forget_compute_blobsubtracts only what themap holds. The budget then drifts upward with bytes the map never kept, and later blobs of real
programs are refused while memory is free.
Insert through the entry API and charge a vacant key only.
insert_compute_blobis split out so theaccounting is testable without a GPU; the new test is CPU-only.
Size: +35 / −3, one file (
crates/xcl/src/hle/d3d12x/real.rs), one logical change.Note on ordering: #774 changes the call site around
keep_compute_blob(a refused driver blob going tothe big-compile queue). It does not touch the charge or the insert, so the two are independent, but
whichever lands first I will rebase onto.
Tested
x86_64-pc-windows-gnullvm(LLVM-MinGW 20261117 asthe linker):
mainate50836band this head — both green in 0.1–20 s incremental.to the module this patch is about:
compute_blob_tests→ 2 passed, 0 failed (the newtwo_results_for_one_key_charge_the_budget_once, which asserts that the second result for one keycharges nothing and that the first blob is the one kept, plus the existing key/forget test).
all in the GPU families this host is known for (the
v_*_f64programs and several graphics tests), thesame ones the other macOS reports in #258 name. None of them reach the code this patch changes; the
section that runs on the CPU passes.
xcl-smokepair from this bench (same title, same bottle, same sandbox, same DXC 1.9.2609, eachon a fresh data root), one on a commit of
main, one on this head:Read these as what they are: on this host they show that the head adds no device removals, no crashes and
no commit growth — not frame parity.
maincross-built for the Wine target does not reach a presentedframe at all (it stops ~1.8 s in with 0 presents and no PSO work;
mainhas no Mac host path yet), soboth sides of a
main-based Mac pair are 0 frames. The host where this title does run is @Ahmet-Dedeler'sMac port;
COMPUTE_BLOBSdoes not exist on that port's base, so there is no pair to take there for thispatch. The package is on a private drive, so its name is not put here.
asks for (quoted from their comments below, not run by this bench):
main@beaa245:cargo test --workspace -- --test-threads=4→ 738 passed, 0 failed, 41 ignored (one more passing test thanmainon thesame box).
x86_64-pc-windows-gnu, head onmain@a1672ef: 705 passed,11 failed, 41 ignored, the 11 being that host's known Wine-lane set, "nothing here fails because of
your change".
built again is vacant again and charged once, because
forget_compute_blobremoves and subtracts underone lock). It is corrected in
991b4da, which is why this head was re-pushed and its block re-run.Not tested
Windows
xcl-smokepair @Kalmarv offered in #258 (04:34) —mainand this head, same title and time, onan RTX 5070 Ti — is still to come.
compute work.
AI use
Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T06:50:50Z.
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, applied on
main@beaa245:That is one more passing test than
mainon the same box (737), so the compute-blob budget charged once per cache entry runs green here and nothing else in the workspace changes verdict. No game data, hardware adapter, no Wine.AI-assisted (opencode): applied the patch to a built tree, ran the suite, restored the two files.
Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T07:17:53Z.
Linux / AMD RDNA3 datapoint.
Merged state: head
5aa4c42onto maina1672ef, clean merge.Full suite,
cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 705 passed, 11 failed, 41 ignored. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. Compute-blob budget accounting tests green; no new failures.Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.
Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross
x86_64-pc-windows-gnu,XCL_NETWORK=0, release profile,--test-threads=4. Linux rows: #42 / #718.AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Imported from ivall/xcl. Originally posted by iggyvilla on 2026-11-24T07:34:32Z.
Read of
5aa4c42(not built or run by me): the fix is right.keep_compute_blobruns on thexcl-psoworkers, thecompute_blob(key).is_some()check and the insert are two separate lock acquisitions, and charging only theEntry::Vacantcase keepstotalequal to what the map holds.One sentence in the doc comment of
insert_compute_blobis not true: "a program built again after its blob was forgotten reaches this call a second time: inserting in both cases charges the budget for bytes the map does not hold".forget_compute_blobremoves the entry and subtracts its length fromtotalin the same lock, so a later insert for that key is vacant and is charged once, correctly; only two workers inserting the same key at once ever double-charged. I would drop that clause so the comment names the one case the change fixes.AI use: Claude Code, Claude Sonnet 5.5, read the diff and checked it against
forget_compute_blob; the comment is mine.mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #172Imported from ivall/xcl. Originally posted by mikebuckets171 on 2026-11-24T07:42:27Z.
@iggyvilla you are right and it is fixed:
forget_compute_blobremoves the entry and subtracts its length under the same lock, so a blob built again after being forgotten is vacant and is charged once, correctly. The double charge only ever happens between two workers that both pass thecompute_blob(key).is_some()check. The doc comment now names that one case and says explicitly that the forgotten-then-rebuilt case is correct (991b4da). The head'sxcl-smokeblock was re-run on the new commit; the suite counts from @dcastell1 and @SlopTart are quoted in the description so the gate sees them where the PR is read. Thanks for reading the diff closely.Imported from ivall/xcl. Originally posted by mikebuckets171 on 2026-11-24T11:07:02Z.
Premise re-checked against today's
main, becausereal.rsmoved under this PR after it was filed - the change still describes main accurately.Since this was filed,
real.rsabsorbed at least four merges (5c3ff31,11920b5,e7da8a1,285560f). Re-read at6efdabc:keep_compute_blobis atreal.rs:3640. It still takes the lock, checks only capacity -if bytes.is_empty() || *total + bytes.len() > COMPUTE_BLOBS_MAX { return; }(3654) - then charges*total += bytes.len()(3657) and insertsm.insert(key, std::sync::Arc::new(bytes))(3658), with no check of whetherkeyis already charged.let mut cached = compute_blob(key)atreal.rs:3420and callskeep_compute_blob(key, *ppv, dxil.len())at 3449. Two workers can still both find the key vacant and both charge for it, which is what this PR closes.if let (Some(p), Some(b)) = (disk.as_deref(), compute_blob(key))) to write the blob to the disk cache. That interacts with this change but does not fight it: this patch keeps the first blob stored for a key, so the disk write takes the same blob the map holds. No behavioural fork between the two paths.git merge-treeof6efdabcagainstpr/blob-cache-accountingreports no conflict, so the branch needs no rebase for the Windows pair @Kalmarv offered - head991b4daonto6efdabcis a clean merge.PR checksis green here;CIhas never started on any of my heads (only thePR checksdescription job appears, which is main's ownpull_request_targetworkflow), so a maintainer's workflow approval is still what it needs to leave draft.Host: macOS 27.2.1 (Apple silicon, M5 Pro), CrossOver 26, D3DMetal - the port-side tests behind this PR's
Testedsection were run here. AI use: GPT-6 Luna re-read the code at6efdabc, ran the merge check and drafted this comment; no new runs were needed for it.mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #172upstream-sync referenced this pull request2026-11-24 19:06:45 +00:00
upstream-sync referenced this pull request2026-11-25 02:07:14 +00:00
upstream-sync referenced this pull request2026-11-25 05:07:03 +00:00
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T10:38:42Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:14:19Z.
Triage (#1607) – head
991b4daMain already charges the compute-blob budget once per key: commit
665f72f(D3D12.X: persist slow driver blobs past the RAM cap) replacedkeep_compute_blobwithDriverBlobs, whosefinishandadmitadd tototalonly when!map.contains_key(&key)(real.rs). The double charge this PR fixes is gone. The code it edits is gone too, so it cannot be rebased.Recommendation: close (superseded by main commit
665f72f).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:40:00Z.
Closing as superseded: this change is already on
main(665f72fc). main DriverBlobs::finish/admit charge the budget only if !map.contains_key(&key) (real.rs ~7207); keep_compute_blob/insert_compute_blob no longer exist; oversize blobs refused by limit check (only a zero-length guard differs)Two independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed