DirectStorage: inflate zlib requests with zlib-rs #1712
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1722"
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 gbuyssens on 2026-11-24T19:54:40Z.
DirectStorage's zlib stage decodes with zlib-rs instead of miniz_oxide. Titles stream thousands of 64 KiB zlib blocks at start-up (the retail title I test: ~9 800 file requests in its first load, ~650 MB inflated), and zlib-rs decodes them about twice as fast. The behaviour does not change. Related: #661 speeds up only miniz_oxide's Adler-32 (5.7 %); this replaces the decoder in this path, so #661 would no longer matter for DirectStorage.
What is in it
crates/xcl/src/hle/dstorage.rs:inflate_zlib(src, limit)wrapszlib_rs::inflate::uncompress_slicewith the same rules as the miniz call it replaces (output limited to the destination or intermediate size, E_ZLIB_DATA on a wrong Adler-32, a cut stream or more output than the limit, a shorter stream returned as is for BCPack's lenient case, bytes after the stream's end ignored), plus a unit test of each rule.crates/xcl/Cargo.toml,Cargo.lock:zlib-rs0.5.5 (Zlib licence, pure Rust, no dependencies). The other miniz_oxide uses (shader packs, PNG, tests) are left as they are.Tested
RTX 3060 (driver 32.0.16.2101), i5-9600K, 32 GB, Windows 11 Pro 26300, Rust 1.98.0 MSVC; debug for the suite, release for timing and the title.
cargo test --workspace --no-fail-fast -- --test-threads=4: 859 passed, 0 failed, 42 ignored (mainc160d86: 858 / 0 / 42; the one more is the new test). SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).Decode speed, release, 64 KiB blocks compressed at level 6, 20 passes × 3 rounds, all outputs checked against the input:
xcl.exe(38 % ratio)The same harness checked the edge cases on all decoders: trailing padding, bad Adler-32, a limit one byte short, a limit larger than the stream.
Retail title,
scripts/smoke.ps1 -Seconds 90, release builds, mainc160d86and this PR alternating, 9 runs after a warm-up: no crash or device removal in any run. On this title the start-up is not bound by inflate: in the runs that started fast, the first 9 000 requests completed at 12.3 / 12.9 s (main) and 13.0 / 11.9 s (PR). The title also has a slow start-up mode in both builds (first PresentX at 15–31 s instead of ~4 s), which makes frames and peak commit follow how far the title got rather than the build.Regression run
main (run 1, back to back with the PR's run 1):
PR:
Not tested
Ruled out: libdeflate decoded the same blocks faster (540–685 MB/s), but its Rust binding (
libdeflater) is Apache-2.0 only, which GPL-2.0 does not allow. Decoding with miniz_oxide into an exact-size buffer instead of a growing Vec gave nothing measurable (181–274 MB/s).AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T22:28:51Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.Thanks!
Imported from ivall/xcl. Originally posted by humsterbumster on 2026-11-25T01:32:19Z.
Independent test report from a Linux/NVIDIA machine (this is a test report, not a code PR).
Tested (patch applied with
git cherry-pick -n e51814eontomainaa9ab8a: no conflicts;zlib-rs 0.5.5resolved from crates.io):cargo build --workspace --release --target x86_64-pc-windows-gnu(Rust 1.100.0): OK,xcl.exebuilt.cargo test -p xcl --lib --target x86_64-pc-windows-gnu --no-run, then the lib test binary under Proton 11 Wine (RTX 5090, NVIDIA 620.73.04): 125 tests printedok, 0FAILED, then the binary exits 3 mid-run ingpu::dxil::ops_tests— the same exit this machine's main builds show (batch logs: 19 binaries, 15x rc=0, 3x rc=101, 1x rc=3), so no new failure.main— menus at 60 presents per 2 s (30 fps), same log lines, no new warnings from the zlib path.Not tested: Windows-native run, BCPack/BC7 paths (unchanged by this PR), and a long streaming soak.
A caveat on the retail numbers: this machine's copy of the title's
shaders.rpfcurrently fails the torrent's own SHA-1 on two pieces, so 49 DirectStorage zlib requests fail with0x89240032(E_ZLIB_DATA) at the same file offsets withminiz_oxideand withzlib-rs. That is corrupt local data, not this PR: the block at one of those offsets inflates to 62,588 B and then reports a truncated/Adler-invalid stream. I will re-run a clean retail streaming pass once the package verifies.AI use: omp (DeepSeek V4.1 Flash 1017) ran the build, the test binary and the retail run and wrote this report.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:35:31Z.
Triage (#1607) – head
e51814eNo open or merged PR swaps the zlib inflater. #3325 parallelizes zlib requests and #661 (merged) sped up the checksums; neither changes the inflater.
zlib-rsis Zlib-licensed, which is compatible with GPL-3.0. The new dependency needs the reason given in the PR description (the speedup claimed in the doc comment is not measured in the diff).inflate_zlibzero-fills alimit-sized buffer for every request, even when the stream is shorter.miniz_oxide's_with_limitgrows its buffer as needed instead.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.