xcl run: XCL_RAM_MB caps the RAM the process holds #3304

Merged
Foniass merged 1 commit from upstream-pr/3304 into main 2026-11-29 22:19:00 +00:00
Foniass commented 2026-11-29 06:51:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T06:51:20Z.


A console title's GPU memory is its only copy of what is in it; here
the title's pages are RAM and what the GPU reads of them is copied to
video memory. A retail title's world held 5 GB of RAM in pages whose
copy was on the card, most of them never touched again, and Windows
only takes such pages out of a process when RAM is short for the whole
system: on a 32 GB PC with 15 GB used by other programs that came at
under 4 GB free.

XCL_RAM_MB= gives the process's working set a hard maximum
(SetProcessWorkingSetSizeEx): Windows takes the pages used least out
of it as it grows past that, they stay in RAM on the standby list while
nothing else needs it, and a page touched again comes back with a soft
fault. XCL_RAM_MB=auto moves the maximum once a second so that
XCL_RAM_FREE_MB (6144 unless given) stay available. Unset: no budget,
as before. Commit is unchanged.

Ported from amd-dev a68f609f (raylitebull, ram_budget.rs as on
amd-dev) with its start call; left out: the preparation-worker count
that amd-dev also bounds by available RAM (a default behaviour change
of its own).

