compress: Elide long-offset path on 64-bit - #4772
Open
uarif1 wants to merge 1 commit into
Open
Conversation
ZSTD_seqToCodes() only enables longOffsets on 32-bit builds because the 64-bit bitstream accumulator can hold every supported offset. However, ZSTD_encodeSequences_body() still tests the runtime flag for the first sequence and every sequence in its hot loop. Make the architecture condition explicit at both branches so 64-bit compilers can discard the unreachable path. Add an assertion documenting the invariant while preserving the existing 32-bit behavior. In five alternating GCC 11.5 fullbench runs encoding sequences for an 8 MiB, 50%-compressible level-3 sample, throughput increased from 1201.6 to 1213.4 MB/s on average (+1.0%) with identical 2,706,887-byte output. The fullbench text section also shrank by 512 bytes. Signed-off-by: Usama Arif <usama.arif@linux.dev>
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.
ZSTD_seqToCodes() only enables longOffsets on 32-bit builds because the 64-bit bitstream accumulator can hold every supported offset. However, ZSTD_encodeSequences_body() still tests the runtime flag for the first sequence and every sequence in its hot loop.
Make the architecture condition explicit at both branches so 64-bit compilers can discard the unreachable path. Add an assertion documenting the invariant while preserving the existing 32-bit behavior.
In five alternating GCC 11.5 fullbench runs encoding sequences for an 8 MiB, 50%-compressible level-3 sample, throughput increased from 1201.6 to 1213.4 MB/s on average (+1.0%) with identical 2,706,887-byte output. The fullbench text section also shrank by 512 bytes.