xcl run: XCL_RAM_MB caps the RAM the process holds #3304
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3304"
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 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 onamd-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-largeXCL_RAM_FREE_MBgives 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 inan_automatic_maximum_follows_the_ram_available).What is in it
crates/xcl/src/ram_budget.rs(new): the setting, the automatic maximum, testscrates/xcl/src/host.rs:startafter the boot is set;lib.rs;README.md: the switchTested
cargo test --workspace --no-fail-fast -- --test-threads=4ondb9a8f09: 2608 passed, 4 failed, 49 ignored. The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(E_OUTOFMEMORYfromCreateComputePipelineState, seeds 70 / 545 / 1019 / 1507). They fail the same way on this branch's base, mainfa204595, on this machine, and pass here on newer main (#3264, rebased onto0fe06eb0, has 0 failures). SKIPPED GPU tests: 44 distinct notices, almost allno wave64.Regression run
main:
this PR:
Not tested
XCL_RAM_MBset (the smoke run is without it: the default is unchanged); the effect on a memory-tight PC is amd-dev's reportAI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-29T08:31:08Z.
merge-check
base:
d8bd9a3820head:
06f7542727merge: clean (local merge 66cf84d0698ad4f09095f45a283561c4457b43f2;
git diff --checkclean)build:
cargo build --workspace-> ok; clean release builds of base and merge -> oktests:
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_untouchedfailed 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 newram_budget::testspassed on the original head.review: Two missing boundary cases in the opt-in code are reproducible.
XCL_RAM_MB=17592186044416parses but overflows atmb * MB, panicking in the debug build;XCL_RAM_FREE_MBhas the same path. Once auto mode installs a hard maximum,next_max(Some(_), ...)never returnsNoneeven 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=81921,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 -- --nocapturefailed 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.Generated smoke blocks
Each block came from
scripts/smoke.ps1 -Seconds 60on its clean release tree, withXCL_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.The third block used
XCL_RAM_MB=8192; the first two had it unset.Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-29T13:15:17Z.
merge-check
base:
7a649b0e73head:
06f7542727merge: clean (trial merge 351496b0, local, not pushed;
git diff --checkclean)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_0to_3, which fail on the base too (base alone: 2666 passed, 4 failed, 49 ignored). The threeram_budgettests passed.review: whole diff read (+180/-0:
ram_budget.rs, one call inhost.rs, README). WithoutXCL_RAM_MBstart()returns at once, so the default path is one environment read.set_maxpassesQUOTA_LIMITS_HARDWS_MAX_ENABLEwith the minimum left soft, and lifts it withMAX_DISABLE; the automatic thread stops if Windows refuses.next_maxis covered by its test for growth, shrink by a step, and the 4096 MB floor. Two things I would want a user ofautoto know, both measured below and neither a fault in the code: what Windows reports as available is mostly standby here, soautowith 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,autonever 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.7a649b0e, not setXCL_RAM_MB=autoXCL_RAM_MB=autoXCL_RAM_MB=16000Three earlier runs of
maind2ec83dewithout 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 firstautorun 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.
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):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 fuzzE_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.)