Review fixes (thehollowedone's candidate patch, with its tests): a number of MB too large for bytes (XCL_RAM_MB=17592186044416) overflowed and panicked in debug builds; it is now no setting, and a too-large XCL_RAM_FREE_MB gives the default reserve. An automatic maximum moved by a step at most, so once set it never went away; it is now lifted when more than a step of RAM is spare again (oversized_megabyte_settings_do_not_overflow, and new cases in an_automatic_maximum_follows_the_ram_available).

What is in it

  • crates/xcl/src/ram_budget.rs (new): the setting, the automatic maximum, tests
  • crates/xcl/src/host.rs: start after the boot is set; lib.rs; README.md: the switch

Tested

  • NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug tests, release smoke
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on db9a8f09: 2608 passed, 4 failed, 49 ignored. The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (E_OUTOFMEMORY from CreateComputePipelineState, seeds 70 / 545 / 1019 / 1507). They fail the same way on this branch's base, main fa204595, on this machine, and pass here on newer main (#3264, rebased onto 0fe06eb0, has 0 failures). SKIPPED GPU tests: 44 distinct notices, almost all no wave64.
  • Retail title: 60 s smoke run below (no device removal or crash, frames and peak commit within the limits).

Regression run

main:

xcl-smoke v1
commit: 3b6a91ed096d6d6e0fee52cfb86dc0a7d7c8c1b0
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1193 (PresentX 1193)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15684 MB

this PR:

xcl-smoke v1
commit: db9a8f091b7f6560327783f3f5c3316058fd07e3
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1679 (PresentX 1679)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 16899 MB

Not tested

  • a run with XCL_RAM_MB set (the smoke run is without it: the default is unchanged); the effect on a memory-tight PC is amd-dev's report
  • AMD GPUs

AI use

  • Claude Code with Claude Opus 5.5: ported this part of the amd-dev commit named above to main, applied the review fixes, wrote the commit message and this description, ran the tests and the smoke run.
  • Review fixes: thehollowedone's candidate patch (written with Codex), applied as posted, with more test cases.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5548404170 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3304). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-29T06:51:20Z. --- A console title's GPU memory is its only copy of what is in it; here the title's pages are RAM and what the GPU reads of them is copied to video memory. A retail title's world held 5 GB of RAM in pages whose copy was on the card, most of them never touched again, and Windows only takes such pages out of a process when RAM is short for the whole system: on a 32 GB PC with 15 GB used by other programs that came at under 4 GB free. XCL_RAM_MB=<MB> gives the process's working set a hard maximum (SetProcessWorkingSetSizeEx): Windows takes the pages used least out of it as it grows past that, they stay in RAM on the standby list while nothing else needs it, and a page touched again comes back with a soft fault. XCL_RAM_MB=auto moves the maximum once a second so that XCL_RAM_FREE_MB (6144 unless given) stay available. Unset: no budget, as before. Commit is unchanged. Ported from amd-dev a68f609f (raylitebull, ram_budget.rs as on amd-dev) with its start call; left out: the preparation-worker count that amd-dev also bounds by available RAM (a default behaviour change of its own). **Review fixes (thehollowedone's candidate patch, with its tests):** a number of MB too large for bytes (`XCL_RAM_MB=17592186044416`) overflowed and panicked in debug builds; it is now no setting, and a too-large `XCL_RAM_FREE_MB` gives the default reserve. An automatic maximum moved by a step at most, so once set it never went away; it is now lifted when more than a step of RAM is spare again (`oversized_megabyte_settings_do_not_overflow`, and new cases in `an_automatic_maximum_follows_the_ram_available`). **What is in it** - `crates/xcl/src/ram_budget.rs` (new): the setting, the automatic maximum, tests - `crates/xcl/src/host.rs`: `start` after the boot is set; `lib.rs`; `README.md`: the switch **Tested** - NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug tests, release smoke - `cargo test --workspace --no-fail-fast -- --test-threads=4` on db9a8f09: 2608 passed, 4 failed, 49 ignored. The 4 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3` (`E_OUTOFMEMORY` from `CreateComputePipelineState`, seeds 70 / 545 / 1019 / 1507). They fail the same way on this branch's base, main fa204595, on this machine, and pass here on newer main (#3264, rebased onto 0fe06eb0, has 0 failures). SKIPPED GPU tests: 44 distinct notices, almost all `no wave64`. - Retail title: 60 s smoke run below (no device removal or crash, frames and peak commit within the limits). **Regression run** main: ``` xcl-smoke v1 commit: 3b6a91ed096d6d6e0fee52cfb86dc0a7d7c8c1b0 gpu: NVIDIA GeForce RTX 5070 Ti title: 3cb1d8e0 seconds: 60 exit: 0x0 frames shown: 1193 (PresentX 1193) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15684 MB ``` this PR: ``` xcl-smoke v1 commit: db9a8f091b7f6560327783f3f5c3316058fd07e3 gpu: NVIDIA GeForce RTX 5070 Ti title: 3cb1d8e0 seconds: 60 exit: 0x0 frames shown: 1679 (PresentX 1679) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 16899 MB ``` **Not tested** - a run with `XCL_RAM_MB` set (the smoke run is without it: the default is unchanged); the effect on a memory-tight PC is amd-dev's report - AMD GPUs **AI use** - Claude Code with Claude Opus 5.5: ported this part of the amd-dev commit named above to main, applied the review fixes, wrote the commit message and this description, ran the tests and the smoke run. - Review fixes: thehollowedone's candidate patch (written with Codex), applied as posted, with more test cases. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
thehollowedone commented 2026-11-29 08:31:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-29T08:31:08Z.


merge-check
base: d8bd9a3820
head: 06f7542727
merge: clean (local merge 66cf84d0698ad4f09095f45a283561c4457b43f2; git diff --check clean)
build: cargo build --workspace -> ok; clean release builds of base and merge -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2,620 passed, 1 failed, 49 ignored; 26 explicit GPU skips (21 no wave64, 3 unsupported per-lane operations, 2 no heap windows). test_title_runs_and_game_folder_is_untouched failed once at the sparse-upload submit-5 readback. The exact filtered test passed on a head retry and on untouched main (1/0/0 each); I cannot attribute the one full-suite failure to this PR. The three new ram_budget::tests passed on the original head.
review: Two missing boundary cases in the opt-in code are reproducible. XCL_RAM_MB=17592186044416 parses but overflows at mb * MB, panicking in the debug build; XCL_RAM_FREE_MB has the same path. Once auto mode installs a hard maximum, next_max(Some(_), ...) never returns None even after RAM becomes plentiful. For example, a 4 GiB working set with 16 GiB available and a 6 GiB reserve remains capped at 4.5 GiB, although starting under those same measurements leaves it uncapped. That can cause avoidable page faults on a later burst; a frame-time cost has not been measured. Two local regressions failed on the original PR code (3 passed, 2 failed across the focused module) and passed with the candidate below (5 passed, 0 failed). The Windows integration test also changes the shared test process's working-set settings; a child process would isolate it. The README should state that explicit values below 4096 MiB are silently raised to 4096 MiB, or the implementation should honor/reject them explicitly.
performance: Guarded 60 s menu-phase smoke: base with cap unset 1,674 frames / 15,371 MB peak commit; merge with cap unset 1,675 / 15,443 MB; merge with XCL_RAM_MB=8192 1,691 / 15,051 MB. All exited without crash or device removal. The opt-in log shows Windows accepted the 8192 MiB maximum. These runs did not measure the process working set, page faults, or world-load pacing, so they do not establish a performance benefit or cost. Windows documents that a hard maximum changes paging behavior.
verdict: not yet: handle representable but overflowing settings, release an auto cap when RAM is plentiful again, and rerun the full suite after those changes.
hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11 / Codex (GPT-6.2 Sol) ran the tests, smoke and candidate; Codex (GPT-6.2 Astra) independently reviewed the Windows memory path.

Candidate diff and focused regression

This is a local candidate, not a pushed commit. cargo test -p xcl --lib ram_budget::tests -- --nocapture failed on the original code with the two new assertions, then passed 5/0/0 with this diff. It has not had a full workspace run or title smoke as a patched tree.

diff --git a/crates/xcl/src/ram_budget.rs b/crates/xcl/src/ram_budget.rs
@@
 fn setting_of(ram: Option<&str>, free: Option<&str>) -> Option<Setting> {
     let ram = ram?.trim();
     if ram.eq_ignore_ascii_case("auto") {
-        let free = free.and_then(|v| v.trim().parse::<u64>().ok()).unwrap_or(6144);
-        return Some(Setting::Auto(free * MB));
+        let free = free.and_then(|v| v.trim().parse::<u64>().ok()).and_then(|mb| mb.checked_mul(MB)).unwrap_or(6144 * MB);
+        return Some(Setting::Auto(free));
     }
-    ram.parse::<u64>().ok().filter(|&mb| mb > 0).map(|mb| Setting::Fixed((mb * MB).max(LEAST)))
+    ram.parse::<u64>().ok().filter(|&mb| mb > 0).and_then(|mb| mb.checked_mul(MB)).map(|bytes| Setting::Fixed(bytes.max(LEAST)))
 }
@@
-/// beyond `keep`, and has to shrink by what is missing; `before` (None: no maximum yet) moves
-/// by `STEP` at most. None: no maximum is needed (more than `STEP` to spare).
+/// beyond `keep`, and has to shrink by what is missing. An active maximum moves by `STEP` at
+/// most while needed; surplus greater than `STEP` removes it.
@@
 fn next_max(before: Option<u64>, ws: u64, available: u64, keep: u64) -> Option<u64> {
-    let want = (ws + available).saturating_sub(keep).max(LEAST);
+    if available.saturating_sub(keep) > STEP { return None; }
+    let want = ws.saturating_add(available).saturating_sub(keep).max(LEAST);
     match before {
-        None if available > keep + STEP => None,
         None => Some(want.max(ws.saturating_sub(STEP))),
-        Some(b) => Some(want.clamp(b.saturating_sub(STEP), b + STEP).max(LEAST)),
+        Some(b) => Some(want.clamp(b.saturating_sub(STEP), b.saturating_add(STEP)).max(LEAST)),
     }
 }
@@
+    #[test]
+    fn oversized_megabyte_settings_do_not_overflow() {
+        assert_eq!(setting_of(Some("17592186044416"), None), None);
+        assert_eq!(setting_of(Some("auto"), Some("17592186044416")), Some(Setting::Auto(6144 * MB)));
+        let largest_mb = (u64::MAX / MB) * MB;
+        assert_eq!(next_max(None, LEAST, 0, largest_mb), Some(LEAST));
+    }
+
+    #[test]
+    fn automatic_limit_lifts_when_ram_is_plentiful_again() {
+        assert_eq!(next_max(Some(LEAST), LEAST, 16_384 * MB, 6144 * MB), None);
+    }
@@
-        assert_eq!(next_max(Some(10000 * MB), 10000 * MB, 9000 * MB, keep), Some(10000 * MB + STEP));
+        assert_eq!(next_max(Some(10000 * MB), 10000 * MB, 6400 * MB, keep), Some(10256 * MB));
Generated smoke blocks

Each block came from scripts/smoke.ps1 -Seconds 60 on its clean release tree, with XCL_PREPARE=0, the same adapter, a fresh cache per run, and the script's network-off setting. A 16 GiB process-tree commit cap, 8 GiB system-commit headroom floor and 210 s launcher timeout guarded each run; neither guard stopped a run.

xcl-smoke v1
commit: d8bd9a38204667f3ca7dd9eeffcc2f1c937b07b0
gpu: NVIDIA GeForce RTX 3080 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15371 MB
xcl-smoke v1
commit: 66cf84d0698ad4f09095f45a283561c4457b43f2
gpu: NVIDIA GeForce RTX 3080 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1675 (PresentX 1675)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 15443 MB
xcl-smoke v1
commit: 66cf84d0698ad4f09095f45a283561c4457b43f2
gpu: NVIDIA GeForce RTX 3080 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1691 (PresentX 1691)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15051 MB

The third block used XCL_RAM_MB=8192; the first two had it unset.

<!-- greyfinch-sync:ivall/xcl:comment:7253155962 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3304#issuecomment-7253155962). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-29T08:31:08Z. --- merge-check base: d8bd9a38204667f3ca7dd9eeffcc2f1c937b07b0 head: 06f7542727b73ac0a45c69112403d12b3bc622c0 merge: clean (local merge 66cf84d0698ad4f09095f45a283561c4457b43f2; `git diff --check` clean) build: `cargo build --workspace` -> ok; clean release builds of base and merge -> ok tests: `cargo test --workspace --no-fail-fast -- --test-threads=4` -> 2,620 passed, 1 failed, 49 ignored; 26 explicit GPU skips (21 no wave64, 3 unsupported per-lane operations, 2 no heap windows). `test_title_runs_and_game_folder_is_untouched` failed once at the sparse-upload submit-5 readback. The exact filtered test passed on a head retry and on untouched main (1/0/0 each); I cannot attribute the one full-suite failure to this PR. The three new `ram_budget::tests` passed on the original head. review: Two missing boundary cases in the opt-in code are reproducible. `XCL_RAM_MB=17592186044416` parses but overflows at `mb * MB`, panicking in the debug build; `XCL_RAM_FREE_MB` has the same path. Once auto mode installs a hard maximum, `next_max(Some(_), ...)` never returns `None` even after RAM becomes plentiful. For example, a 4 GiB working set with 16 GiB available and a 6 GiB reserve remains capped at 4.5 GiB, although starting under those same measurements leaves it uncapped. That can cause avoidable page faults on a later burst; a frame-time cost has not been measured. Two local regressions failed on the original PR code (3 passed, 2 failed across the focused module) and passed with the candidate below (5 passed, 0 failed). The Windows integration test also changes the shared test process's working-set settings; a child process would isolate it. The README should state that explicit values below 4096 MiB are silently raised to 4096 MiB, or the implementation should honor/reject them explicitly. performance: Guarded 60 s menu-phase smoke: base with cap unset 1,674 frames / 15,371 MB peak commit; merge with cap unset 1,675 / 15,443 MB; merge with `XCL_RAM_MB=8192` 1,691 / 15,051 MB. All exited without crash or device removal. The opt-in log shows Windows accepted the 8192 MiB maximum. These runs did not measure the process working set, page faults, or world-load pacing, so they do not establish a performance benefit or cost. [Windows documents](https://learn.microsoft.com/en-us/windows/desktop/api/memoryapi/nf-memoryapi-setprocessworkingsetsizeex) that a hard maximum changes paging behavior. verdict: not yet: handle representable but overflowing settings, release an auto cap when RAM is plentiful again, and rerun the full suite after those changes. hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11 / Codex (GPT-6.2 Sol) ran the tests, smoke and candidate; Codex (GPT-6.2 Astra) independently reviewed the Windows memory path. <details><summary>Candidate diff and focused regression</summary> This is a local candidate, not a pushed commit. `cargo test -p xcl --lib ram_budget::tests -- --nocapture` failed on the original code with the two new assertions, then passed 5/0/0 with this diff. It has not had a full workspace run or title smoke as a patched tree. ```diff diff --git a/crates/xcl/src/ram_budget.rs b/crates/xcl/src/ram_budget.rs @@ fn setting_of(ram: Option<&str>, free: Option<&str>) -> Option<Setting> { let ram = ram?.trim(); if ram.eq_ignore_ascii_case("auto") { - let free = free.and_then(|v| v.trim().parse::<u64>().ok()).unwrap_or(6144); - return Some(Setting::Auto(free * MB)); + let free = free.and_then(|v| v.trim().parse::<u64>().ok()).and_then(|mb| mb.checked_mul(MB)).unwrap_or(6144 * MB); + return Some(Setting::Auto(free)); } - ram.parse::<u64>().ok().filter(|&mb| mb > 0).map(|mb| Setting::Fixed((mb * MB).max(LEAST))) + ram.parse::<u64>().ok().filter(|&mb| mb > 0).and_then(|mb| mb.checked_mul(MB)).map(|bytes| Setting::Fixed(bytes.max(LEAST))) } @@ -/// beyond `keep`, and has to shrink by what is missing; `before` (None: no maximum yet) moves -/// by `STEP` at most. None: no maximum is needed (more than `STEP` to spare). +/// beyond `keep`, and has to shrink by what is missing. An active maximum moves by `STEP` at +/// most while needed; surplus greater than `STEP` removes it. @@ fn next_max(before: Option<u64>, ws: u64, available: u64, keep: u64) -> Option<u64> { - let want = (ws + available).saturating_sub(keep).max(LEAST); + if available.saturating_sub(keep) > STEP { return None; } + let want = ws.saturating_add(available).saturating_sub(keep).max(LEAST); match before { - None if available > keep + STEP => None, None => Some(want.max(ws.saturating_sub(STEP))), - Some(b) => Some(want.clamp(b.saturating_sub(STEP), b + STEP).max(LEAST)), + Some(b) => Some(want.clamp(b.saturating_sub(STEP), b.saturating_add(STEP)).max(LEAST)), } } @@ + #[test] + fn oversized_megabyte_settings_do_not_overflow() { + assert_eq!(setting_of(Some("17592186044416"), None), None); + assert_eq!(setting_of(Some("auto"), Some("17592186044416")), Some(Setting::Auto(6144 * MB))); + let largest_mb = (u64::MAX / MB) * MB; + assert_eq!(next_max(None, LEAST, 0, largest_mb), Some(LEAST)); + } + + #[test] + fn automatic_limit_lifts_when_ram_is_plentiful_again() { + assert_eq!(next_max(Some(LEAST), LEAST, 16_384 * MB, 6144 * MB), None); + } @@ - assert_eq!(next_max(Some(10000 * MB), 10000 * MB, 9000 * MB, keep), Some(10000 * MB + STEP)); + assert_eq!(next_max(Some(10000 * MB), 10000 * MB, 6400 * MB, keep), Some(10256 * MB)); ``` </details> <details><summary>Generated smoke blocks</summary> Each block came from `scripts/smoke.ps1 -Seconds 60` on its clean release tree, with `XCL_PREPARE=0`, the same adapter, a fresh cache per run, and the script's network-off setting. A 16 GiB process-tree commit cap, 8 GiB system-commit headroom floor and 210 s launcher timeout guarded each run; neither guard stopped a run. ``` xcl-smoke v1 commit: d8bd9a38204667f3ca7dd9eeffcc2f1c937b07b0 gpu: NVIDIA GeForce RTX 3080 Ti title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1674 (PresentX 1674) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15371 MB ``` ``` xcl-smoke v1 commit: 66cf84d0698ad4f09095f45a283561c4457b43f2 gpu: NVIDIA GeForce RTX 3080 Ti title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1675 (PresentX 1675) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 15443 MB ``` ``` xcl-smoke v1 commit: 66cf84d0698ad4f09095f45a283561c4457b43f2 gpu: NVIDIA GeForce RTX 3080 Ti title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1691 (PresentX 1691) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15051 MB ``` The third block used `XCL_RAM_MB=8192`; the first two had it unset. </details>
tiagonleal commented 2026-11-29 13:15:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-29T13:15:17Z.


