Commit 2ba5a31
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
- jit/x86
- lib
- compiler
- src
- test
- stdlib
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| |||
0 commit comments