Repository navigation
Conversation
This was referenced Oct 21, 2026
The main loop of decode_huffman_code_block_stateless_01 and _04 takes the index of the next distance lookup from read_in after the refill, so the lookup waits for the refill. Take the index before the refill, as the loop already does for the next lit/len lookup. read_in_length can be as low as 9 at that point, but the last refill loaded all 64 bits of read_in and at most 48 of them have been consumed since: 15 + 13 for a distance code and its extra bits, and 15 + 5 for a lit/len code and its extra bits. The low 16 bits of read_in already hold the stream bits that the refill would put there, so the 10-bit index, and with it the output, does not change. 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 2.4% to 6.2% faster on the Silesia files compressed by zlib -6, and 1.0% to 4.6% 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-dist-lookup
branch
from
October 21, 2026 21:27
4b9be0c to
be6d806
Compare
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 x86 inflate main loop takes the next lit/len index from
read_inbefore the input refill, but the distance index after it, so the distance lookup waits for the refill. This PR takes the distance index before the refill too.This is safe:
read_in_lengthcan be as low as 9 there, but the last refill loaded all 64 bits ofread_in, and at most 48 have been consumed since (15 + 13 for a distance code and its extra bits, 15 + 5 for a lit/len code and its extra bits), so the low 10 bits already hold the right stream bits.Both x86-64 decoders change:
decode_huffman_code_block_stateless_01(SSE4.2) and_04(AVX2). Output does not change.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% or less.
Testing
make checkpasses with_04, with_01forced, and natively on Windows (mingw-w64), where callee-saved registers stay intact over 2.2 million win64 calls per decoder.read_in_lengthdown to 9).