Repository navigation
Conversation
The main loop of the x86 inflate decoder copies a match 16 bytes at a time, so a match longer than 16 bytes takes a second store and a loop branch that is hard to predict. In the AVX2 decoder, decode_huffman_code_block_stateless_04, copy 32 bytes at a time with ymm registers, so most matches take one load, one store and no loop branch. The output slop of the main loop grows by 16 bytes to cover the longer stores. A match whose distance is less than 32 bytes and less than its length keeps going through small_byte_copy, which doubles the distance until it is at least the copy size. On GitHub-hosted runners with AMD Zen 3, Zen 4 and Zen 5 and Intel Ice Lake, Emerald Rapids and Granite Rapids CPUs, inflate gets 1.0% to 2.7% faster on the Silesia files compressed by zlib -6, and 0.7% to 1.9% faster on 64 KB pieces of them compressed at isa-l level 1. Signed-off-by: Parker Loflin <parker@cronstable.dev>
ptweezy
force-pushed
the
igzip-x86-inflate-copy32
branch
from
October 21, 2026 21:27
b579067 to
0fa3477
Compare
This was referenced Oct 21, 2026
ptweezy
marked this pull request as draft
October 21, 2026 22:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes the AVX2 inflate decoder (
decode_huffman_code_block_stateless_04) copy matches 32 bytes at a time with ymm registers instead of 16 with xmm. A match of up to 32 bytes whose distance is at least its length takes one store; a match whose distance is less than both 32 and its length still goes throughsmall_byte_copy. The main-loop output slop grows from 274 to 290 bytes, exactly enough for the longest stores.This applies to every x86-64 CPU with AVX2;
_01assembles to the same code as on master.Output
Decoded output does not change. On main-loop
ISAL_INVALID_LOOKBACKandISAL_INVALID_SYMBOLfailures, where master already miscounts (#446), statelessavail_outcomes out 290 bytes short instead of 274, and the leftover bytes in the overcounted tail of the output differ.Conflicts
This PR conflicts with #446 in
igzip/igzip_decode_block_stateless.asm.Results
Inflate on GitHub runners, in-process A/B, two runs per runner. Each cell is master's best-of-11 MB/s and the median over runs of this PR's change in best-of-11 throughput (harness, runs 1, 2, 3). 4 KB and 1 KB isa-l L1 slices change by 1.2% or less.
Testing
make checkpasses with_04, with_01forced, and natively on Windows (mingw-w64), where 2.2 million win64 calls per decoder leave callee-saved registers and the upper ymm state clean._04faults.