Skip to content

xcl run: add opt-in XCL_TITLE_COMMIT_CAP_MB job memory limit (#1566) - #1831

Open
fixgep wants to merge 2 commits into
xcl-dev:mainfrom
fixgep:feat/title-commit-cap-mb
Open

fixgep wants to merge 2 commits into
xcl-dev:mainfrom
fixgep:feat/title-commit-cap-mb

Conversation

@fixgep

@fixgep fixgep commented Nov 24, 2026 •

Copy link
Copy Markdown

Adds an opt-in process commit cap via XCL_TITLE_COMMIT_CAP_MB (disabled when unset or 0), plus OOM diagnostics when the cap is active. When set to a positive MiB value, the host creates and assigns a Windows Job Object with JOB_OBJECT_LIMIT_PROCESS_MEMORY (ProcessMemoryLimit = cap_mb * 1024 * 1024) before mapping or starting the title, keeps the handle alive for the host run, logs a clear diagnostic naming XCL_TITLE_COMMIT_CAP_MB and current process commit on D3D12 heap OOM refusals, and records allocation-free failure details in xcl.log and report.json before fatal Rust OOM fail-fast (0xc0000409). Part of #1566.

What is in it

  • crates/xcl/src/config.rs: ENV_TITLE_COMMIT_CAP_MB, parse_title_commit_cap_mb, title_commit_cap_mb_from_env, and unit tests for unset/zero/positive/invalid values.
  • crates/xcl/src/host.rs, crates/xcl/src/util.rs: CommitCapJob, apply_commit_cap_mb, apply_commit_cap_from_env, active_commit_cap_mb, current_process_commit_bytes / current_process_commit_mb, format_commit_cap_oom, log_commit_cap_if_active, StackBuf, and unit/subprocess tests verifying uncapped vs 64 MB capped VirtualAlloc, Vec::try_reserve, and OOM formatting.
  • crates/xcl/src/hle/d3d12x/vram.rs, crates/xcl/src/hle/d3d12x/sparse.rs, crates/xcl/src/hle/d3d12x/real.rs: log XCL_TITLE_COMMIT_CAP_MB, the configured cap MiB, and current process commit MiB when CreateHeap / CreateHeap1 fails with OOM while the cap is active.
  • crates/xcl/src/hooks.rs, crates/xcl/src/eh.rs, crates/xcl/src/log.rs, crates/xcl/src/report.rs: hook std::alloc::handle_alloc_error via hook_addr, write an allocation-free emergency line to xcl.log (write_emergency) and an allocation-free report.json (write_emergency_alloc_error using pre-cached startup metadata and StackBuf) before 0xc0000409 fail-fast, with unit and subprocess tests.
  • README.md: document XCL_TITLE_COMMIT_CAP_MB=N.

Tested

  • Hardware & toolchain: NVIDIA GeForce RTX 3060 (driver 32.0.15.9144), AMD Ryzen 5 7500F 6-Core Processor, Windows 10.0.26200.0, rustc 1.100.0 (0ef1bc386 2026-11-09), debug (cargo test) & release (cargo build --release -p xcl).
  • Targeted unit/subprocess tests (commit_cap, emergency_oom_report, alloc_error_hook): all 6 passed (alloc_error_hook_logs_active_commit_cap_and_writes_report verified 0xc0000409 exit code, xcl.log, and report.json under XCL_TITLE_COMMIT_CAP_MB=64).
  • cargo test -p xcl --lib -- --test-threads=4: 913 passed, 1 failed (gpu::recomp::tests::gpu_clamp_and_omod_per_instruction on v_pk_add_i16 clamp, pre-existing on main 177cd407 on RTX 3060), 22 ignored (SKIPPED GPU/driver-cache tests: 18 no wave64, 3 refused in gpu::recomp::lower_dxil::tests, 1 cannot disable the driver cache in shaders::tests::pso_measurement_compiles_an_exact_synthetic_record).
  • cargo test -p xcl --test '*' -- --test-threads=4: 49 passed, 0 failed, 20 ignored (SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; XCL_SAMPLE_* tests skipped their sample bodies because those env vars are unset).
  • cargo build --release -p xcl: built cleanly with zero new compiler warnings (only 2 pre-existing Atomic::fetch_update deprecation warnings in real.rs and xgameruntime/mod.rs).

Regression run

main:

xcl-smoke v1
commit: 177cd407e0114bd087622ae0c358fb3ba7e97484
gpu: NVIDIA GeForce RTX 3060
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1088 (PresentX 1088)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15523 MB

PR:

xcl-smoke v1
commit: e8d71df7cd9cd3b4f4dfa88c9d999c6307f53764
gpu: NVIDIA GeForce RTX 3060
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1137 (PresentX 1137)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15347 MB

Not tested

  • AMD / wave64 GPUs (no wave64 on RTX 3060), non-Windows hosts (unsupported), XCL_SAMPLE_* retail test inputs, and other workspace crates outside xcl (cargo test --workspace was not run).
  • Long multi-minute retail runs hitting a positive XCL_TITLE_COMMIT_CAP_MB limit (covered via synthetic 64 MiB subprocess tests).

AI use

  • Antigravity (Gemini 4 Hydrogen): wrote the commit-cap implementation, OOM diagnostics and allocation-free xcl.log/report.json emergency reporting, unit/subprocess tests, README.md note, and PR description; ran builds, tests, and smoke runs.

@gabrielsteglich

Copy link
Copy Markdown

Independent Windows/NVIDIA validation of the commit cap.

I merged PR head f0dbb087f3ec781bc740c816404f723fd7cd4e20 onto main at 1d027e5c76c9a86a7ee2ca1cc677edf0be95d331 locally, producing 1336bdceaa1ba6063b941d6132a51ff44df694af.

  • Windows 11 Pro build 26300, Intel Core i9-13900K, NVIDIA GeForce RTX 3090 (621.01), Rust 1.97.0 MSVC, and DXC 1.9.2602.17. Debug builds.
  • cargo test --offline --locked -p xcl --lib title_commit_cap -- --test-threads=4 --show-output passed both tests. title_commit_cap_mb_parsing and title_commit_cap_enforced_only_when_positive passed, including the capped and uncapped subprocess cases.
  • cargo build --offline --locked --workspace succeeded. cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output reported 962 passed, 0 failed, and 43 ignored. Cargo's pass count includes cases that returned early. Optional sample-data tests were disabled.
24 SKIPPED messages
SKIPPED gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu: f64, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64
SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64
SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
SKIPPED test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll
SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
SKIPPED uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))

