1
Farzana Ahmed Siddique, Tommy James Tracy II, Nathan Brunelle, Kevin Skadron
University of Virginia
7th December 2022
Deterministic vs. Non-deterministic Finite Automata in Automata Processing
Automata Processing for Pattern Matching
MOTIVATION
2
Network Security
Genomics
Machine Learning
Regex
Finite State Automata
Anti Virus
Grapefruit’ 20
Impala’ 20
SPM’ 16
REAPR’ 19
Hybrid-FA’ 07
Hyperscan’ 19
Hardware
von Neumann Architecture
(CPU, GPU)
Spatial Architecture (FPGA, ASIC)
Finite Automata Variants
MOTIVATION
3
Network Security
Genomics
Machine Learning
Anti Virus
Regex
Finite State Automata
Hardware
Deterministic Finite Automata (DFA)
Non-deterministic Finite Automata (NFA)
von Neumann Architecture
(CPU, GPU)
Spatial Architecture (FPGA, ASIC)
It is important to carefully choose an optimal hardware and computation model pair, to design an efficient pattern matching engine.
Differences in Finite Automata Variants
MOTIVATION
4
1
3
2
b
a
a
4
a,b
b
a,b
1
3
4
2
b
a
a
b
DFA
NFA
DFA can be more compact than the NFA?!
MOTIVATION
5
DFA’s state count is greater than or equal to the NFA.
[1] D. Tabakov, MY. Vardi,LPAR’ 05
[2] For each symbol, ratio of the total number of transition to the total number of states.
This paper answer this question!
Experiments
6
Benchmark/Application Used
EXPERIMENTS
7
Benchmark/Application | #Patterns |
Brill | 5,946 |
Snort | 2,348 |
ClamAV | 33,000 |
Hamming | 1,000 |
Levenshtein | 1,000 |
Random Forest | 8,000 |
1. State Count Analysis: Minimized DFA vs. Optimized NFA
8
Methodology
STATE COUNT ANALYSIS: MINIMIZED DFA VS. OPTIMIZED NFA
9
State Count Analysis
Individual Pattern
Multiple Pattern
DFA Minimization
STATE COUNT ANALYSIS: MINIMIZED DFA VS. OPTIMIZED NFA
10
NFA Optimization
STATE COUNT ANALYSIS: MINIMIZED DFA VS. OPTIMIZED NFA
11
NFA Optimization: Example
STATE COUNT ANALYSIS: MINIMIZED DFA VS. OPTIMIZED NFA
12
2
1
12
16
13
17
3
4
15
19
14
18
101
101
101
116
116
97
97
108
114
2
1
12
16
3
4
15
19
14
18
101
116
116
97
97
108
114
101
101
2
1
12
3
4
15
19
14
18
101
116
116
97
97
108
114
101
NFA Optimization: Example
STATE COUNT ANALYSIS: MINIMIZED DFA VS. OPTIMIZED NFA
13
2
1
12
3
4
15
19
14
101
116
116
97
108
114
101
Complexity : O(n2)
n = #states in the NFA.
2
1
3
4
15
19
14
101
116
116
97
108
114
NFA Optimization
STATE COUNT ANALYSIS: MINIMIZED DFA VS. OPTIMIZED NFA
14
Findings (Individual Patterns)
STATE COUNT ANALYSIS: MINIMIZED DFA VS. OPTIMIZED NFA
15
Snort
ClamAV
Findings (Individual Patterns)
STATE COUNT ANALYSIS: MINIMIZED DFA VS. OPTIMIZED NFA
16
Brill
Levenshtein
Findings (Individual Patterns)
STATE COUNT ANALYSIS: MINIMIZED DFA VS. OPTIMIZED NFA
17
Hamming
DFAs generated for individual patterns are comparable to the equivalent NFAs in state count.
Findings (Multiple Patterns)
STATE COUNT ANALYSIS: MINIMIZED DFA VS. OPTIMIZED NFA
18
DFAs generated by merging patterns can be expensive in terms of conversion time and state count.
The Paper That Motivated This
19
2. DFA vs. NFA Performance Analysis on FPGA
20
Grapefruit
DFA VS. NFA PERFORMANCE ANALYSIS ON FPGA
21
FPGA Architecture (taken from Xilinx website)
Automata Mapped to LUTs
1. STE represents a state and the symbols that activates that state.
2. STE is implemented using Look up tables (LUT).
Methodology
DFA VS. NFA PERFORMANCE ANALYSIS ON FPGA
22
NFA vs. DFA Performance Analysis on FPGA
Minimized DFA
Optimized NFA
Findings
DFA VS. NFA PERFORMANCE ANALYSIS ON FPGA
23
Benchmark | Computation Model | Max Fan-Out | Avg Node Degree |
YARA | NFA | 133 | 1.1 |
YARA | DFA | 5 | 1.1 |
ER | NFA | 3 | 3.5 |
ER | DFA | 3 | 3 |
High Fan-Out a Performance Bottleneck
DFA VS. NFA PERFORMANCE ANALYSIS ON FPGA
24
Why High fan-out or node degree works as a performance bottleneck for FPGA?
Throughput
Frequency
Benchmarks that have high fan out or node degree for NFA, may use DFAs while processing on FPGA
3. CPU vs. FPGA Performance Analysis
25
Hyperscan
CPU VS. FPGA PERFORMANCE ANALYSIS
26
Hyperscan Regex Decomposition
Methodology
CPU VS. FPGA PERFORMANCE ANALYSIS
27
Performance Analysis: CPU vs. FPGA
CPU
FPGA
Findings
CPU VS. FPGA PERFORMANCE ANALYSIS
28
Why Grapefruit Performs Poorly for Some Benchmarks?
CPU VS. FPGA PERFORMANCE ANALYSIS
29
Hyperscan’s throughput is sensitive to pattern matching rate!
CPU VS. FPGA PERFORMANCE ANALYSIS
30
Pick a symbol (x) from the accepted symbol list
X is accepted by the state
X is not accepted by the state
Terminate
Empty state list
Nonempty state list
Summary
CONCLUSION
31
1. If we keep the patterns separate, minimized DFAs are comparable in state count to their equivalent optimized NFAs. However, generating a large DFA for an entire application is infeasible.
2. DFAs can also be used as computation model for FPGA and can outperform NFAs on FPGA.
3. Compared to FPGA-based automata processing engine, the performance of CPU-based is application and workload sensitive.
Thanks!
QUESTION?
32
Acknowledgement: Tommy Tracy, Abdullah Tahsin Mughrabi, Alif Ahmed, Kevin Skadron