Shaders: reuse the file buffer when loading unsplit cache entries #2584
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2594"
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 storrmzz on 2026-11-26T01:01:52Z.
Loading a translated shader cache entry currently allocates a second payload-sized buffer after reading the file. Reuse the validated file buffer for entries without split pieces; split entries retain their existing allocation and validation behavior.
What is in it
pso.rs, with ownership/round-trip and malformed-entry tests; document it in README.Tested
Ryzen 7 8840HS, Radeon 780M (32.0.31033.3), Windows 11 Pro 26300, Rust 1.100.0; debug workspace, optimized standalone benchmark.
cargo build --workspace --jobs 2: passed.cargo test --workspace --no-fail-fast --jobs 2 -- --test-threads=4 --nocapture: 1436 passed, 1 failed, 47 ignored; 11 SKIPPED subcases (six unsupported f16/conversion cases, one driver-cache test requiring Developer Mode, three missing-debug-layer cases, one unavailable heap-window case).The sole failure is
gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, seed 722; reproduced before this optimization on base08db802. No test was disabled to conceal it. The final branch is based onb49be18.Buffer-ownership test fails before the optimization and passes after it. The standalone old/new loader comparison agrees on 2,664 valid/malformed inputs.
Two warm-file-cache runs of the extracted production loader (including validation), synthetic structurally valid containers,
rustc -O, alternating order, nine-round medians: 4-16 MiB entries loaded 27-35% faster, with approximately half the incremental heap peak. This does not measure game loading or FPS.Independent report by mokkamokacaffe, exact PR head versus
b49be183: GTX 1060 6GB (582.66), i7-6700, Windows 10 Pro 19045.7846, Rust 1.100.0 MSVC. Debug and release builds passed. Full workspace with--no-fail-fast -- --test-threads=4: PR 1,434 passed / 3 failed / 47 ignored; main 1,432 passed / 3 failed / 47 ignored; 359 explicit SKIPPED messages on each. All three failures reproduced on main with matching errors.Independent report by tiagonleal, exact PR head:
cargo test -p xcl --lib translated_cache -- --nocapture --test-threads=1: 6 passed / 0 failed / 0 ignored.cargo test -p xcl --lib gpu::recomp::pso -- --nocapture --test-threads=4: 29 passed / 0 failed / 1 ignored, no SKIPPED lines. Hardware and paired retail smoke below. These are contributor-reported results, separate from the author's local tests above.Regression run
Paired runs reported by tiagonleal on 2026-11-26. Both commits built separately in clean detached worktrees, release; same title
9cc6a39e, 60 seconds each, main first, default settings. RTX 5070 Ti 16 GB (32.0.16.1742), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 MSVC; NVIDIA xcl.exe shader-heap profile 1024 MB. Reported command:scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e. Neither tested revision includes the later #2555 startup preparation step.Main (
b49be183):PR head (
ae921b40):Original result blocks copied unchanged from the linked contributor report. One run per revision, no world load; the 102-frame difference is not evidence of a performance improvement.
Not tested
AI use
This PR was created with AI assistance from OpenAI Codex (gpt-6-astra).
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T01:13:24Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-26T13:25:15Z.
Reviewed exact head
ae921b40fc1f4253ef186aeab389247bbf4302c3againstmainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7. I found no logic issue requiring a code change.rest.is_empty()proves the validated DXIL payload reaches the end of the file buffer;b.len() - lentherefore identifies its start.copy_withinandtruncatedo not reallocate, which is pinned by the pointer/capacity regression.git diff --check origin/main...ae921b40passed.The same change appears in mega-PR #2778 as
355826c5, whose commit message says it was adapted from #2594. #2594 should remain the focused source of truth rather than being duplicated through #2787.Not tested
AI use
Imported from ivall/xcl. Originally posted by mokkamokacaffe on 2026-11-26T14:00:36Z.
Tested
ae921b40fc1f4253ef186aeab389247bbf4302c3and upstreammainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7.cargo test --workspace -- --test-threads=4stopped after the library suite with 1,308 passed, 3 failed, 27 ignored, and 349 explicitSKIPPEDmessages.--no-fail-fastand four test threads, the PR finished with 1,434 passed, 3 failed, and 47 ignored.mainfinished with 1,432 passed, 3 failed, and 47 ignored. Both logged 359 explicitSKIPPEDmessages. All three PR failures reproduced onmainwith matching errors.Regression run
Both release builds completed from clean worktrees. The smoke runs were blocked because no locally owned unpacked title was available. No
xcl-smokeblocks were generated.Not tested
AI use
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-26T15:07:29Z.
Paired 60 s smoke on RTX 5070 Ti (Windows 11):
ae921b40andmainb49be183both reach 60 presents per 2 s, 0 removals, 0 crashes; the PR's cache tests passTested
ae921b40fc1f4253ef186aeab389247bbf4302c3(still the head, PR open, no smoke posted before this one). Baseb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7= currentmainand the merge-base. Both built as is, release, in clean detached worktrees; no earlier build was reused.scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e, default settings, one run each, base first. Neither tree has the shader preparation step that #2555 added later.cargo test -p xcl --lib translated_cache -- --nocapture --test-threads=1: 6 passed, 0 failed, 0 ignored, includingtranslated_cache_reuses_unsplit_read_bufferandtranslated_cache_buffer_decode_preserves_validation_and_split_entries.cargo test -p xcl --lib gpu::recomp::pso -- --nocapture --test-threads=4(the module the PR touches): 29 passed, 0 failed, 1 ignored (compile_time_bench::repeated_pso_shader_compile), no SKIPPED lines.Not tested
AI use
Imported from ivall/xcl. Originally posted by storrmzz on 2026-11-28T11:11:52Z.
Hi @bmjask and @Prime1997 !
I noticed that commit
3ceadfbincorporates the implementation, tests, and README changes from my PR #2594, with a small adjustment to preserve the cache I/O timing. Thanks for integrating it and referencing my PR!However, I noticed that my GitHub account (storrmzz) isn't credited as an author or co-author on the commit. Could we find a way to preserve that attribution so GitHub recognizes my contribution too?
Also, should I close #2594 as incorporated elsewhere, or would you prefer to handle it differently? Thanks!
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:26:36Z.
Triage (#1607) – head
ae921b4Main already has this change. Commit
3ceadfb("Shaders: reuse unsplit cache file buffers", merged with #2959) addstranslated::decode_entryin pso.rs, which reuses the file buffer for unsplit entries with the samecopy_within/truncate. It also has the testtranslated_cache_reuses_unsplit_read_bufferand the same README sentence.Recommendation: close (superseded by main commit
3ceadfb).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 throny on 2026-12-01T12:55:02Z.
Closing as superseded: this change is already on
main(3ceadfb). main pso.rs translated::decode_entry reuses the file buffer, test translated_cache_reuses_unsplit_read_buffer exists (3ceadfb, #2959); PR added lines present except 2 adapted linesTwo independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed