perf: optimize SIMD check and encode implementations#39
Merged
Conversation
Replace check algorithm with signed overflow trick for large inputs (≥128 bytes). Add AVX2 check path processing 32 bytes per iteration. Double encode throughput (32→64 bytes/iter) via new AVX2 path. References: - http://0x80.pl/notesen/2022-01-17-validating-hex-parse.html
Merging this PR will degrade performance by 30.01%
Performance Changes
Comparing |
Apply Muła & Langdale signed overflow trick to SSE2 check path too, reducing from 10 to 5 operations per chunk. Remove length threshold dispatch since both paths now use the same efficient algorithm.
Extract check_chunk_sse2 and use it directly in check_avx2's remainder handler instead of calling check_sse2 which goes through chunks_exact. Since the AVX2 remainder is at most 31 bytes, there's at most one 16-byte chunk — no need for a loop.
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.
Replace check algorithm with signed overflow trick for large inputs (≥128 bytes). Add AVX2 check path processing 32 bytes per iteration. Double encode throughput (32→64 bytes/iter) via new AVX2 path.
References:
Split from #35, credit to @zerosnacks.