《電子技術應用》
您所在的位置:首頁 > 人工智能 > 设计应用 > YJJFA:一种数据驱动的高性能正则表达式匹配算法
YJJFA:一种数据驱动的高性能正则表达式匹配算法
电子技术应用
杨嘉佳
中国电子信息产业集团有限公司第六研究所
摘要: 正则表达式匹配技术在人工智能时代背景下扮演着重要角色,尤其在数据清洗与数据抽取领域,可为大语言模型训练所需的高质量数据处理提供技术支撑。然而,传统正则表达式匹配算法存在性能瓶颈,限制了其应用范围。针对此问题,提出一种基于可信区域的高性能正则表达式匹配算法,命名为YJJFA算法。该算法通过对状态转移表划分成最优可信区域与非信任区域,减少需要处理的状态转移表输入字符数量,并借助非内存访问的非信任字符集向量比较以实现信任字符低时间消耗处理。实验结果表明,YJJFA算法在L7filter规则上的吞吐率达17.88~53.81Gb/s,较原始DFA算法性能提升了一个数量级。
中圖分類號:TP391.1 文獻標志碼:A DOI: 10.16157/j.issn.0258-7998.256942
中文引用格式: 楊嘉佳. YJJFA:一種數(shù)據(jù)驅(qū)動的高性能正則表達式匹配算法[J]. 電子技術應用,2026,52(4):102-107.
英文引用格式: Yang Jiajia. YJJFA: a data-driven high-performance regular expression matching algorithm[J]. Application of Electronic Technique,2026,52(4):102-107.
YJJFA: a data-driven high-performance regular expression matching algorithm
Yang Jiajia
The Sixth Research Institute of China Electronics Corporation
Abstract: Under the background of the artificial intelligence era, regular expression matching technology plays a crucial role, particularly in data cleansing and data extraction domains, where it provides technical support for high-quality data processing required by large language model training. However, traditional regular expression matching algorithms suffer from performance bottlenecks that limit their application scope. To address this challenge, this paper proposes a data-driven high-performance regular expression matching algorithm, denoted as YJJFA algorithm. The algorithm reduces the number of input characters that need to be processed in the state transition table by partitioning it into optimal trusted regions and untrusted regions, while leveraging non-memory-access vector comparisons of the untrusted character set (UBCS) to achieve low-time-cost processing of trusted characters. Experimental results show that the YJJFA algorithm achieves a throughput rate of 17.88~53.81 Gb/s on L7filter rules, representing an order-of-magnitude performance improvement over conventional DFA implementations.
Key words : regular expression matching;trusted zones;high-performance;data cleansing

引言

作為大數(shù)據(jù)處理的重要技術手段之一,正則表達式(以下簡稱“正則”)因其強大的描述表達能力,在復雜數(shù)據(jù)的掃描處理中扮演重要角色。在人工智能時代背景下,正則表達式可以用于數(shù)據(jù)數(shù)據(jù)清洗、數(shù)據(jù)檢索等應用場景。此外,較為典型的應用還包括:基于正則表達式實現(xiàn)系統(tǒng)日志的特征提取、入侵檢測系統(tǒng)配置正則表達式實現(xiàn)網(wǎng)絡流量的深度檢測預警,以及利用正則表達式進行基因組序列數(shù)據(jù)的發(fā)現(xiàn)等。

當前,正則表達式的主流實現(xiàn)可分為非確定型有限自動機(Nondeterministic Finite Automata, NFA)[1]和確定型有限自動機(Deterministic Finite Automata, DFA)兩種方式[2]。假設模式長度為m,那么NFA的空間復雜度僅為線性級,但最壞情況下的時間復雜度可能為指數(shù)級。而DFA通過狀態(tài)轉移保證處理一個字符只消耗一次狀態(tài)轉移,卻有可能面臨著狀態(tài)空間爆炸問題。

實際上,在大數(shù)據(jù)和人工智能時代,一次狀態(tài)轉移只消耗一個字符的性能已遠無法滿足大規(guī)模數(shù)據(jù)處理的性能需求。因此,如何提高DFA的匹配性能成為了本文研究的重點。為提高DFA的匹配性能,本文提出一種基于可信區(qū)域高性能正則表達式數(shù)據(jù)加速匹配算法:通過將DFA狀態(tài)轉移表劃分出最優(yōu)信任區(qū)域減少非信任列的數(shù)量,同時利用輸入字符與非信任列在指令層級的比對,最大限度獲得可略過的字符數(shù),減少內(nèi)存訪問的次數(shù)。


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

http://www.ihrv.cn/resource/share/2000007046


作者信息:

楊嘉佳

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

2.jpg

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