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. |
The huge-pipeline gate (xcl-dev#1524) let a compile on an xcl-pso worker start with 3 GB of commit free, whatever the program's size. The driver's compiler takes memory in proportion to the program: ~1.5 GB for a 1 MB one (NVIDIA), and an AMD driver took a process from 34 to 42 GB of commit on a retail title's 13.8 MB compute program (xcl-dev#1332 in the form of xcl-dev#1321). With the giant lane next to the ordinary ones that compile started at 4 s, in the background, while the title's world loading took its own 25 GB: on 32 GB of RAM the process ran into the machine's commit limit at 28 - 34 s, twice with XCL_HUGE_PSO_CONCURRENCY=4 and once with the defaults (a title thread's page could not be committed). big_compile_commit_needed(bytes) is 3 GB plus 1 GB for every 2 MB of DXIL, and big_compile_may_start also refuses a background compile that would take more than 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): 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 the pipeline wanted, so a graphics program the share holds back would have stayed a stand-in, 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 rule 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>
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 (#1524) lets a compile on an
xcl-pso*worker start with 3 GB of commit free, whatever the program's size. The driver's compiler takes memory in proportion to the program: ~1.5 GB for a 1 MB one (NVIDIA, from the gate's own comment), and an AMD driver took the process from 34 to 42 GB of commit on a retail title's 13.8 MB compute program (#1332 in the form of #1321). With the giant lane running next to the ordinary ones, that compile starts at 4 s, in the background, while the title's world loading takes its own 25 GB: on 32 GB of RAM the process ran into the machine's commit limit at 28–34 s, twice withXCL_HUGE_PSO_CONCURRENCY=4and once with the defaults (a title thread's page could not be committed:0xc0000005in the title's ownmemcpy). Part of #232 / #505.A background compile now needs
3 GB + 1 GB per 2 MB of DXILof commit free, and may take at most a quarter of the machine's RAM (XCL_HUGE_PSO_RAM_SHARE, thenof 1/n, default 4;0leaves the commit free alone to decide, as before); a bigger program waits for a bind that wants it (the gate's existing way out) and is built then, on that thread, as before #1524, andxcl.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 (3.5–4 GB needed, under the quarter).What is in it
crates/xcl/src/hle/d3d12x/real.rs:big_compile_commit_needed(bytes),big_compile_may_start(needed, free, physical, ram_share)andhuge_pso_ram_share()(XCL_HUGE_PSO_RAM_SHARE), used bybig_compile_commit_free(bytes)in the gate, which logs a program it holds back;pso_async::resolvemarks a graphics pipeline wanted at its first bind, so a held graphics program gets built then (found in review by WebIdentity1, with the testa_graphics_bind_releases_the_background_ram_share_gate, both taken as they are); teststhe_commit_a_background_compile_needs_grows_with_its_dxilanda_background_compile_starts_within_the_commit_and_a_quarter_of_the_ram.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 && XCL_REQUIRE_GPU=wave64,mesh cargo test --workspace -- --test-threads=4on224888a(--no-fail-fast, 20 test binaries): 977 passed, 1 failed, 45 ignored. The failure,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722: res[30] = 0x1, CPU 0x7fffffff), fails identically onmain689f2dbon this card: the 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.XCL_PSO_TRACE=1: without the rule,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. The head's peak commit is a third of
main's: the 13.8 MB program's background compile, whichmainstarts at 4 s, does not start.Not tested
AI use
🤖 Generated with Claude Code