Add AVX2 escape kernels with runtime dispatch - #45
Merged
Merged
Conversation
x86_64 escaping previously used only baseline SSE2 (16-byte lanes). Add AVX2 variants of the escape-only and fused validate+escape kernels that scan 32 bytes per iteration, selected at runtime via is_x86_feature_detected! (cached by std_detect) since precompiled binaries target baseline x86-64. SSE2 remains the fallback and handles the sub-32-byte tail. Verified against the scalar reference on 24k boundary-adversarial and fuzzed cases per arch (native NEON, Rosetta SSE2, QEMU AVX2).
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.
Summary
escape.rs: the escape-only path used for atom keys and the fused UTF-8-validate + escape path used for binary strings. They mirror the SSE2 structure exactly — classify control/"/\bytes with a vector compare, bulk-store clean chunks, handle the first flagged byte viaQUOTE_TAB, and fall into byte-by-byte validation on non-ASCII chunks.is_x86_feature_detected!("avx2")(cached by std_detect after the first call), since precompiled binaries target baseline x86-64. SSE2 remains the fallback and also handles the sub-32-byte tail after the AVX2 main loop. The aarch64/NEON and scalar paths are untouched.-cpu max(AVX2 path actually executed) — all kernels agree with scalar everywhere.