Shaders: split compute pieces share one pool of piece builders #2931
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2931
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2931"
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?
@KOLESNiii on GitHub · 2026-11-27 00:44 UTC · original
KOLESNiii:shaders-piece-queue→main· +188 −5 · 1 files · 1 commits · draft--pipelinesand startup shader preparation start a fresh group of up toXCL_PIPELINE_THREADShelper threads for every split compute program. All the groups wait at the same 4-slotrunninggate. With 17 shader workers on four-piece programs, that is 68 helpers for 4 driver slots. Each helper also reads its piece's driver blob (driver_cache::load, a fullfs::read) before the gate, so on a warm run every waiting helper holds a blob in memory.This PR starts
XCL_PIPELINE_THREADSpiece builders once perprecompile, and the pieces of every split program go through them. The native-create limit is unchanged, and at mostXCL_PIPELINE_THREADSpieces have read their blob at a time. A program's worker still waits for its own pieces, so progress reporting and the summary counters behave as before.Part of #2880. Whether the old scheme costs anything measurable is the open question in #2880, and this PR is mainly there so it can be measured A/B against
main. If it only changes thread counts, it may not be worth merging.What is in it
crates/xcl/src/shaders.rs:PieceQueue/PieceJob,Pipelines::{queue_pieces, build_pieces, open_pieces, close_pieces};precompilestarts the builders and closes the queue once its shader workers have returned.makecalled outsideprecompile(tests) keeps its own per-program helpers.split_programs_share_the_piece_builders: four three-piece programs on two builders. Every piece is cached whenmakereturns, the queue drains, the builders exit and the gate count returns to 0.Testing wanted: please post baseline figures, not only the smoke run
The standard smoke run is useful as a regression check, but it doesn't reach what this PR changes. What's needed is the profile from the #2880 comment, run on
mainand on this PR's head with everything else held constant:XCL_SPLIT_WAVE64=1). Give the GPU, driver, CPU and RAM.XCL_DXC_THREADS(same value throughout, e.g. 15),XCL_PIPELINE_THREADS=4, defaultXCL_PIPELINE_MAX_KB, a dedicatedXCL_DXIL_CACHE, a release build.xcl shaders <pack> --precompile --only cs --pipelines, on a pack whosesplit compute programs: N (M pieces)line shows at least a few hundred pieces.%XCL_DXIL_CACHE%\driverand the driver's shader cache (NVIDIA\DXCache/D3DSCache) deleted before each runXCL_DXIL_CACHEtime … sline; thepipelines made / refused / loaded from the driver cacheandsplit compute programslines; peak live threads and total threads created (WPR, or a ≤10 ms sampler; sampled peaks miss short-lived helpers); process peak commit (PeakPagefileUsage, or a ≤50 msPrivateMemorySize64sampler).%XCL_DXIL_CACHE%\driverand the same made / refused / reused counts on both builds.Tested
cargo build -p xclandcargo test -p xcl --lib --no-runbuild with no new warnings.shaders::tests and the whole suite) are waiting in this machine's exclusive-run queue. Their counts will be added here; nothing has been run on a GPU yet.Regression run
scripts/smoke.ps1onmainand on this head, to be added when they have runNot tested
xcl runwith a split-heavy titleAI use
🤖 Generated with Claude Code
@ettehn on GitHub · 2026-11-27 00:50 UTC · original
Paired offline benchmark for #2880 on RTX 5070 Ti Laptop 12 GiB (621.24), Ryzen 9 8945HX, 31.8 GiB usable RAM, Windows 11 26200.9974, Rust 1.97.1 MSVC, DXC/DXIL 1.8.2502.11. Clean release builds of
8b957bec6f82495aec940944c6bf47faa02db590and093a5fcdc2d8db1358c78e0074567960e1e1560e.Synthetic RPF9 with 160 variants of the existing wave32 split compute fixture.
xcl shaders <pack> --precompile --only cs --pipelines --windows 1,XCL_DIRECT_DXIL=1,XCL_DIRECT_SPLIT_INSTRUCTIONS=12,XCL_DXC_THREADS=15,XCL_PIPELINE_THREADS=4, default size cap. Three cold/warm pairs per build, interleaved base/head/head/base/base/head. Each pair started with an identical copy of the translation cache and an empty XCLdriverfolder. I left the NVIDIA system cache in place, so the XCL-cold rows are not a driver-cold comparison.Thread snapshots: median interval 4.17–4.57 ms across runs, maximum 5.95 ms. IDs seen are a lower bound, not an ETW thread-create total. Peak commit is the Windows
PeakPagefileUsagecounter. All 12 runs made 800 pieces, refused 0, and ended with the identical set of 800.psofilenames. XCL reported 0 cache loads on the first run of each pair and 800 on the warm run. The first base XCL-cold run was an outlier at 5.669 s and 278.62 MiB, so I would not infer a cold-time change from this setup. The repeatable difference is thread count, with warm wall time slightly higher on this short fixture. A retail title, a cold NVIDIA cache and full workspace tests were outside this run. OpenAI Codex (6.2sol) assisted with verification.@KOLESNiii on GitHub · 2026-11-27 01:25 UTC · original
Thank you @ettehn, a paired, interleaved A/B with matched cache states is exactly what this needed. I've written up what it shows, together with the two runs on #2880, in this comment. In short: thread starts per pass go from about 640 to 4 and peak commit drops about 10 MiB, consistent with thread stacks. Cold time doesn't change, because the 4-slot gate is the limit. The small warm slowdown may come from this PR dropping the blob read-ahead that the waiting helpers gave
main. I'll try a2 × XCL_PIPELINE_THREADSbuilder variant to check that.AI use: Claude Code (Claude Opus 5.5) drafted this comment.
@SzczepanGrela on GitHub · 2026-11-27 02:57 UTC · original
AMD/RADV/Wine functional coverage at
093a5fcd. The requested performance comparison remains unmeasured here.Tested
093a5fcdc2d8db1358c78e0074567960e1e1560eand main8b957bec6f82495aec940944c6bf47faa02db590, Windows GNU release executables. Separate source copies with local test-only observations/profile fixture; original assertions unchanged.26.3.1-arch3.5; Ryzen 7 7700, CachyOS7.3.0-5-cachyos. GE-Proton11-12 / Wine 11.0 Staging, native D3D12 through vkd3d-proton8293130ebe370b1+(local asserts-disabled build). Rust1.97.1, DXC/DXIL1.9.2602.17.cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run --message-format=json-render-diagnostics.pipeline_cap_tests --nocapture --test-threads=1, then--test-threads=4. Main: 3 passed, 0 failed each; head: 4 passed, 0 failed each. 0 ignored, 0 skipped.split_programs_share_the_piece_builderspasses at both thread counts: four programs, three distinct DXIL pieces each, two shared builders, twelve PSOs made, zero refused. Its original assertions confirm all piece blobs exist whenmakereturns, the queue drains, builders exit and the running gate returns to zero. This tests native PSO creation/cache completion, not execution of those twelve shaders. The existing stale-cap test's separate GPU dispatch returns word 0 = 42 on both sources.A local precompile pilot with four owned guarded-add programs produced 28 SDK-validated wave32 DXIL pieces. With matched warm translation caches, empty private driver caches,
XCL_DXC_THREADS=15,XCL_PIPELINE_THREADS=4,XCL_DIRECT_DXIL=1,XCL_SPLIT_WAVE64=1and split limit 12, both main and head processes exited with code 5 before the pipeline counters/libtest summary or profile file. No root cause was established. The larger benchmark was not started, so there are no comparable timing, thread-count or peak-commit figures from this attempt.Not tested
The requested bulk cold/warm performance comparison, execution of the queued twelve-piece fixture, native Windows, other GPUs, the full suite, startup cancellation, retail workloads or
scripts/smoke.ps1. These results do not establish a performance or memory benefit.AI use
OpenAI Codex (GPT-6; exact serving variant not exposed) ran the comparisons, prepared the local test-only observations/pilot, independently checked sources and raw results, and drafted this report. Publication authorized by the account owner.
@luckyteagirl on GitHub · 2026-11-27 05:44 UTC · original · reviewed
If every piece builder panics, precompilation can hang before it reports the failure. The
Builtguard decrements the count only for the job that started. Jobs still queued keep their producer waiting inqueue_pieces, and the coordinator joins producers before closing the pool. I ran an isolated Windows harness with the exact queue methods and the same join order, using two builders and three jobs. The control completed. When the build stub panicked in both builders, the coordinator was still blocked after two seconds and I stopped the fixture. Could the pool wake its producers with a failure and shut down when a builder exits unexpectedly? Queue and builder loop · Shutdown orderThe regression test has a related teardown issue. It unwraps each producer's join result before closing the pool, so a failed assertion can leave the scoped threads waiting indefinitely. Collecting the join results and closing the pool before propagating errors would let that test report the assertion. Test teardown
AI use: OpenAI Codex (GPT-6.2 Sol) reviewed the source, ran the CPU-only fault-injection harness, and drafted this comment. No title, GPU, or full suite was run.
@JJAutoCompare on GitHub · 2026-11-27 11:03 UTC · original
Tested
Clean
093a5fcdc2d8db1358c78e0074567960e1e1560eon Windows 11 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC, DXC/DXIL 1.9.2602.17, debug. Built withcargo test --offline --locked -j 2 -p xcl --lib --test gpu_compute_e2e --no-run --message-format=json-render-diagnostics. Reran these synthetic groups withXCL_ADAPTER=A770and--test-threads=1 --nocapture:shaders::pipeline_cap_tests::split_programs_share_the_piece_builders(1 pass). Four callers shared two spawned and joined builders. All 12 piece blobs were present on return, zero refused, and the queue and gate drained.offline_split_compute_pipeline_is_reused_by_a_second_process(1 pass). A warm process reused the cached pieces. Corrupting one piece rebuilt that piece and preserved reuse of the others.gpu::dxil::module::split::tests::dispatch_chain_payload_(2 passes). Synthetic GPU readback agreed with the expected dispatch-chain order and payload.Four passed, zero failed, ignored, or skipped. Each group used the shared Arc mutex. The pinned executables matched before, under, and after the lock.
Not tested
Arc performance, peak native calls, cancellation and panic handling, the full workspace, and retail smoke.
AI use
T3 Code / Codex (
gpt-6.2-sol) ran the fixtures and independently reran the four checks above.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.