SIMD-accelerate JSON string scanning in JSONLexer#1984
Open
lavenzg wants to merge 1 commit intofacebook:static_hfrom
Open
SIMD-accelerate JSON string scanning in JSONLexer#1984lavenzg wants to merge 1 commit intofacebook:static_hfrom
lavenzg wants to merge 1 commit intofacebook:static_hfrom
Conversation
Summary: Add SIMD-optimized character scanning functions (scanSpecialCharU8, scanSpecialCharU16) that find the first byte/char16_t that is '"', '\\', or <= 0x1F. Use these in JSONLexer::scanString() to skip over runs of normal characters in bulk during the escape-free hot loop. The SIMD scan applies only to ASCII and UTF16 encodings (where UsesRawPtr is true and we have a contiguous buffer with known bounds). UTF8 uses UTF16Stream which is not a raw pointer and is unaffected. Jenkins hash is handled separately: after SIMD skips a range of normal characters, the hash is computed over that range in a scalar loop, keeping the SIMD scan free of data dependencies. Implementation tiers: - NEON (aarch64): 16 bytes / 8 char16_t per iteration - SSE2 (x86-64): 16 bytes / 8 char16_t per iteration - Scalar fallback for all other platforms Differential Revision: D93549305
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:
Add SIMD-optimized character scanning functions (scanSpecialCharU8, scanSpecialCharU16) that find the first byte/char16_t that is '"', '\', or <= 0x1F. Use these in JSONLexer::scanString() to skip over runs of normal characters in bulk during the escape-free hot loop.
The SIMD scan applies only to ASCII and UTF16 encodings (where UsesRawPtr is true and we have a contiguous buffer with known bounds). UTF8 uses UTF16Stream which is not a raw pointer and is unaffected.
Jenkins hash is handled separately: after SIMD skips a range of normal characters, the hash is computed over that range in a scalar loop, keeping the SIMD scan free of data dependencies.
Implementation tiers:
Differential Revision: D93549305