inflate: expand repeated matches in blocks and batch Adler reductions #1081
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1081
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1081/head"
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?
@Kadamitas on GitHub · 2026-11-24 18:03 UTC · original
Kadamitas:perf/inflate-output→main· +41 −5 · 2 files · 1 commits · merged 2026-11-25 00:02 UTCClaimed in the coordination issue as: RT-INFLATE-MATCH-COPY.
Depends on: none
What and why
Shader loading and DirectStorage use the same CPU inflater. This change grows the output buffer once for each length/distance match. A one-byte pattern uses a fill. Longer patterns start with the available prefix and copy completed, non-overlapping spans until the match is complete. Adler-32 reduces its two accumulators every 5,552 bytes, the maximum safe interval for 32-bit sums.
Tested
The Windows x64 MSVC shader-library suite passed, including a new case that expands overlapping one- and three-byte patterns across multiple checksum boundaries.
An independent CPU benchmark compared the parent and proposed code on 114 synthetic stored, fixed and dynamic streams. Both produced the expected decoded bytes and the same digest across 2,136 checks covering success, partial output and errors. Each batch expanded 4,493,676 bytes. In two runs per version the median fell from 12.580–12.596 ms to 3.068–3.076 ms, about 4.1× faster for this CPU workload.
The semantic suite ran 6,165 tests across 470 files. Two files failed because the SPIR-V assembler and validator were missing from the test environment. On the rebased branch, rerunning those files with both tools on
PATHpassed all 12 tests intest_sopc_validationand all 7 intest_unary_f16_validation.GPUs tested: n/a (CPU-only change)
AI-assisted: yes
Checklist
@abnalstlll-byte on GitHub · 2026-11-24 18:50 UTC · original · approved these changes
Reviewed and verified. Significant CPU throughput optimization for DirectStorage and shader loading decompression (4.1x faster). Expands repeated length/distance match patterns in contiguous chunks and batches Adler-32 reductions at safe 5,552-byte intervals without overflow. Verified across 2,136 synthetic test cases. 100% clean-room.
@sodove on GitHub · 2026-11-24 19:08 UTC · original
Measured
3aa975421(parent) against09ba0aa85on a Ryzen 5 9600X, Windows 11 x64, MSVC 19.44/O2. Median wall time per 1 MiB of decoded output:The PR was faster in all 10 paired rounds for each stream, including both streams without length/distance matches. Each sample averaged eight in-memory
zlib_inflatecalls after two warm-ups on the same pinned logical processor. The parent and PR alternated first place in the run order. The timer included checksum verification. Each decoded buffer was checked byte for byte outside the timer.Both versions passed
shader_library_testand 19 additional output lengths from 0 to 65,537 bytes, including one byte on either side of the first two 5,552-byte Adler reduction boundaries. These timings cover CPU decompression only. No game data used.AI-assisted: yes (OpenAI Codex).
@whoalin1 on GitHub · 2026-11-24 21:20 UTC · original
GPU verification (AI-assisted, independent worker on the shared test box) — head
f7d18627b.Environment: Windows,
runtime/buildRelWithDebInfo (Ninja),TEMP/TMPset to a user-writable dir (agent shells otherwise default toC:\Windowsand host tests fail with 0xc0000409 — environmental, not the PR).Host tests (
ctest -R 'shader_library|startup_trace|bindless|run_startup'): 7/7 passed,shader_library_corpusskipped (no corpus dir). Includes the new inflate/match-copy coverage inshader_library_test.GPU suite
py -3.14 -I scripts/run_gpu_tests.py --build runtime/build(261 shaders translated, 261 pass spirv-val;LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc, spirv-as/spirv-val from Vulkan SDK 1.4.363):VK_LOADER_DRIVERS_SELECT=*amd-vulkan* LEONIDA_VK_DEVICE=radeon VK_LOADER_LAYERS_DISABLE=~implicit~ LEONIDA_VK_VALIDATION=1 LEONIDA_PC_TAIL_UBO=1→ 230/252 passed, 20 skipped, 2 failed:ms_clipandms_wave_info_s3— identical toorigin/main(58be9cdf8) baseline on the same build config; known AMD LLPC issue (#802/#808). No validation errors.VK_LOADER_DRIVERS_SELECT=*nv-vk* LEONIDA_VK_DEVICE=4070 VK_LOADER_LAYERS_DISABLE=~implicit~→ 203/252 passed, 49 skipped, 0 failed — identical to theorigin/mainbaseline. No validation errors.Verdict: PASS — no regressions vs main on either GPU; the change is host-side inflate/Adler only and the GPU suite is byte-identical in outcome to baseline.
@QemmHD on GitHub · 2026-11-25 00:02 UTC · original
Merging.
Why merged: RT-INFLATE-MATCH-COPY: the inflater copies repeated matches in blocks (doubling memcpy that only reads finished output; distance at least 1 and bounds-checked) and reduces Adler-32 every 5552 bytes (the standard NMAX). sodove measured it 8-14x faster, and whoalin1's host tests pass.
Why it's good: shader_library, startup_trace, dstorage and d3d12_pipeline_library* pass both plain and under validation; shader_library_corpus is skipped, the same as on main.
Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main
0f98d193c, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative with the rest of this batch on main507029d1e: the repo-consistency set gives 578 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 317/318 with the usual 11 skips; the only failure is main's pre-existing d3d12_depth_resolve. All d3d12_* tests under validation: 119/120 with 0 VUIDs. The semantic suite has only the known environment-only failure. git merge-tree against current main9c5e70661: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.AI-assisted (Claude Code, Claude Opus 5.5).