Vectorize JSON escaping#64
Merged
Merged
Conversation
15309fd to
126b60b
Compare
126b60b to
5efbe9f
Compare
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
Vectorize JSON byte escaping with NEON, AVX2, and AVX-512BW; eliminate per-entry heap allocation in SSTable reads; replace linear memtable scan with binary search.
Latency result (x86_64 AVX2)
Scalar is the byte-at-a-time lookup table from master. Vectorized is the SIMD scanner on this branch.
Core Components
simdcrate (new):write_escaped_json_bytesdispatches tofind_next_escape_avx512bw,find_next_escape_avx2,find_next_escape_neon, orfind_next_escape_fallbackbased on arch/CPU featuresFIND_NEXT_ESCAPE_DISPATCH: self-patchingstatic mutfunction pointer -- CPU detection runs once, subsequent calls pay one indirect jumpSstableReader: gainsdata_buf: Vec<u8>field; reused across entries viaresizeinstead of allocating per readReadSnapshot::get: linear scan overmemtable_entriesreplaced withbinary_search_by_keyPlatform Support
aarch64: NEON 16-byte lanes viavcltq_u8/vcgtq_u8/vceqq_u8, bitmask extracted withvpadd_u8+vreinterpret_u16_u8x86/x86_64: runtime dispatch viais_x86_feature_detected!; AVX-512BW processes 64 bytes/iter using__mmask64OR, AVX2 processes 32 bytes/iter usingvpmovmskb; LLVM lowers both to avpaddb+vpminub/vpcmpltubsaturation range checkHelpers
find_next_escape_raw: selects arch path at compile time--falls through tofind_next_escape_fallbackon unsupported targetsTests
simd::json