Shaders: under Wine, at most 4 DXC compile threads by default #2117
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2127"
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 St5sz2Jk on 2026-11-25T05:26:46Z.
Under Wine,
compile_threads()now defaults to at most 4 DXC threads instead of every core but one.XCL_DXC_THREADSstill chooses. Part of #1269 (measurements).Under Wine the DXC workers of one process mostly wait on each other, so more threads do not help, and past a point they make it slower. On a 32-thread Ryzen 9 5950X with Wine 11.22,
xcl shaders shaders.rpf --precompile --only csinto an empty cache for 120 s:With the default (31 threads here), a retail title's world load waited 35–70 s for each compute program it needed: the title's loading threads were in
dxc::compile_cached→Receiver::recv, and the driver builds took ≤ 6 s. WithXCL_DXC_THREADS=4, the same load got through and ran the story intro. Several processes do scale (4 × 2 threads: 60.4 MB in 120 s), which shows the lock is per process; #1502's--processeswould help--precompilehere too.The same count also bounds the
xcl-pso-Npipeline workers. On NVIDIA under Proton, @voiceovarian1-max found that this keeps the world load from running a 31 GB machine out of memory: 0 of 10 runs survived with the default, 3 of 3 with 4 (comment).4 rather than 2: the two were equal in the scan, and 4 keeps more slack for compiles that wait on memory or on each other's cache flights. Native Windows is unchanged.
What is in it
crates/xcl/src/gpu/recomp/dxc.rs:default_compile_threads(cores, wine)(every core but one; at mostWINE_COMPILE_THREADS= 4 under Wine), used bycompile_threads()whenXCL_DXC_THREADSis unset, with one info line when the cap applies. Unit testwine_caps_the_default_compile_threads.Tested
7.3.5-2-cachyos, Wine 11.22, vkd3d-protonec207194(DXVKdxgi). Rust cross-build forx86_64-pc-windows-msvc, debug for the tests, release for the runs. Head0e84e74onmain6020a33.cargo test --workspace -- --test-threads=4under Wine (cargo's runner set towine), on this head and onmain6020a33:-p xcl --lib: 1048 passed, 50 failed, 26 ignored (main: 1047 passed, 50 failed, 26 ignored; the one more is the new test). One test is skipped with--skip:hle::mfplat::tests::reset_dxgi_device_manager_with_d3d12_device_and_token_validationcallsdxgi.dll.DXGID3D10CreateDevice, which DXVK'sdxgidoes not export, and Wine aborts the whole binary there (on main too).lower_dxil::tests::f16_programs_on_the_gpu(4: per-lane form refused),f32_programs_on_the_gpu(2: per-lane form refused),shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(cannot disable the driver cache).xcl shaders … --precompile --only cswithXCL_DXC_THREADSunset logsDXC: 4 compile threads under Wine (XCL_DXC_THREADS to choose)andprecompiling … (4 compile threads; …).XCL_DXC_THREADS=4on a stacked tree (main+ #684, #871, #433, #1692), not this branch.Regression run
The two blocks are @JoaoPauluu's (comment): RTX 3060 12 GB under Proton Experimental 11.0 with #257's vkd3d-proton patch,
scripts/linux/smoke.sh(#257), retail title for 60 s, no input. A secondmainrun gave 1370 frames. I can't make a clean pair here: on this RDNA4 / Wine 11.22 machine,mainstops at start-up without #871 (0x80000003at+0x2478b7bafter anE_INVALIDARG, 2.7 s in; reported on #871).main:
this PR:
Under Wine
peak commitreads 0 MB, so these blocks do not check memory.Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-25T06:12:12Z.
A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with
main(1356 here; 1368 and 1370 on the twomainruns). The cap is reached: the log hasDXC: 4 compile threads under Wine (XCL_DXC_THREADS to choose)at 3.95 s. The new testwine_caps_the_default_compile_threadspasses under Wine.Tested
x86_64-pc-windows-gnu.0e84e74as it is (based on6020a33) andmain6e1e2be, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Runs in order: main, this PR (with other PRs in between), main.Regression run
main (first run):
this PR:
The second
mainrun: 1370 frames,exit: 0x0, no device removal, no crash. Under Wine,peak commitreads 0 MB, so these blocks do not check memory.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T06:32:31Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by voiceovarian1-max on 2026-11-25T08:07:26Z.
Data for "Not tested: Proton's Wine, NVIDIA": with
XCL_DXC_THREADS=4a retail title's world load no longer runs this 31 GB machine out of memory (3 of 3 runs; default: 0 of 10). Here the gain is not DXC: the pipeline workers take the same count.Not this branch:
XCL_DXC_THREADS=4on a local stack (main9e3831e+ #1315/#1316 + #867 + #871 + #877 + #1321 + #684 + #640 + #605 + #495 + #1420 + #1368's line). Of the ten default runs, two were onmain930e8b4+ #867 + #871 + #877 and the same five PRs, the others on that stack with or without its last two items.Setup: RTX 4070 Ti 12 GB (NVIDIA 620.73.04, 32-lane waves), i7-14700K (28 threads), 31 GB RAM, CachyOS kernel 7.3.5, Proton Experimental's Wine (wine-11.0), vkd3d-proton v3.1 +
scripts/linux/vkd3d-proton-xcl.patch. Release,x86_64-pc-windows-gnu. Retail 1.0.2.1,XCL_PSO_WAIT_MS=10 XCL_COHERENT_MB=1024 XCL_PAGE_BUDGET_MB=4096. The DXIL of every compute program the title uses was already on disk (--precompile), so DXC hardly ran in these runs. A script ends a run when the system has under 3.5–4 GB available.pso_asyncstartscompile_threads()workers (xcl-pso-N) beside the 4 preload workers, so the cap also bounds how many pipelines are in the driver at once:XCL_DXC_THREADS=4(4 + 4 workers)What the default run does at world load (
XCL_THREAD_DUMP_AT, and the process's anonymous mappings every 5 s):The new mappings are 64 MiB
rw-pones at0x7f…: glibc arena heaps, i.e. native allocations of the driver's compiler, one pile per worker. XCL's own counters (target pages, arenas, sparse pools) stay flat through it.MALLOC_ARENA_MAX=4with the default workers does not help (guard at 125 s).With 4 workers the runs end later for other reasons: the title's watchdog at 165 and 195 s (Series X, as in #505), an access violation in the title at 130 s (Series S).
So on NVIDIA under Wine the cap this PR adds also does what #214 aims at. The memory figures may interest #1566 as well; I will put the heap-side numbers there.
Not tested: this branch's head, plain Wine, AMD, a count between 4 and 28.
AI use: Claude Code (Claude Fable 5.2) ran the runs and wrote this report; posted with the account owner's approval.
Imported from ivall/xcl. Originally posted by GreemSC on 2026-11-26T08:17:16Z.
AMD + Wine data for the memory side of this PR (complements @voiceovarian1-max's NVIDIA numbers above): with
XCL_DXC_THREADS=4the retail title's anonymous memory at 240 s was 2–3 GB lower than with the default (19 here), the driver's native arenas stayed under ~1 GB, and frame pacing was better. Same reach.Tested
mainb49be18+ a Wine stack (#1732 with #867/#871/#877, #684, #1860, #2097, #2404, #2615, #2598, #751 and diagnostics), exe unchanged between the two sides; onlyXCL_DXC_THREADSdiffers.XCL_DIRECT_DXIL=1, A pressed every 4 s from 22 s; smaps snapshots at 120 and 240 s. Default: 4 runs;XCL_DXC_THREADS=4: 2 runs.XCL_DXC_THREADS=4, 2 runsrw-pblocks at0x7f…, the same glibc-arena shape voiceovarian1-max describes; a fifth run with the default worker count (and one compute program refused withXCL_REFUSE_CS) reached 5.0 GB of them at 240 s.MALLOC_ARENA_MAX=2did not help here either (an earlier run on an older tree).Not tested: this branch's head (the cap through its default rather than the variable), more than 2 runs with the cap, counts other than 4 and 19, Windows.
AI use: Claude Code (Claude Opus 5.5) ran the runs, read the smaps and wrote this report.
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-27T12:51:43Z.
Independent test report under Wine/Proton (not native Windows) for head
0e84e740.Setup
experimental-11.0-20261112, vkd3d-proton masterec207194with a local patch dropping thelpVtblchecks ind3d12_command_allocator_from_iface/d3d12_command_list_from_iface, DXC1.9.2609.5, Rust 1.96.0,x86_64-pc-windows-gnumain83b00818, test commitedbadca9Tests (debug,
XCL_REQUIRE_GPU=wave64,--test-threads=1)gpu::recomp::dxc::: 21 passed, 0 failed (main: 20 passed, 0 failed)cargo test --workspace --no-fail-fast -- --test-threads=4, lib binary: 1322 passed, 8 failed, 27 ignored (mainthe same run: 1320 passed, 9 failed, 27 ignored). The failures are all amongmain's (f32/f64 GPU programs, FMA contraction, DXIL fuzz 2, UAV clear values, sparse tile recommit, Opus/XMA2 voices).tests/d3d12_resource_and_sync.rsaborts on both trees.DXC: 4 compile threads under Wine (XCL_DXC_THREADS to choose).Retail title, cold shader cache (release; the warm-cache snapshot with XCL's DXIL cache emptied, Mesa/vkd3d caches kept;
XCL_DIRECT_DXIL=1 XCL_PREPARE=1 XCL_PREPARE_WORKERS=2 XCL_PREPARE_GRAPHICS=0 XCL_PSO_PRELOAD=1 XCL_PSO_WAIT_MS=50 XCL_TEXTURE_LEVEL_PAGES=1 XCL_COHERENT_MB=1024 VKD3D_CONFIG=ignore_shared_fence; two 20-minute runs back to back per tree, the second on the first one's cache)main(default: 11 DXC threads here)Not tested
AI use
Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T19:41:04Z.
merge-check claim
head:
0e84e74063Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T19:47:47Z.
merge-check
base:
ff0c364b3dhead:
0e84e74063merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, run earlier today on the same commit: 2888 passed, 1 failed, 51 ignored, 28 SKIPPED lines; its one failure,
hle::d3d12x::pso_async::used_tests::emission_resolves_the_retained_recipe_after_title_address_reuse, passed here and in ten other merged runs today, so it is intermittent on the base. The new testwine_caps_the_default_compile_threadspassed.review: no blocking finding; one file, every hunk read.
compile_threadskeeps every core but one on Windows and takes at most 4 under Wine whenXCL_DXC_THREADSis unset; a setXCL_DXC_THREADSwins in both cases, the clamp to 1..64 is unchanged, and the choice is logged once under Wine. On Windows the result is the same expression as before (default_compile_threads(cores, false)iscores - 1). Not tested here: Wine itself. This machine is Windows, so the capped branch ran only in the unit test, and the throughput figures in the comment (Wine 11.22, 32-thread Ryzen) are the author's.performance: none on Windows. Under Wine: fewer DXC threads by default, which the author measured as faster there; not measured here.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T20:00:05Z.
merge-check claim
head:
0e84e74063Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T20:05:14Z.
merge-check
base:
ff0c364b3dhead:
0e84e74063merge: clean (trial merge 9ee351babf1ade0e0b896ad69df77464e32c4190; git diff --check clean; +39/-1 in crates/xcl/src/gpu/recomp/dxc.rs)
build: cargo build --workspace -> ok (39 lib + 19 test warnings, all pre-existing; none from the changed lines)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 0 failed, 51 ignored (base
ff0c364bis 2889 + 1 new test). SKIPPED: 27, the standard set for this card. The new wine_caps_the_default_compile_threads passes in the targeted run and inside the full suite. This machine is native Windows, so the run exercises the unchanged path end to end; the Wine branch is covered by the unit test plus the thread's Wine/Proton reports.review: no blocking finding; one file, every hunk read. compile_threads (dxc.rs:758) keeps XCL_DXC_THREADS in charge when it is set and parses (on both platforms); an unparseable value still falls through to the default, as before. The 1..=64 clamp is unchanged. With the variable unset, native Windows gets default_compile_threads(cores, false) = cores - 1, the identical expression to the old code path; under Wine (the existing util::under_wine, a OnceLock over ntdll's wine_get_version export) the default is at most 4, and one xlog_info line is printed only when the cap actually lowers the count (n < cores - 1) - the exact line quoted in the thread's Wine reports. I traced the other call sites: the cap propagates to the pools derived from compile_threads (the xcl-pso-N pipeline workers in pso_async, the (count/4).clamp(2,4) slot counts, the 8*count backlogs), so under Wine it also bounds how many pipelines are in the driver at once - which the thread's memory data says is where the benefit is. Windows behavior is untouched, so on native Windows this PR is a no-op at run time. The new test covers the pure function directly (32 non-Wine -> 31, 32 Wine -> 4, 4 cores Wine -> 3, 1 core -> 0 then clamped to 1 by the caller); all four assertions check out against the function, and no Wine environment is needed to run it. This machine is native Windows, so my suite exercises the unchanged path; the Wine branch rides on the unit test plus the thread's data - four independent Wine/Proton reports: JoaoPauluu's retail smoke with the cap-reached log line and the test passing under Wine, voiceovarian1-max's NVIDIA runs where the default worker count ran the machine out of memory at world load 10 of 10 and the cap survived 3 of 3, GreemSC's AMD data (2-3 GB less anonymous memory, better pacing), and ClosetPie107's independent Wine run (dxc module 21/21, full-suite failures identical to main's set). The one opposing data point, noted in the thread: on a 12-thread CPU a cold-cache preparation was ~12-34 % slower with the cap and no memory pressure on either tree - the measured trade-off the author discusses, and XCL_DXC_THREADS remains the override. Dupe: no #1607 group names this PR; the related open PRs change different knobs (#3336 worker priority, #3462 documenting XCL_DXC_THREADS in the README, #2950 an adaptive memory budget).
performance: none on native Windows (identical expression). Under Wine the DXC worker pool and the pipeline pools derived from it shrink to at most 4, which is the point of the change: the author's doc comment cites 32-thread Wine 11.22 throughput peaking at 2-4 threads (11.8 MB/120 s with 1, 19.5 with 2 and 4, 17.8 with 8, 12.8 with 16), and the thread's runs show the memory and pacing gains; the known cost is slower cold-cache preparation on lower-core machines.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:26:07Z.
Triage (#1607) – head
0e84e74No other open PR caps the default number of DXC threads under Wine, and main's
compile_threadsis unchanged. The change uses the existingutil::under_wineand leavesXCL_DXC_THREADSin control.No problems found in the diff.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-12-02T21:42:28Z.
merge-check
base:
5ad98adbc3head:
0e84e74063merge: clean (merge commit 40f8c107c582fc0a49e3f8b48a7bc47e1d5956da;
git diff --checkclean)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3006 passed, 0 failed, 52 ignored; SKIPPED: 24 (22 no wave64, 2 no heap windows); failing: none
title run: Newer Retail Game, release build of this merge, Series S settings (
XCL_DEVICE_TYPE=lockhart,XCL_COHERENT_MB=512,XCL_UMA_WINDOWS=16,XCL_SPARSE_LAZY=1), scripted A presses, 240 s planned: into the world at 78 s, 40 s there with 69 frames presented, no crash, no device removal; then our RAM guard stopped it (free RAM under 1 GB on this 32 GB PC, as in main's second run).review: none. The change applies under Wine only; this Windows run does not reach it.
performance: none on Windows. World frame rate not compared: on this 32 GB PC the runs of main and of the PRs end 30 to 150 s into the world (RAM guard or time limit).
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (driver 617.42), Ryzen 7 9800X3D, 32 GB, Windows 11 Pro 26300 / Claude Code with Claude Opus 5.5
Same settings on main
5ad98adb, two runs: into the world at 94 s with 145 s there and no frame presented (ran to the 240 s limit); into the world at 80 s with 59 s there and 90 frames, then stopped by our RAM guard (free RAM under 1 GB). "In the world" here means the first 2 s window of the activity log with 5,000+ draws and dispatches.AI use: Claude Code (Claude Opus 5.5) ran the build, tests and title runs and wrote this; a Claude Sonnet subagent read the diff and I checked its points.
~Tiago
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.