The validation used synthetic tests. Startup and world loading with the cap enabled remain untested on this machine.

AI use — OpenAI's coding agent with GPT-6 ran the local validation and drafted this report.

@tikD1337

Copy link
Copy Markdown

Test report on a local merge of main 20cf130 + #1809, #1852, #1798 and this PR (release build).

Setup: NVIDIA GeForce RTX 4070 Ti SUPER 16 GB, driver 621.01, 31.6 GB RAM, Windows 11 Pro. Retail title, XCL_TITLE_COMMIT_CAP_MB=24000.

What happened

  • xcl.log confirms the cap: process commit cap: 24000 MB (XCL_TITLE_COMMIT_CAP_MB).
  • At 61.15–61.25 s, 28 × CreateHeap(0x4000000 bytes, type 1, alignment 0x0, flags 0x0) refused (0x8007000e), each followed by no video memory for more pages of title textures (0x8007000E). Those are the last lines of the log.
  • Then the process ended with 0xC0000409. There is no process ends with status line and no thread dump in xcl.log, and report.json has "crash": null, "exit_code": null.

What it does not show: whether the 24 GB was really reached or the limit counts more than the title's own commit. The same build without the cap grew by about 30 GB of commit in 100 s in the next two runs, and an external guard stopped them. So the cap likely did stop real growth here.

Two points for this PR

  1. A refusal by the job limit reaches the log as "no video memory", and the cap is not named. A line saying that an allocation failed while the cap is set, with the process's commit at that moment, would tell the two apart.
  2. Reaching the cap ends the title with a fail-fast and no report, so xcl.log and report.json do not say why the run ended.

No game data is included. The report was written with Claude Code (Claude Opus 5.5) from the run's xcl.log and report.json; the run was done by the person posting.

…l-dev#1566)

Part of xcl-dev#1566.

Record the active XCL_TITLE_COMMIT_CAP_MB limit and current process commit in MiB on D3D12 heap OOM warnings and before fatal Rust alloc-error fail-fast (writing allocation-free diagnostics to xcl.log and report.json).

Assisted-by: Antigravity (Gemini 4 Hydrogen)
@zorde23

zorde23 commented Nov 25, 2026

Copy link
Copy Markdown

Test report on an AMD RX 6750 XT (12 GB, driver 32.0.21045.29003), Ryzen 7 5700X, 32 GB RAM (45 GB commit limit), Windows build 26200, release build.

