Skip to content

Commit 2ba5a31

Browse files
committed
Support byte ranges in binary patterns
Allow non-empty lists of inclusive byte-range tuples in binary:compile_pattern/1 and the binary match, matches, split, and replace operations. Normalize overlapping ranges and compile them to the new br pattern type. Use SIMD for up to 16 normalized entries, with equality checks for singletons and one-sided comparisons for ranges touching 0 or 255. Use the 256-byte membership table for tails, unsupported SIMD targets, and larger range sets. ASCII validation throughput on arm64 macOS (million calls/s): SIMD Unicode SWAR Guard Valid ASCII 14.40 2.74 2.74 0.41 Invalid last 13.78 3.00 2.74 0.41 Invalid first 42.30 148.81 91.83 104.38 SIMD is the one added by this pull request, Unicode stands for the current unicode:bin_is_7bit/1. Guard is the equivalent guard imlpementation and the SWAR one is an optimized version of that. The native unicode:bin_is_7bit/1 can be removed in a future commit. As shown in the benchmarks above, the new byte ranges are clear winners for validating data, as most times you are expecting to fully traverse binaries without matches. For parsing, byte ranges can be faster than guards, but may be beaten by SWAR on certain payloads.
1 parent 085efcf commit 2ba5a31

8 files changed

Lines changed: 674 additions & 36 deletions

File tree

erts/emulator/beam/atom.names

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ atom blocked_normal
147147
atom bm
148148
atom bnot
149149
atom bor
150+
atom br
150151
atom bxor
151152
atom break_ignored
152153
atom breakpoint

0 commit comments

Comments
 (0)