merge-check
base: 7a649b0e73
head: 06f7542727
merge: clean (trial merge 351496b0, local, not pushed; git diff --check clean)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2669 passed, 4 failed, 49 ignored; SKIPPED: 26 (21 "no wave64" on this GPU, 3 per-lane f16 forms refused, 2 "no heap windows"); failing: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0 to _3, which fail on the base too (base alone: 2666 passed, 4 failed, 49 ignored). The three ram_budget tests passed.
review: whole diff read (+180/-0: ram_budget.rs, one call in host.rs, README). Without XCL_RAM_MB start() returns at once, so the default path is one environment read. set_max passes QUOTA_LIMITS_HARDWS_MAX_ENABLE with the minimum left soft, and lifts it with MAX_DISABLE; the automatic thread stops if Windows refuses. next_max is covered by its test for growth, shrink by a step, and the 4096 MB floor. Two things I would want a user of auto to know, both measured below and neither a fault in the code: what Windows reports as available is mostly standby here, so auto with the default 6144 MB cut the working set from about 14 GB to about 7 GB within 20 s; and once a maximum is set, auto never returns to "no maximum".
performance: none by default. scripts/smoke.ps1 -Seconds 60 (Newer Retail Game, menus, release, XCL_PREPARE=0, switch not set): merged tree 1696 frames, peak commit 17012 MB; base 1692 and 1697 frames, 16957 and 17238 MB.
Runs into the world, 600 s asked for each, 32 GB of RAM, XCL_PREPARE=0, XCL_UMA_DRIVER=mixed:1536:1792, XCL_TEXTURE_LEVEL_PAGES=1, A pressed every 4 s. My harness has a guard that ends the run when free RAM falls under 1 GB.