What was tested: f0dbb08 cherry-picked onto main 80f4819 (one conflict in config.rs, where #1053 added parse_device_type at the same place; kept both). XCL_TITLE_COMMIT_CAP_MB=20480. The same build also had local diagnostics (memory by kind, a commit guard), which are also in the main run it is compared with.

Run: the retail title, 300 s, A pressed at 15-35 s to reach the world, XCL_PSO_PRELOAD=0, XCL_ACTIVITY=1.

main 80f4819 with #1831 at 20,480 MB
end stopped by my guard at 150 s (system commit) exit 0xC0000409 at 110 s
frames drop to 0-20 per 2 s at 76 s 79 s
process commit at 96 s 21.9 GB 20.5 GB
local video memory at 96 s 10.5 GB 9.2 GB

Not tested: other caps, NVIDIA, a full cargo test --workspace on this build.

Written with Claude Code from runs on this machine.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@thiagocalile

Copy link
Copy Markdown

Tested commit f0dbb08 locally merged onto main 62265d3 (1-spot conflict in crates/xcl/src/config.rs with #1053's parse_device_type) on an AMD Radeon RX 6600 (8 GB VRAM, native wave64).

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, driver 32.0.21045.29003; XCL_ADAPTER=radeon), Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (26200), Rust 1.100.0 MSVC, DXC 1.8.2502.11.
  • XCL_ADAPTER=radeon cargo test -p xcl --lib title_commit_cap -- --nocapture: 2 passed, 0 failed, 0 ignored (0.04 s).
  • 90 s scripts/smoke.ps1 world-load sweep (release, XCL_DIRECT_DXIL=1, XCL_PRESS_A_AT=15,25,35):
    • Uncapped: exit 0x0, 2,348 frames (60 60 60), peak commit 23,979 MB, 0 crashes.
    • XCL_TITLE_COMMIT_CAP_MB=20480: exit 0x80000003, peak commit 20,241 MB (CreateHeap(64 MiB) refused 0x8007000E at 58.1 s).
    • XCL_TITLE_COMMIT_CAP_MB=16384: exit 0xc0000409, peak commit 16,224 MB (silent __fastfail inside XCL/CRT).

Note / possible follow-up (cross-linked with #1566):
We also tested adding a 2 GiB soft title-only headroom in kernelx.rs (VirtualAlloc MEM_COMMIT, XMemAllocDefault, AllocateTitlePhysicalPages) below the hard job cap so XCL's own allocations don't trigger silent 0xC0000409 (full table & snippet in #1566). That turned 0xC0000409 into a clean logged refusal at 16,384 MB (42.9 s), while confirming that above ~18.4 GB the remaining climb is XCL's own vram::Pages CreateHeap(64 MiB) pools — so #1831 is best documented as an outer safety fuse against runaway commit (and needs a quick rebase on config.rs).

Not tested

  • Full workspace suite at the merged commit, NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Antigravity (Gemini 4 Neon) ran the unit tests and 90 s RX 6600 smoke sweep and drafted this report; I checked the output before posting.

@JJAutoCompare

Copy link
Copy Markdown

XCL PR #1831 verification

Clean detached head f0dbb087f3ec781bc740c816404f723fd7cd4e20. The diff changes README.md, crates/xcl/src/config.rs, and crates/xcl/src/host.rs.

STOR-WINLAB ran Windows 11 Enterprise Evaluation x64 build 26200 on a Ryzen 7 3800X with Intel Arc A770 (16 GiB, driver 32.0.101.9175). DXC reported 1.9.2609.5. Rust was rustc 1.100.0 (0ef1bc386 2026-11-09), x86_64-pc-windows-msvc. Cargo used unoptimized dev/test profiles with debug info and incremental compilation disabled.

Tested

  • cargo build --workspace and cargo test --workspace --no-run both succeeded outside the Arc lock. The latter compiled 19 test binaries.
  • cargo test -p xcl --lib commit_cap with XCL_ADAPTER=NONE_CPU_ONLY outside the lock yielded 3 passed, 0 failed, 0 ignored, and 0 explicit skips. The tests covered unset, blank, zero, positive, and invalid input plus zero and overflow rejection by the Windows cap helper. Child processes committed 128 MiB via VirtualAlloc with the cap unset or zero. Under the 64 MiB cap, Windows rejected that allocation with a memory-limit error accepted by the test, and Vec::try_reserve also failed.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 ran once under Invoke-ArcTest.ps1 with XCL_ADAPTER=A770 and RUST_TEST_NOCAPTURE=1. Cargo exited 1. All three PR tests passed again.

Workspace failures and skips

All 20 libtest summaries in pr1831-suite.log (19 binaries and one doctest run) total 941 passed, 19 failed, 42 ignored. The 18 library failures were in GPU DXIL and recompiler tests, including pipeline creation errors and result mismatches. The synthetic-title e2e failed its RSSetDepthBiasX check when a blue pixel was expected to be green.

The log had 25 lines beginning with SKIPPED . Reasons included missing wave64 (17), refused wave32 per-lane cases (3), tiled resources tier below 2 (1), driver cache control (1), unavailable heap windows (1), and missing D3D12 debug-layer support (2). These are excluded from coverage.

Not tested

Matched main baseline, retail-title smoke run, and positive-cap enforcement through a live xcl run title launch. The XCL_SAMPLE_* variables were unset, so game-data paths were outside coverage.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1831-suite.log and published.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants