Repository navigation
Conversation
|
merge-check Local candidate diff against the PR headdiff --git a/crates/xcl/src/gpu/recomp/dxc.rs b/crates/xcl/src/gpu/recomp/dxc.rs
@@
-/// Commit that can still be had, the page files' growth included ([`avail_page_file`]), or
-/// `None` if the query fails.
+/// Commit currently available to this process, or `None` if the query fails.
pub fn commit_free() -> Option<u64> {
avail_page_file()
}
+/// Commit capacity after page-file growth, for planning long-lived GPU heaps.
+pub fn commit_capacity() -> Option<u64> {
+ avail_page_file().map(|now| now.saturating_add(page_file_growth()))
+}
@@
-/// Available page-file commit bytes from Windows, or `None` if the query fails: what is free
-/// against the page files' current size (`ullAvailPageFile`) and what they can still grow by
-/// (`page_file_growth`). Windows grows a page file when a commit needs it, so with page files that
-/// start small (the default, and a 2 GB start with a 16 GB maximum) `ullAvailPageFile` alone read
-/// a few GB free on a 32 GB PC while over 20 GB more could be had: the title's GPU heaps stayed
-/// out of the coherent window (`uma`) and the compiles it waited for stood at these gates.
+/// Available commit from Windows at the page files' current size, or `None` on query failure.
fn avail_page_file() -> Option<u64> {
@@
- (unsafe { GlobalMemoryStatusEx(&mut m) } != 0).then(|| m.ullAvailPageFile.saturating_add(page_file_growth()))
+ (unsafe { GlobalMemoryStatusEx(&mut m) } != 0).then_some(m.ullAvailPageFile)
}
diff --git a/crates/xcl/src/gpu/uma.rs b/crates/xcl/src/gpu/uma.rs
@@
-/// Commit that can still be had, the page files' growth included (`dxc::commit_free`).
+/// Commit capacity including possible page-file growth (`dxc::commit_capacity`).
fn free_commit() -> usize {
- crate::gpu::recomp::dxc::commit_free().map_or(usize::MAX, |b| b as usize)
+ crate::gpu::recomp::dxc::commit_capacity().map_or(usize::MAX, |b| b as usize)
}
diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs
@@
-/// That much commit is free, the page files' growth included (true when that is not known).
+/// That much commit is free now (true when that is not known). |
7bbc957 to
cf7d80d
Compare
|
Thanks, @thehollowedone, agreed. Counting growth that hasn't happened yet is right for the one-time heap plan but not for admitting compiles side by side. I adopted your split and squashed it into the one commit; new head
I updated the description with the suite, the page-file A/B and the regression runs on the new head. The A/B shows the split keeps the fix: the PR still gets the 4,095 MB coherent window at 11.5–11.9 GB free, where |
|
One process-limit boundary remains on head Please cap growth-aware capacity by any remaining hard process/job commit limit, or conservatively use current process headroom when that limit is present; keep the page-file growth benefit for unrestricted processes. A synthetic query-to-routing regression can supply 4 GiB process headroom, 20 GiB system growth and a hard job limit, then check that the coherent window does not take the growth path. A control without the hard limit should retain it. This is an API-contract/source finding, not an observed allocation failure on this head. Microsoft's AI use: Codex (GPT-6.2 Sol) checked the PR call path and Microsoft documentation; Codex (GPT-6.2 Astra) independently checked the process-limit case. |
|
One refinement to my process-limit note on head For a conservative fix that preserves growth-aware planning for processes outside jobs, use IsProcessInJob with a null job handle to detect any job. If it reports membership, use current process headroom for the heap decision unless an effective cap for the full job chain is known; otherwise retain the page-file growth estimate. A focused regression should cover an unconstrained immediate child job under a memory-limited parent, as well as a process outside a job. This is a source/API-contract follow-up; I did not run that nested-job regression. AI use: Codex (GPT-6.2 Sol) checked the Windows API contracts and drafted this note. |
…grow to XCL reads free commit as GlobalMemoryStatusEx's ullAvailPageFile, which counts each page file at its current size. Windows grows a page file only when commit nears the current limit, so with page files that start small (the default, or e.g. 2 GB growing to 16/32 GB) the reading stays at a few GB for a whole run while much more can be had. On a 32 GB PC with an RX 9070 XT (xcl-dev#2996), that kept the title's GPU heaps out of the coherent window: uma.rs wants 17,408 MB of commit free before the title starts, and read a few GB. dxc::commit_capacity() is new: ullAvailPageFile plus what each page file can still grow by (its maximum less its size, from NtQuerySystemInformation (SystemPageFileInformationEx), capped by the free space on its volume, and 0 when that is not known; the sizes are logged once). uma::free_commit reads it, since those heaps are planned once and live the whole run. The compile gates keep admitting on commit free now (dxc::commit_free(), ullAvailPageFile alone): wait_for_memory, big_slots, pieces_at_once and the driver-compile and build-ahead checks through big_compile_commit_free, which now reads dxc::commit_free() instead of its own GlobalMemoryStatusEx call. Microsoft documents allocations failing when page-file growth lags concurrent demand, so growth that has not happened is not counted for compiles started side by side. A regression test at the query-to-gate boundary supplies both values (2 GB now, 20 GB of growth, one background compile running) and checks a second one waits until 7 GB are free now. Under a job's commit limit the growth is not counted: such a limit does not rise with the page files, and ullAvailPageFile does not show it (on Windows 11 build 26200 a process in an 8 GB job read the system's 42 GB free). dxc::job_commit_limit() reads the immediate job's limits (QueryInformationJobObject with a null handle: JOB_OBJECT_LIMIT_PROCESS_MEMORY or JOB_OBJECT_LIMIT_JOB_MEMORY); a limit on an outer job of nested jobs cannot be read from inside. uma::heaps_window() takes the capacity query, and a regression from CommitSource to the window checks that 4 GiB now and 20 GiB of growth give the heaps the window outside a job and not under a job limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cf7d80d to
ae8050f
Compare
|
Thanks for both notes. I checked the API contract on this PC before changing anything, and it doesn't hold here. On Windows 11 build 26200,
So On So head
The description is updated for the new head. |
|
On head The fake commit query can return 2 GiB on its first call and 7 GiB on its second. That makes the rejected first attempt and later admission deterministic without another thread. A growth closure that panics also catches an accidental switch from Candidate test-only diffdiff --git a/crates/xcl/src/gpu/recomp/dxc.rs b/crates/xcl/src/gpu/recomp/dxc.rs
@@ fn a_background_compile_waits_for_commit_free_now_not_the_page_files_growth() {
- use std::sync::atomic::AtomicU64;
+ use std::cell::Cell;
let gate = MemoryGate::new();
let reserve = 6 * GB;
- let now = AtomicU64::new(2 * GB);
- let source = CommitSource { now: || Some(now.load(Ordering::SeqCst)), growth: || 20 * GB, job_limited: || false };
- assert_eq!(source.capacity(), Some(22 * GB));
+ let plan = CommitSource { now: || Some(2 * GB), growth: || 20 * GB, job_limited: || false };
+ assert_eq!(plan.capacity(), Some(22 * GB));
let unwanted: Wanted = Box::new(|| false);
- assert!(gate.try_admit(reserve, || source.free(), false, &unwanted), "the first compile goes in with none running");
- let admitted = AtomicBool::new(false);
- let early = std::thread::scope(|s| {
- s.spawn(|| {
- let unwanted: Wanted = Box::new(|| false);
- wait_admitted(&gate, &source, reserve, Duration::from_secs(60), &unwanted);
- admitted.store(true, Ordering::SeqCst);
- });
- std::thread::sleep(Duration::from_millis(300));
- let early = admitted.load(Ordering::SeqCst);
- now.store(7 * GB, Ordering::SeqCst);
- early
- });
- assert!(!early, "a second background compile went in on page-file growth that had not happened");
- assert!(admitted.load(Ordering::SeqCst), "it goes in once 7 GB are free now");
+ assert!(gate.try_admit(reserve, || Some(2 * GB), false, &unwanted));
+ let reads = Cell::new(0);
+ let source = CommitSource {
+ now: || {
+ let n = reads.get();
+ reads.set(n + 1);
+ Some(if n == 0 { 2 * GB } else { 7 * GB })
+ },
+ growth: || panic!("compile admission must not read future page-file growth"),
+ job_limited: || false,
+ };
+ wait_admitted(&gate, &source, reserve, Duration::from_secs(60), &unwanted);
+ assert_eq!(reads.get(), 2, "reject 2 GiB now, then admit at 7 GiB now");
assert_eq!(gate.working.load(Ordering::SeqCst), 2);AI use: OpenAI Codex (GPT-6.2 Astra) identified the scheduling gap; OpenAI Codex (GPT-6.2 Sol) checked the admission path and prepared this suggestion. |
|
Correction to my process-limit note and follow-up: I inferred that Current head AI use: OpenAI Codex (GPT-6.2 Sol) rechecked the thread and corrected its earlier inference. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
No open or merged PR makes the same change: #632 also touches the AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
Thanks to both of you. The next head,
Why I haven't pushed it yet: the regression run needs a clean title run of the head, and on AMD current
So I'll push As a check in the meantime, RX 9070 XT, default
Suite on AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and the title runs, and drafted this reply. |
gut0to
left a comment
There was a problem hiding this comment.
AI-assisted review: I traced the page-file enumeration, per-path free-space query, and capacity calculation. I used AI assistance and checked the current implementation; I did not run a Windows configuration test.
| /// What the page files can still grow by: each up to its maximum, and no further than its | ||
| /// volume's free space (nothing when that is not known). | ||
| fn growth_of(files: &[PageFile]) -> u64 { | ||
| files.iter().map(|f| f.max.saturating_sub(f.size).min(f.volume_free.unwrap_or(0))).fold(0, u64::saturating_add) |
There was a problem hiding this comment.
Could volume free space be counted once per distinct volume? page_files() attaches GetDiskFreeSpaceExW free bytes to each page-file entry, and growth_of() caps every entry independently. If two reported page files resolve to the same volume, both can claim the same free bytes, so commit_capacity() may overestimate how much commit can be added and admit a heap plan that later cannot grow. Please aggregate the growth limits by volume and add a test with two page files sharing one volume.
There was a problem hiding this comment.
Yes, done locally. The page files' growth is now added up per volume, and each volume's total is capped once by its free space. Each page file still stops at its own maximum.
The volume is now found by its name (GetVolumePathNameW, then GetVolumeNameForVolumeMountPointW, giving \\?\Volume{…}\), not by the path's drive letter. Two paths on one volume share one budget that way, and a page file on a volume mounted in a folder (C:\mnt\x\pagefile.sys) is counted against that volume, not against C:. Before, that case also read C:'s free space.
New test page_files_on_one_volume_share_its_free_space: two page files on one volume with 10 GB free, each able to grow by 14 GB, and one on another volume with 4 GB of room. The result is 14 GB. With the old per-file cap it reads 24 GB, so the test fails; I checked that.
On this PC the three page files resolve to three different volume names, each with its free space, so nothing measured so far changes. System Properties sets one page file per drive, so two on one volume would take a hand-edited registry setting; I didn't set one up. The sum is right either way.
This goes into the same push as the changes in my last comment, once #3455 is on main.
AI use: Claude Code (Claude Opus 5.5) made the change, wrote and ran the test, and drafted this reply.
XCL reads free commit as
GlobalMemoryStatusEx'sullAvailPageFile, which counts each page file only at its current size. Windows grows a page file only when commit gets close to the current limit. So on a PC whose page files start small (the Windows default, or for example 2 GB growing to 16/32 GB), XCL reads a few GB free while much more is available. The check inuma.rsthat puts the title's GPU heaps in the coherent window wants 17,408 MB of free commit at startup, so it keeps them out. This PR lets that one check count what each page file can still grow by: the heaps are planned once and live the whole run.The compile gates keep reading the commit that is free now. They admit compiles that allocate side by side, and Windows can fail allocations when page-file growth lags behind concurrent demand (Microsoft). Under a job's commit limit the growth isn't counted either, because such a limit doesn't rise with the page files. Both follow thehollowedone's reviews below. Part of #2996, where the plan was posted first (comment).
What #2996 measured on a 32 GB PC with an RX 9070 XT (
amd-devand the hive recipe), with growable page files:What is in it
crates/xcl/src/gpu/recomp/dxc.rs:CommitSource { now, growth, job_limited }.commit_free()isullAvailPageFile, as onmain.commit_capacity()addspage_file_growth(). For each page file that's its maximum minus its current size, fromNtQuerySystemInformation(SystemPageFileInformationEx), capped by the free space on its volume (GetDiskFreeSpaceExW), and 0 when either is unknown. The page files are logged once (commit: the page files can grow by N MB more than their size now (…)).job_commit_limit(): if the process's immediate job setsJOB_OBJECT_LIMIT_PROCESS_MEMORYorJOB_OBJECT_LIMIT_JOB_MEMORY, no growth is added (logged once).ullAvailPageFiledoesn't show job limits: on Windows 11 build 26200 a process in an 8 GB job read the system's 42 GB free.wait_for_memoryadmits throughwait_admitted, which reads only the current value.crates/xcl/src/gpu/uma.rs:heaps_window()takes the capacity query (dxc::commit_capacity). 1 test fromCommitSourceto the window: 4 GiB now and 20 GiB of growth give 4,095 MB outside a job and 512 MB under a job's limit; 17 GiB now is enough on its own; with no stored heaps there's no query.crates/xcl/src/hle/d3d12x/real.rs:big_compile_commit_free()readsdxc::commit_free()instead of callingGlobalMemoryStatusExitself. It's the same value as before.capacity(), orcapacity()to ignore the job limit, fails the matching test.Tested
stable-x86_64-pc-windows-msvc); debug build for the tests, release for the title runscargo test --workspace --no-fail-fast -- --test-threads=4onmaind0832e61merged withae8050f1(clean merge,git diff --checkclean): 2887 passed, 9 failed, 51 ignored. Onmaind0832e61: 2882 passed, 9 failed, 51 ignored. The 5 more passes are this PR's tests. The same 8 tests fail on both, so they come frommainon this card, not this PR:fuzz_validate_and_gpu_1,fuzz_validate_and_gpu_3,gpu_smem_flat_descriptor_windows_and_limits,f32_programs_on_the_gpu,gpu_f32_compares_with_nan,gpu_float_compares_random,gpu_ps_readfirstlane_loop_on_a_primitive_edge_ends, and the e2etwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs(counted twice).Regression run
The page-file A/B on this head. Retail title, 60 s smoke runs,
mainand this PR alternated over 2 rounds,XCL_DIRECT_DXIL=1on both sides: on AMD, currentmaincrashes in AMD's shader compiler at ~43 s without it (#3544, fixed by #3455).The page files on C: and D: can grow; X: is fixed at 32 GB. Before each run, a small helper held commit (
VirtualAlloc(MEM_COMMIT), no RAM touched), so every run started at 11.4–12.3 GB of free commit. That's about what this PC has on a normal day with its usual programs open. The runs started from VS Code, inside a job with no memory limit.mainff0c364br1 / r2UMA: 12332 MB/12164 MB of commit free, under 17408 MB: the title's GPU heaps stay outside unified memory(512 MB window)ae8050f1r1 / r2commit: the page files can grow by 22524 MB more than their size now, thenUMA opened (…, 4095 MB coherent window)main's r2 crash is in AMD's shader compiler (amdxc64.dll+0x85f80f, read at address 0x8). It hit the thread building graphics PSO26aa07cb05c04290(310,732 B DXIL). The PR's runs didn't get to that pipeline within 60 s, and neither didmain's r1.cf7d80d2, it crashedmainand this PR alike, 6 times. It went away after AMD's shader cache was cleared, and now it's back on the fresh cache as runs reach that pipeline again. So it's not a damaged cache, as I'd thought: AMD's compiler crashes on that pipeline. It's not Since #3243, AMD's shader compiler crashes (amdxc64.dll, null read) ~43 s into the retail title on an RX 9070 XT;XCL_DIRECT_DXIL=1avoids it #3544's address (+0x735dd8), and withXCL_DIRECT_DXIL=1graphics pipelines stay on the HLSL path.Under a job's commit limit, the same 60 s title run of this head in a job with a 37 GB
JOB_OBJECT_LIMIT_JOB_MEMORY(XCL_PREPARE=0), at 11.6 GB free, logged:It got the 512 MB window and ended by itself (exit 0, job peak commit 16.9 GB).
Not tested
QueryInformationJobObjectwith a null handle gives the immediate job), so the growth is still counted there.maindoesn't see any job limit either.XCL_DIRECT_DXIL(Since #3243, AMD's shader compiler crashes (amdxc64.dll, null read) ~43 s into the retail title on an RX 9070 XT;XCL_DIRECT_DXIL=1avoids it #3544), NVIDIA, Windows 10, a PC with no page file, and page files on a volume whose free space can't be read (the code counts no growth there).amd-dev: it reads free commit separately inuma.rs,pso_async.rsandflight.rs, so this PR doesn't reach it as is.AI use