SIMD Mask Table Encoding for Character Class Matching
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing regex matching solutions, such as Hyperscan, Perl Compatible Regular Expressions (PCRE), and Regular Expression 2 (RE2), rely on non-deterministic finite automaton (NFA) and deterministic finite automaton (DFA) for character class matching, which are inefficient and sensitive to the number of characters in the character class, leading to suboptimal performance.
Innovation Solution
Implementing G-Model and F-Model encoding and decoding schemes using SIMD instructions for parallel processing of character class matching, which utilize 4-row/64-column and 1-row/128-column mask tables, respectively, to accelerate character class matching by leveraging processor capabilities like Intel® and AMD® processors with AVX-512 SIMD instructions.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If traditional NFA or DFA algorithms are used for character class matching, then the matching logic is straightforward to implement, but the performance degrades significantly as the character class size increases
Solution Approach 1:
The patent applies preliminary action by pre-computing and storing character class membership information in encoding tables before the actual matching process. The encoding phase creates lookup tables that map characters to their class memberships, which are then used during decoding/matching without re-computation. This shifts the computational burden from the matching phase to the preprocessing phase, significantly improving real-time matching performance.
Solution Approach 2:
The patent introduces encoding tables as an intermediary data structure between the character class definition and the matching process. These tables serve as a mediator that translates character class specifications into a format optimized for parallel processing. The intermediary tables enable the matching algorithm to quickly determine character class membership without directly evaluating the original character class syntax during matching.
2Productivity
If character-by-character comparison is used for each character in the character class, then the implementation is simple, but the number of comparisons increases linearly with character class size
Solution Approach 1:
The patent merges multiple character comparisons into a single parallel operation by using SIMD instructions. Instead of comparing each character in the input data against each character in the character class sequentially, the encoding tables consolidate character class membership information such that a single parallel lookup operation can determine membership for multiple characters simultaneously. This merging of comparison operations dramatically reduces the total number of comparisons needed.
Solution Approach 2:
The patent substitutes the mechanical character-by-character comparison process with a table lookup mechanism enhanced by SIMD instructions. Rather than physically comparing each character pair, the system uses pre-computed encoding tables and parallel bit manipulation to determine character class membership. This substitution replaces sequential mechanical comparison with parallel table-driven lookup, significantly improving matching speed.
3Adaptability or versatility
If the character class size increases, then the filtering capability improves, but the sensitivity and processing time increase
Solution Approach 1:
The patent transitions from a one-dimensional sequential comparison approach to a multi-dimensional parallel processing approach. By organizing character class membership information in multi-dimensional encoding tables and using SIMD instructions that operate on multiple data elements simultaneously, the system adds parallelism as a new dimension to the matching process. This allows the system to handle larger character classes efficiently by distributing the comparison workload across multiple parallel processing lanes.
Data Source
AI summary
Examples include techniques to encode and decode for character class matching. A character class including a plurality of characters may be encoded in a mask table. A sampled chunk of input data is used to perform a decode operation to check, in a parallel manner, each character included in the input data with the encoded mask table. The checking of each character in the input data to determine whether at least one character in the input data matches a character included in the character class.


