Shaders: move capture hashing off lock and offload xbox stats #1019
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1026"
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 rdj415 on 2026-11-24T10:28:04Z.
Move shader validation, in-place FNV-1a hashing, and container classification outside the global
STATElock ingpu::shader::capture, and offload non-dumpaccount_xboxFSSM decompression and RDNA2 instruction counting to a low-priority background worker flushed byshader::stats().A retail title submits 200k+ shader blobs across parallel loading threads while >98% are duplicates of ~3.6k-19k unique shaders (e.g. 204,736 submissions for 3,579 unique shaders in the first 60 s, 15.67M RDNA2 instructions). Previously
shader::captureheld the globalSTATEmutex acrossreadable(), heap-copying every duplicate into aVec<u8>,fnv64(), andclassify(), and then ranaccount_xbox()synchronously on the title's loading threads.What is in it
crates/xcl/src/gpu/shader.rs: runreadable()andfnv64()directly on the borrowed slice outsideSTATE, skip allocatingVec<u8>on duplicate hashes, avoidStringallocations on existing stage/kind keys, classify unique blobs outsideSTATE, and offload non-dumpaccount_xbox()to a low-priorityxcl-shader-statsworker thread with a bounded flush instats().crates/xcl/src/gpu/shader.rs: unit tests covering concurrent multi-thread deduplication, deterministic worker flush onstats(), and unreadable-pointer rejection.Tested
rustc 1.98.0-nightly (096694416 2026-06-29)(x86_64-pc-windows-msvc), Windows SDK DXC 1.8.2502.11 (10.0.26100.0).cargo test -p xcl --lib gpu::shader::tests: 7 passed, 0 failed, 0 ignored..\scripts\test.ps1(debug): 675 passed, 3 failed (pre-existing #718 cubemap reuse flakeplaced_title_textures_share_vram_and_preserve_pixels+ 2PoisonErrorcascades), 21 ignored; 2 GPU tests skipped (no wave64:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware). On a second lib run (cargo test --workspace --tests -- --test-threads=4), all 3 #718 tests passed (677 passed, 1 failed from pre-existing #913 OOM incross_queue_cycle_and_same_queue_fifo_do_not_deadlock, which passed in isolation: 1 passed, 0 failed).cargo test -p xcl --test '*' -- --test-threads=4(all integration tests includinge2e.rs): 41 passed, 0 failed, 20 ignored.scripts/smoke.ps1):report.jsonpreserved exactunique=3579,rdna2_instructions=15665903,xbox_hw_stages={"CS":2734,"PS":508,"VS":228}on bothmainand PR head, while frames shown increased from 500 to 694 in 60 s.Regression run
main:
PR:
Not tested
XCL_DUMP_SHADERS=1disk dump path (behavior unchanged, not exercised during smoke run).XCL_SAMPLE_*sample-data tests (environment variables unset).AI use
shader::capture, wrote the implementation, unit tests, commit message, and PR description; all builds, tests, and smoke runs were executed on the hardware named above.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T11:31:41Z.
Independent verification, merged onto current
main384f7f7locally (clean merge).Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.
cargo test -p xcl --lib shader: 27 passed, 0 failed, 2 ignored (bench + retail-sample tests) — includescapture_deduplicates_across_threads_and_flushes_xbox_statsandcapture_flushes_multiple_unique_console_shaders_from_worker, which exercise the new off-lock hashing/stats path.fnv64now runs on the borrowed slice before the copy, dedupseen.inserthappens under a short lock, and classification/unique accounting moved off it — the lock is no longer held acrossto_vec/classify.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
upstream-sync referenced this pull request2026-11-25 09:07:36 +00:00
Imported from ivall/xcl. Originally posted by throny on 2026-11-25T09:20:29Z.
Test report for exact head
870de7d.Tested
cargo build --workspace && cargo test --workspace -- --test-threads=4on870de7das it is (its own base): 719 passed, 0 failed, 41 ignored.SKIPPED: 2 lines (no wave64 on this adapter, and the like).scripts/smoke.ps1, the retail title, 60 s, release builds,main568e7dbfirst, then this head:main:
PR:
Not tested: AMD, the head merged onto current
main, a world load.AI use: Claude Code (Claude Opus 5.5) ran this and wrote the report; the diff was read for safety by a Claude Opus 5.5 sub-agent before it was built.
Imported from ivall/xcl. Originally posted by 4usphs on 2026-11-25T11:52:35Z.
AMD run on the exact head
870de7d(870de7ddbc), as pushed on its base077ce40(not merged onto currentmain), on two AMD adapters with native 64-lane waves: RDNA4 and the console's generation, RDNA2.Tested
XCL_TRANSLATED_CACHE=0; adapter picked withXCL_ADAPTER.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4:gfx1036), driver 32.0.21045.29003: 716 passed, 3 failed, 41 ignoredSKIPPEDtests on either adapter.capture_deduplicates_across_threads_and_flushes_xbox_stats,capture_flushes_multiple_unique_console_shaders_from_worker,capture_rejects_unreadable_pointer_without_polluting_seenrun and pass on both adapters.placed_title_textures_share_vram_and_preserve_pixelsat its cubemap reuse check,transitions_apply_when_their_list_is_submitted,d32s8_targets_take_their_own_size_of_video_memory): the intermittent failure of #718, which takes the other two with it (#673), not this PR. They pass on their own on this head.cargo test -p xcl --lib -- --test-threads=4on the base077ce40fails the same 3 on the iGPU (that run passed on the RX 9070 XT, so it is intermittent there too).Not tested
AI use
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-25T12:28:19Z.
Linux / AMD RDNA4 (RADV) test report for head
870de7dmerged locally ontomain1a0bbe3(clean merge).Environment
experimental-11.0-20261112), vkd3d-proton v3.1 (#257+dxil-spirv53aac418), DXVKv3.1.1-209, DXC1.9.2609.5,x86_64-pc-windows-gnucross-compileTested (debug test binary under Wine,
--test-threads=1 --nocapture)gpu::shader::tests: 7 passed, 0 failed, 0 ignored, 0 skipped (0.04 s), includingcapture_deduplicates_across_threads_and_flushes_xbox_stats,capture_flushes_multiple_unique_console_shaders_from_worker, andcapture_rejects_unreadable_pointer_without_polluting_seen.Not tested: full workspace suite, retail title run, native Windows.
AI use: T3 Code / Antigravity (Gemini 4 Neon) merged, built, ran the tests on this machine, and drafted this report.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T03:40:51Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:39:11Z.
Triage (#1607) – head
870de7dHalf of this is already on main: #3295 (
7d52779e) hashes and copies the shader outside the capture lock and counts per kind in a second short critical section. What remains here is the backgroundxcl-shader-statsworker foraccount_xbox, which no other PR adds. Please rebase down to that part.gpu/shader.rstests: they assert exact deltas of the globalsubmitted/by_stage["ps"]counters. Other lib tests that create pipelines throughnull.rsalso callshader::capturewithoutCAPTURE_TEST_LOCK, so the tests can fail at random when they run in parallel.If
account_xboxpanics, the worker thread dies and every laterstats()call waits the full 5 s flush timeout.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.