Repository navigation
Conversation
ebiggers
force-pushed
the
dev
branch
7 times, most recently
from
November 10, 2026 06:32
7388149 to
fa387b0
Compare
Replace the 'optimum_nodes' array, which was an array of pairs of u32, with two arrays of u32. deflate_find_min_cost_path() does up to 256 consecutive reads from 'cost_to_end' for each write it does to 'cost_to_end' and 'item'. Making the 'cost_to_end' values contiguous enables SIMD optimizations without having to deinterleave the fields. This also works well for deflate_tally_item_list() and deflate_flush_block(), which only use 'item', not 'cost_to_end'.
The sizing of the 'cost_to_end' array currently relies on the fact that deflate_compress_near_optimal() can choose a block_length very close to MAX_BLOCK_LENGTH only at the very end of the input buffer. In that case there will be no matches extending past block_length, so the usual sentinel entries in 'cost_to_end' are unneeded. It's correct, but a bit subtle. Let's just reserve the extra 257 entries (which is negligible when the array already had size 305000), and omit the MIN() in deflate_optimize_and_flush_block(). This way, this subtle assumption about MAX_BLOCK_LENGTH goes away.
ebiggers
force-pushed
the
dev
branch
5 times, most recently
from
November 10, 2026 07:19
735a41d to
db26939
Compare
Introduce AVX2 (x86_32 and x86_64) and NEON (arm64 only for now)
optimized implementations of deflate_find_min_cost_path().
These implementations use vector instructions to handle the
consideration of multiple lengths for the same match offset much more
efficiently than the scalar code did.
Some benchmark results at compression level 12:
- 43% higher compression throughput on an x86_64 AMD Ryzen 9950X
(Zen 5) processor
- 27% higher compression throughput on an arm64 C1-Ultra processor
The resulting compressed data remains identical.
The portable implementation is made faster as well, as it's restructured
to the more efficient form that matches the AVX2 and NEON code.
deflate_optimize_and_flush_block() computes the frequency of each byte in the uncompressed block twice: once in deflate_choose_all_literals() and once in deflate_set_initial_costs(). This is redundant. Move deflate_set_initial_costs() up before the static block check (which overwrites c->freqs) and make it reuse c->freqs from deflate_choose_all_literals().
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.
No description provided.