Repository navigation
Conversation
wait_for_memory trusted the free commit, which an auto-growing page file keeps "plenty" however much the compiles hold. xcl shaders --precompile on a retail pack ran to 100 GB of commit, most of it in the page file, on its CS_RaytracingResolve_* compute programs (2-15 GB each in DXC). --precompile now sets a cap on the process's private memory (default half of the RAM; XCL_DXC_MEMORY_GB, 0 = none). Under it a compile is let in at once below a quarter of the cap, one per 500 ms up to the cap, and not while another runs at the cap; the minute's wait no longer lets one through. A running title is unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Precompile: hold the DXC compiles to a share of the RAM
xcl shaders --precompileon a retail pack (26 503 programs) ran to ~100 GB of commit, most of it in the page file, and stalled for tens of minutes on the compute programs near the end of the pack.wait_for_memoryadmits a compile when the free commit is at least 6 GB plus 1 GB per running compile, and an auto-growing page file keeps that true however much the compiles hold. It also assumes a compile takes at most ~0.7 GB; the pack'sCS_RaytracingResolve_*programs take 2 – 15 GB each in DXC, and four translated compute programs (CS_ScreenProbes_*,CS_Primary_Shade_*; 4.6 – 155 MB of HLSL) do not compile at all within 24 GB.This is a mitigation, not a fix for those four programs: a compile already running keeps growing, and the cap only stops further ones from starting.
What is in it
gpu/recomp/dxc.rs:set_memory_cap/default_memory_cap(XCL_DXC_MEMORY_GB, default half of the RAM, 0 = none),private_bytes(the process's private commit),cap_admits, andwait_for_memoryusing it when a cap is set. Under a cap a compile starts at once below a quarter of the cap, one per 500 ms up to the cap, and not while another runs at the cap (one alone always goes, so nothing deadlocks); the 60 s wait no longer lets one through. Without a cap (a running title) nothing changes.shaders.rs:--precompilesets the cap and prints it.private_bytesreading this process.Tested
cargo test --release -p xcl --lib -- memory_cap private_bytes: 2 passed, 0 failed, 0 ignored (on this PR's commit, rebased ontomainb9b6ea6).xcl shaders <pack> --precompile --only cs, 15 compile threads, run inside a 24 GB job object so a runaway would be killed: peak ~24 GB (before, with the same threads and no cap: over 100 GB, 20 GB of it resident), the process was not killed, and 2 685 compute programs compiled in 40 min with 4 errors (DXC "not enough memory" on the four programs above).--precompileof the same pack, same limits, finished (25 134 compiled, 10 434 already cached, 22 errors, 390 GS programs skipped).Regression run
Not run yet (draft):
scripts/smoke.ps1onmainand on this commit. The change does not run in a title:--precompileis the only caller ofset_memory_cap.Not tested
cargo test --workspace -- --test-threads=4(only the two new tests were run).scripts/smoke.ps1on a title (see above).AI use
wait_for_memory, traced which programs grew), wrote the change, the tests and this description. The runs above were done on the author's machine under the author's direction.Mirror of xcl-dev#1762 (auto-synced, do not edit).