tree, switch ended by the guard peak working set least free RAM last 2 s with a present presents
base 7a649b0e, not set yes, at about 86 s 19.7 GB 0.67 GB 86 s 1656
merged, not set yes, at about 84 s 19.4 GB 0.14 GB 84 s 1685
merged, XCL_RAM_MB=auto no, ran 600 s 13.6 GB 3.81 GB 94 s 1757
merged, XCL_RAM_MB=auto no, ran 600 s 13.7 GB 3.11 GB 86 s 1593
merged, XCL_RAM_MB=16000 no, ran 600 s 15.6 GB 1.01 GB 88 s 1717

Three earlier runs of main d2ec83de without the switch ended the same way as the first two rows (guard at 80 to 84 s, working set 19.0 to 19.1 GB). So the switch does what it says: the process stays inside the RAM this PC has, where without it the run does not survive the world load. It does not get this title into the world here, though. In all three capped runs the title stops submitting within seconds of the first world frame (mc3304-16000: 1 present with 3965 draws and 13762 dispatches in the 2 s before 88.3 s, then 0 submits to the end) with no watchdog, no device removal and no crash. With the fixed 16000 the working set was never squeezed hard and there are only 10 pipeline-wait warnings, so I do not think the cap causes that stop; the runs without it die at the same point, so I cannot show it either way. In the first auto run the maximum went 14250 MB at 81 s, 7603 MB at 100 s, 4250 MB at 601 s, with 6.1 to 6.8 GB reported available throughout. About 6.6 GB of the working set at the start is the NVIDIA shader cache file (8 GiB on this PC) mapped into the process, which is what a cap trims first.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (617.42), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, rustc 1.100.0, debug suite, release smoke and runs / Claude Code: Claude Fable 5.2 ran the merge, build, suite, smoke and runs and read the diff; Claude Opus 5.5 read the run logs.

  • Tiago
