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
marked this pull request as ready for review
October 30, 2026 21:07
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.
The AVX2 inflate decoder (
decode_huffman_code_block_stateless_04) copies matches 32 bytes at a time with ymm registers instead of 16 with xmm, so a match of up to 32 bytes whose distance is at least its length takes one store. Matches whose distance is less than both 32 and their length still go throughsmall_byte_copy. The main-loop output slop grows from 274 to 290 bytes._01does not change.Decoded output does not change. On main-loop
ISAL_INVALID_LOOKBACKandISAL_INVALID_SYMBOLfailures, which master already miscounts (#446), statelessavail_outcomes out 290 bytes short instead of 274.This PR conflicts with #446 in
igzip/igzip_decode_block_stateless.asm.Results
Inflate MB/s on GitHub runners: master's best of 11 rounds, and this PR's median change over two in-process A/B runs per runner (harness; runs 1, 2, 3). 4 KB and 1 KB slices change by 1.2% or less.
Testing
make checkpasses with_04and 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 with a slop one byte smaller.