《電子技術(shù)應用》
您所在的位置:首頁 > 模擬設計 > 設計應用 > ɑFA:一種基于非信任字符比較的高性能正則表達式匹配算法
ɑFA:一種基于非信任字符比較的高性能正則表達式匹配算法
電子技術(shù)應用
楊嘉佳,關健,,于增明,,張雷,姚旺君
中國電子信息產(chǎn)業(yè)集團有限公司第六研究所
摘要: 正則表達式匹配技術(shù)在數(shù)據(jù)治理、解析提取和深度包檢測方面有著重大應用價值。然而,由于其在通用平臺上的匹配性能較低,,無法滿足實際環(huán)境下數(shù)據(jù)實時處理的應用需求,,限制了其在高性能數(shù)據(jù)處理領域的應用范圍。針對當前正則表達式匹配性能較低的問題,,提出一種基于非信任字符比較的高性能正則表達式匹配算法,,稱之為ɑFA。該算法通過每次判斷連續(xù)的若干個字符是否屬于最常被訪問狀態(tài)的非信任字符集,,獲取無需通過DFA匹配可直接跳過的字符數(shù),,減少字符匹配過程中訪問內(nèi)存DFA狀態(tài)轉(zhuǎn)移表的次數(shù),從而實現(xiàn)字符匹配的加速處理,。實驗結(jié)果表明,,ɑFA算法可獲得相比于原始DFA匹配算法約為1.05~7.58倍的性能加速比。
中圖分類號:TP391.1 文獻標志碼:A DOI: 10.16157/j.issn.0258-7998.244911
中文引用格式: 楊嘉佳,,關健,,于增明,等. ɑFA:一種基于非信任字符比較的高性能正則表達式匹配算法[J]. 電子技術(shù)應用,,2024,,50(6):57-60.
英文引用格式: Yang Jiajia,Guan Jian,,Yu Zengming,,et al. ɑFA: a high-performance regular expression matching algorithm based on untrusted character comparison[J]. Application of Electronic Technique,2024,,50(6):57-60.
ɑFA: a high-performance regular expression matching algorithm based on untrusted character comparison
Yang Jiajia,,Guan Jian,Yu Zengming,,Zhang Lei,,Yao Wangjun
The Sixth Research Institute of China Electronics Corporation
Abstract: Regular expression matching technology has significant application value in data governance, parsing extraction, and deep packet inspection. However, due to its low matching performance on general-purpose platforms, it cannot meet the application requirements of real-time data processing in practical environments, which limits its application scope in the field of high-performance data processing. In response to the current issue, a high-performance regular expression matching algorithm based on untrusted character comparison is proposed, which is called ɑFA. This algorithm determines whether a sequence of consecutive characters belongs to the untrusted character set of the most frequently accessed state. By doing so, it acquires the number of characters that can be skipped directly without DFA matching, reduces the number of accesses to the DFA state transition table in memory during character matching, and thus achieves accelerated processing of character matching. The experimental results indicate that the ɑFA algorithm can achieve a performance acceleration of approximately 1.05 times to 7.58 times compared to the original DFA matching algorithm.
Key words : regular expression matching;deterministic finite automaton,;high-performance data processing

引言

正則表達式因擁有強大的表達能力與靈活性,,在數(shù)據(jù)治理、解析提取和深度包檢測方面得到了廣泛應用,。比如著名的搜索工具grep,、sed以及入侵檢測系統(tǒng)Snort[1]都包含了很多正則表達式規(guī)則。

正則表達式匹配方法通常分為基于確定型有限自動機(Deterministic Finite Automata, DFA)和基于非確定型有限自動機(Nondeterministic Finite Automata, NFA)[2],。兩者的區(qū)別在于NFA的空間需求較少,但匹配性能較低,;DFA則相反,,匹配性能較高,但空間需求大,。

在真實數(shù)據(jù)處理環(huán)境背景下,,正則表達式的匹配性能是最重要的衡量因素之一。以狀態(tài)轉(zhuǎn)移次數(shù)計算,DFA匹配單個字符時發(fā)生一次狀態(tài)轉(zhuǎn)移,,轉(zhuǎn)移次數(shù)固定,,性能較高且較為穩(wěn)定;相反,,NFA匹配單個字符時可能會引發(fā)若干次狀態(tài)轉(zhuǎn)移,,轉(zhuǎn)移次數(shù)較多,性能較低且穩(wěn)定性較差,。因此,,現(xiàn)有的高性能匹配研究工作主要集中于如何提升DFA的匹配性能。

截止目前,,各式各樣的DFA加速匹配方法已被提出[3],,包括經(jīng)典的多步長自動機、多核平臺并行匹配加速,、基于枚舉方法的SIMD加速,、基于推測與枚舉方法相結(jié)合的新型并行化匹配方法等。但是,,這些算法在加速匹配過程中需多次訪問內(nèi)存導致較大的時間開銷,,因而性能還有進一步提升的空間。

因此,,本文專注于DFA的匹配性能問題,,提出了一種基于非信任字符比較的高性能正則表達式匹配算法。通過每次判斷連續(xù)的若干個字符是否屬于最常被訪問狀態(tài)的非信任字符集,,獲得無需通過DFA匹配可直接跳過的字符數(shù),,從而實現(xiàn)DFA的加速處理。理論分析與實驗結(jié)果表明,,此算法可達到原始DFA性能加速比的1.05~7.58倍,。


本文詳細內(nèi)容請下載:

http://forexkbc.com/resource/share/2000006031


作者信息:

楊嘉佳,關健,,于增明,,張雷,姚旺君

(中國電子信息產(chǎn)業(yè)集團有限公司第六研究所,,北京 100083)


Magazine.Subscription.jpg

此內(nèi)容為AET網(wǎng)站原創(chuàng),,未經(jīng)授權(quán)禁止轉(zhuǎn)載。