<!-- greyfinch-sync:ivall/xcl:comment:7256401563 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3304#issuecomment-7256401563). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-11-29T13:15:17Z. --- merge-check base: 7a649b0e7341c1daf1bcf2f3101e9518a8a8c16f head: 06f7542727b73ac0a45c69112403d12b3bc622c0 merge: clean (trial merge 351496b0, local, not pushed; `git diff --check` clean) build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2669 passed, 4 failed, 49 ignored; SKIPPED: 26 (21 "no wave64" on this GPU, 3 per-lane f16 forms refused, 2 "no heap windows"); failing: `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0` to `_3`, which fail on the base too (base alone: 2666 passed, 4 failed, 49 ignored). The three `ram_budget` tests passed. review: whole diff read (+180/-0: `ram_budget.rs`, one call in `host.rs`, README). Without `XCL_RAM_MB` `start()` returns at once, so the default path is one environment read. `set_max` passes `QUOTA_LIMITS_HARDWS_MAX_ENABLE` with the minimum left soft, and lifts it with `MAX_DISABLE`; the automatic thread stops if Windows refuses. `next_max` is covered by its test for growth, shrink by a step, and the 4096 MB floor. Two things I would want a user of `auto` to know, both measured below and neither a fault in the code: what Windows reports as available is mostly standby here, so `auto` with the default 6144 MB cut the working set from about 14 GB to about 7 GB within 20 s; and once a maximum is set, `auto` never returns to "no maximum". performance: none by default. `scripts/smoke.ps1 -Seconds 60` (Newer Retail Game, menus, release, `XCL_PREPARE=0`, switch not set): merged tree 1696 frames, peak commit 17012 MB; base 1692 and 1697 frames, 16957 and 17238 MB. Runs into the world, 600 s asked for each, 32 GB of RAM, `XCL_PREPARE=0`, `XCL_UMA_DRIVER=mixed:1536:1792`, `XCL_TEXTURE_LEVEL_PAGES=1`, A pressed every 4 s. My harness has a guard that ends the run when free RAM falls under 1 GB. | tree, switch | ended by the guard | peak working set | least free RAM | last 2 s with a present | presents | |---|---|---|---|---|---| | base `7a649b0e`, not set | yes, at about 86 s | 19.7 GB | 0.67 GB | 86 s | 1656 | | merged, not set | yes, at about 84 s | 19.4 GB | 0.14 GB | 84 s | 1685 | | merged, `XCL_RAM_MB=auto` | no, ran 600 s | 13.6 GB | 3.81 GB | 94 s | 1757 | | merged, `XCL_RAM_MB=auto` | no, ran 600 s | 13.7 GB | 3.11 GB | 86 s | 1593 | | merged, `XCL_RAM_MB=16000` | no, ran 600 s | 15.6 GB | 1.01 GB | 88 s | 1717 | Three earlier runs of `main` `d2ec83de` without the switch ended the same way as the first two rows (guard at 80 to 84 s, working set 19.0 to 19.1 GB). So the switch does what it says: the process stays inside the RAM this PC has, where without it the run does not survive the world load. It does not get this title into the world here, though. In all three capped runs the title stops submitting within seconds of the first world frame (`mc3304-16000`: 1 present with 3965 draws and 13762 dispatches in the 2 s before 88.3 s, then 0 submits to the end) with no watchdog, no device removal and no crash. With the fixed 16000 the working set was never squeezed hard and there are only 10 pipeline-wait warnings, so I do not think the cap causes that stop; the runs without it die at the same point, so I cannot show it either way. In the first `auto` run the maximum went 14250 MB at 81 s, 7603 MB at 100 s, 4250 MB at 601 s, with 6.1 to 6.8 GB reported available throughout. About 6.6 GB of the working set at the start is the NVIDIA shader cache file (8 GiB on this PC) mapped into the process, which is what a cap trims first. verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (617.42), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, rustc 1.100.0, debug suite, release smoke and runs / Claude Code: Claude Fable 5.2 ran the merge, build, suite, smoke and runs and read the diff; Claude Opus 5.5 read the run logs. - Tiago
Foniass commented 2026-11-29 17:19:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T17:19:00Z.


Thanks thehollowedone. I applied your candidate patch in db9a8f09 (credited in the commit and the description):

  • oversized MB values give no setting, or the default reserve, instead of overflowing;
  • an automatic maximum is lifted when more than a step of RAM is spare again.

I added more cases to the existing test: a step-limited raise, and a lift from the least maximum. Full suite on db9a8f09: 2608 passed, 4 failed (this machine's fuzz E_OUTOFMEMORY, at the branch's base too), 49 ignored. The new smoke run is in the description.

(Written with Claude Code, Claude Opus 5.5.)

<!-- greyfinch-sync:ivall/xcl:comment:7259594093 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3304#issuecomment-7259594093). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-29T17:19:00Z. --- Thanks thehollowedone. I applied your candidate patch in db9a8f09 (credited in the commit and the description): - oversized MB values give no setting, or the default reserve, instead of overflowing; - an automatic maximum is lifted when more than a step of RAM is spare again. I added more cases to the existing test: a step-limited raise, and a lift from the least maximum. Full suite on db9a8f09: 2608 passed, 4 failed (this machine's fuzz `E_OUTOFMEMORY`, at the branch's base too), 49 ignored. The new smoke run is in the description. (Written with Claude Code, Claude Opus 5.5.)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3304
No description provided.