Repository navigation
Conversation
|
The new permanent RAM-share cap exposes a graphics first-use gap on I reproduced the scheduling failure on native Windows with the actual A small candidate fix calls Tested — Windows 10 19045, Ryzen 7 7800X3D, Rust 1.98.1 MSVC, debug:
Not tested: full workspace suite, retail smoke, actual driver memory use, or visual output. This is a candidate for your PR, not a merge-readiness claim. Our #572 DXC worker-count change is a different layer and does not solve this demand-propagation gap. Candidate fix and deterministic regression (39 added lines)diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs
index 3bc4ad2..4667622 100644
--- a/crates/xcl/src/hle/d3d12x/pso_async.rs
+++ b/crates/xcl/src/hle/d3d12x/pso_async.rs
@@ -517,6 +517,9 @@ fn entry(pso: usize) -> Option<Arc<Pending>> {
pub fn resolve(pso: usize) -> usize {
let Some(p) = entry(pso) else { return pso };
p.note_use();
+ // Used graphics pipelines must escape background-only admission limits too,
+ // while the bind still returns immediately with the stand-in.
+ p.want();
match p.real.load(Ordering::Acquire) {
0 => {
// a lazy one is wanted now: to the workers
diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs
index 43f40be..ba1d815 100644
--- a/crates/xcl/src/hle/d3d12x/real.rs
+++ b/crates/xcl/src/hle/d3d12x/real.rs
@@ -3725,6 +3725,42 @@ mod big_compile_tests {
use std::sync::atomic::AtomicBool;
use std::time::{Duration, Instant};
+ /// A pipeline over the RAM share is held indefinitely until first use. Graphics
+ /// binds must release that gate while still returning the stand-in immediately.
+ #[test]
+ fn a_graphics_bind_releases_the_background_ram_share_gate() {
+ use super::super::pso_async;
+ use std::sync::{Arc, mpsc};
+ static S: Slots = Slots { n: Mutex::new(0), cv: std::sync::Condvar::new(), most: 1 };
+ let cleanup = Arc::new(AtomicBool::new(false));
+ let release = cleanup.clone();
+ let (started_tx, started) = mpsc::channel();
+ let (finished_tx, finished) = mpsc::channel();
+ let standin = 0x7E57_B024usize;
+ pso_async::submit(standin, false, Box::new(move || {
+ started_tx.send(()).unwrap();
+ let _slot = big_compile_turn(&S, || {
+ release.load(Ordering::Acquire)
+ || big_compile_may_start(big_compile_commit_needed(13_823_000), 36 << 30, 32 << 30, 4)
+ }, pso_async::build_is_wanted);
+ finished_tx.send(()).unwrap();
+ 0x5424
+ }));
+ started.recv_timeout(Duration::from_secs(10)).unwrap();
+ let held_before_bind = finished.recv_timeout(Duration::from_millis(100)).is_err();
+ let bound = pso_async::resolve_for_bind(standin);
+ let released_by_bind = finished.recv_timeout(Duration::from_secs(1)).is_ok();
+ // Always release the worker before assertions, including on the unfixed tree.
+ cleanup.store(true, Ordering::Release);
+ if !released_by_bind { finished.recv_timeout(Duration::from_secs(10)).unwrap(); }
+ let real = pso_async::resolve_wait(standin);
+ let _ = pso_async::released(standin);
+ assert!(held_before_bind, "oversize background compile escaped before first use");
+ assert_eq!(bound, standin, "graphics bind must return the stand-in without waiting");
+ assert_eq!(real, 0x5424);
+ assert!(released_by_bind, "graphics bind left its compile held by the RAM-share gate");
+ }
+
#[test]
fn the_commit_a_background_compile_needs_grows_with_its_dxil() {
const GB: u64 = 1 << 30;AI use: Codex with GPT-6 Astra inspected the path, wrote the candidate and test, ran the Windows comparison, and drafted this report. |
6d7290d to
224888a
Compare
|
Thanks, that is a real gap: with the fixed 3 GB rule a held graphics program got its turn once the commit was there, with the share it never did. I took your one-line fix and the test as they are, in 224888a (you are a co-author of the commit); the test fails on the tree without the line ("graphics bind left its compile held by the RAM-share gate") and passes with it, as you reported. Suite and smoke are rerun on the new head in the description. |
|
A note from Linux on Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging, Ryzen 9 9950X3D, 62.5 GB RAM, 56.0 GB of swap. A ten-line program that prints Tested
On Windows that field is the commit left, page file included, so the pull request reads the right number there. Under Wine it follows memory in use, and Linux does not refuse a commit at that number, so it never falls below the free swap, however little memory is left. At 12:52 today Read
Not tested: a title run with or without the change; a Linux machine with less than 39 GB of RAM; what running out of memory looks like under Wine with this gate; the giant lane with the preload of #690 on; Windows. AI use: Claude Code (Claude Fable 5.2) read the diff, wrote and ran the small program and wrote this note. Posted without review by a person: the account owner was away and reads replies later. |
|
Two things, one of them on me. #1774 came first. @brandostrong's "size-based admission" (opened 20:34 UTC yesterday, part of #1269's A19) scales the same gate's headroom with the DXIL size –
@Royalflamejlh's Wine reading ( Proposal, unless the maintainer or @brandostrong prefers otherwise: I rebase this PR on #1774 as a stacked follow-up with only points 1–3 and the |
|
NVIDIA data point, since the description lists it as not tested: this PR merged onto
One run each. Not tested: the test suite, the smoke pair, this PR with #1316. AI-assisted (Claude Code, Claude Opus 5.5); run on my machine. |
PR #1924 — D3D12.X background driver compile headroom
What is in it
Tested
Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
The huge-pipeline gate (xcl-dev#1524, headroom by size since xcl-dev#1774) lets a compile on an xcl-pso worker start when its commit headroom is free. That reading at the start of a compile says nothing about what the title takes next: a retail title's 13.8 MB compute program (xcl-dev#1332 in the form of xcl-dev#1321) started at 4 s in the background with 36 GB of commit free - its headroom is 7 GB - and, with the title's own 25 GB of world loading after it, the AMD driver's ~15 GB for that compile ran the process into the machine's commit limit at 28 - 34 s on 32 GB of RAM, three times (twice with XCL_HUGE_PSO_CONCURRENCY=4, once with the defaults: a title thread's page could not be committed). A background compile now also needs what it takes (the headroom, or 1 GB per MB of DXIL when that is more) to be within a share of the machine's RAM (a quarter; XCL_HUGE_PSO_RAM_SHARE sets the n of 1/n, 0 leaves the commit free alone to decide, as before) and within the RAM available now (under Wine the commit reading is the memory available plus the free swap and never falls, as Royalflamejlh measured in review). Such a program waits for a bind that wants it (the gate's existing way out) and is built then, as a title thread would, and the log says so once per program and worker. Compiles the title waits for, and small ones, are unchanged. A graphics bind resolves without waiting and did not mark its pipeline wanted, so a graphics program the share holds back would have stayed a stand-in with its worker in the gate: `resolve` now calls `want()` too (found, with the test a_graphics_bind_releases_the_background_ram_share_gate, by WebIdentity1 in review). Measured on an RX 7800 XT, 32 GB: with the share the same runs end at 600 s, the 13.8 MB program built at 97 s when the title bound it, and a 60 s smoke's peak commit goes from 84 GB (main) to 27 GB. Co-Authored-By: WebIdentity1 <WebIdentity1@users.noreply.github.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
224888a to
2bb8e1c
Compare
|
Rebased on |
|
@Rednaxeh a gap next to what this PR closes, found in a title run with several huge compiles at once: the commit a background compile waits for is checked when it starts, but nothing counts the compiles already running. Compiles that start together all see the same free commit and all go. Run: RTX 4090 24 GB (driver 621.40), Ryzen 9 9950X3D, 47 GB RAM, 52.4 GB commit limit, Windows 11 26300, release. Tree: #2057 at
With the default ( What would close it, if you want it here: a compile counts what the ones already running take. For example, a total of the Not tested: this PR's head itself (the run above has #1774's gate only), AMD, other titles, more than one run with the setting. AI use: Claude Code with Claude Opus 5.5 made both runs, sampled the memory, read the log and the gate's code, and wrote this at my request. |
|
@S1m0ne1997 thank you, that is a real gap and your reading of the log is the same as mine: the gate reads the free commit once per compile, so with Two data points from this card for the same gate, posted on #1442 and #1269 today: on 32 GB with ~29 GB committed by the title the 3 GB headroom is never free during world loading, so every background compile waits (as @Royalflamejlh measured on #505 and #2130 bounds); only a bind that waits gets one built, on the title's thread. The in-flight total does not change that case, it only keeps a big machine from over-committing. |
Rebased on
mainwith #1774 in: the size-scaled headroom is #1774's, this PR keeps what that gate still lacks. Part of #232 / #505.The headroom a background compile waits for is read when the compile starts, and says nothing about what the title takes next. On 32 GB of RAM a retail title's 13.8 MB compute program (#1332 in the form of #1321) starts at 4 s in the background with 36 GB of commit free – its #1774 headroom is 7 GB – and the AMD driver's ~15 GB for it, with the title's own 25 GB of world loading after it, ran the process into the machine's commit limit at 28–34 s in three runs (
XCL_HUGE_PSO_CONCURRENCY=4twice, defaults once:0xc0000005in the title's ownmemcpy, a page that could not be committed).A background compile now also needs what it takes (the headroom, or 1 GB per MB of DXIL when that is more) to be within a share of the machine's RAM (a quarter;
XCL_HUGE_PSO_RAM_SHAREsets thenof 1/n,0leaves the commit free alone to decide, as before) and within the RAM available now (under WineullAvailPageFileis the memory available plus the free swap and never falls, as @Royalflamejlh measured below). Such a program waits for a bind that wants it (the gate's existing way out) and is built then, on that thread, as before #1524;xcl.logsays so once per program and worker. Compiles the title waits for, and small ones, are unchanged. On NVIDIA with 16 GB or more nothing changes for 1–2 MB programs.What is in it
crates/xcl/src/hle/d3d12x/real.rs:big_compile_takes(dxil_len),huge_pso_ram_share()(XCL_HUGE_PSO_RAM_SHARE),big_compile_may_start(headroom, takes, free, available, physical, ram_share), used bybig_compile_commit_free(dxil_len)in both gate call sites, which logs a program it holds back; testsa_background_compile_starts_within_the_commit_the_ram_share_and_the_ram_availableanda_graphics_bind_releases_the_background_ram_share_gate.crates/xcl/src/hle/d3d12x/pso_async.rs:resolvemarks a graphics pipeline wanted at its first bind, so a held graphics program gets built then (found in review by @WebIdentity1, with the test above; both taken as they are, co-author of the commit).README.md: the huge-pipeline paragraph says so, with the switch.Tested
stable-x86_64-pc-windows-msvc, DXC 1.9.2602.17 (Windows SDK 10.0.26100), debug for the tests, release for the titlecargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4on2bb8e1c(20 test binaries): 1155 passed, 1 failed, 46 ignored. The failure,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722: res[30] = 0x1, CPU 0x7fffffff), fails identically onmainon this card (direct DXIL backend, not this PR).gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpuandf32_programs_on_the_gpu(the per-lane form refusesV_MUL_F16/V_PK_MUL_F16/V_CVT_F16_F32),heap_window_out_of_memory_falls_back_to_the_switch_form.want()line ("graphics bind left its compile held by the RAM-share gate") and passes with it.XCL_PSO_TRACE=1(on689f2db-based trees, before the rebase): without the share,XCL_HUGE_PSO_CONCURRENCY=4ended the process at 34 s twice (commit 41–43 GB, the 13.8 MB compile in flight since 4 s); with it, the same run ends at 600 s and that program is built at 97 s, when the title binds it. With the defaults, one run ofmain689f2dbdied the same way at 29.8 s and one survived with 1 GB of commit to spare.Regression run
A at ~13 s in both runs.
Not tested
ullAvailPhyscondition follows @Royalflamejlh's reading; not run there.AI use
🤖 Generated with Claude Code