Expand description
SIMD byte scanning for the HTTP parsers (owned by the simoom-http1 work). SIMD byte scanning for the HTTP parsers, with runtime detection and a scalar fallback.
The parsers ask one question many times: “how long is the run of bytes, starting here, that
belong to this class?” (a token, a request target, a field value). The first byte outside the
class is the delimiter (:, SP, CR) or an invalid byte, so finding and validating happen in
one pass. scan answers it; find_byte is a plain memchr.
Kernels: SSSE3/SSE4.2 (16 bytes per step) and AVX2 (32) on x86-64, NEON (16) on aarch64. Class
membership uses the nibble-table method: a 16-byte table indexed by the low nibble holds, per
high nibble 0..7, whether that byte is in the class, so any set of ASCII bytes is exact. Bytes
0x80..=0xFF are either all in or all out of a class. The level is detected once and cached;
force overrides it for benchmarks.
Structs§
- Byte
Class - A set of byte values, usable by every kernel.
Enums§
- Level
- A scanning implementation.
Statics§
- FIELD_
VALUE - RFC 9110 field-value bytes: HTAB, SP, VCHAR and obs-text. Stops at CR, LF, NUL, DEL and every other control byte.
- TCHAR
- RFC 9110
tchar: the bytes of a token (method, field name, transfer coding). - URI
- RFC 3986 bytes of a request target other than
%(checked separately with its two hex digits) and[](IP literals only): unreserved, sub-delims,:,@,/,?.
Functions§
- available
- True if this CPU can run
level. - field_
line - Offsets of one header field line at the start of
buf, found in a single dispatch:(name_end, value_start, value_end).name_endis the length of theTCHARrun. If the byte there is:,value_startis past the colon and any SP/HTAB, andvalue_endends theFIELD_VALUErun from there (trailing whitespace included); otherwise both equalname_end. The caller checks the bytes atname_endandvalue_end. - find_
byte - Index of the first
byteinbuf. - find_
byte_ at find_bytewith an explicit level; an unavailable level falls back to scalar.- force
- Uses
levelfrom now on, process-wide; returns false (and changes nothing) if the CPU lacks it. Meant for benchmarks and tests. - level
- The level in use: the best one this CPU supports, unless
forcechose another. - scan
- Length of the run of bytes at the start of
bufthat are inclass: the index of the first byte outside it, orbuf.len(). - scan_at
scanwith an explicit level; an unavailable level falls back to scalar.